stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Utility Procedures / Code Snippets
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=166
Page 4 of 7
Author:  babalu4u [ Sun Nov 25, 2012 9:25 am ]
Post subject:  Re: Utility Procedures / Code Snippets

Function to add extra buffer in indicator....

Code: Select all

double tableau1[];
double tableau2[];
:
int start()
  {
     if (!ResizeBuffer(tableau1, Bars)) return;
     if (!ResizeBuffer(tableau2, Bars)) return;
:
///////////////////////////////////////////////////////////////////////////////
bool    ResizeBuffer(double& buffer[], int size){
    if (ArraySize(buffer) != size){
        ArraySetAsSeries(buffer, false);    // Shift values B[2]=B[1]; B[1]=B[0]
        if (ArrayResize(buffer, size) <= 0){
            Alert("ArrayResize [1] failed: ", GetLastError());
            return(false);  }
        ArraySetAsSeries(buffer, true);
    }
    return(true);
}
Author:  mobthehop [ Sun Nov 25, 2012 1:13 pm ]
Post subject:  Re: Utility Procedures / Code Snippets

Thanks for sharing!
Author:  icon [ Mon Dec 31, 2012 1:12 am ]
Post subject:  Re: Utility Procedures / Code Snippets

I have a function that use significant processing from the computer , and I plan to test the code I am coding on different pairs and different timeframes .
My question : is there a way to force one EA to use that function at a time , its more or less making one EA active at a time .
Any advice is highly appreciated
Author:  AnotherBrian [ Mon Dec 31, 2012 2:42 am ]
Post subject:  Re: Utility Procedures / Code Snippets

icon wrote:I have a function that use significant processing from the computer , and I plan to test the code I am coding on different pairs and different timeframes .
My question : is there a way to force one EA to use that function at a time , its more or less making one EA active at a time .
Any advice is highly appreciated
Just pitching an idea here, use global variables. Just not sure how you would do it, but globals allow EA's to talk to each other.
Maybe using a list of the pairs and cycle thru them. Or use a chartID, something like this
ChartID = WindowHandle(Symbol(), Period());
I use it to allow the EA to identify itself.

Not a complete idea but it should get you thinking....
Author:  icon [ Mon Dec 31, 2012 2:54 am ]
Post subject:  Re: Utility Procedures / Code Snippets

AnotherBrian wrote:
icon wrote:I have a function that use significant processing from the computer , and I plan to test the code I am coding on different pairs and different timeframes .
My question : is there a way to force one EA to use that function at a time , its more or less making one EA active at a time .
Any advice is highly appreciated
Just pitching an idea here, use global variables. Just not sure how you would do it, but globals allow EA's to talk to each other.
Maybe using a list of the pairs and cycle thru them. Or use a chartID, something like this
ChartID = WindowHandle(Symbol(), Period());
I use it to allow the EA to identify itself.

Not a complete idea but it should get you thinking....
Thanks AnotherBrian , yes seems like a good idea
Author:  KevinT [ Thu Mar 14, 2013 3:31 pm ]
Post subject:  Re: Utility Procedures / Code Snippets

Hi Coders :oops:

What about a usefull procedure for DUMMIES :P ?

- How to disable dialog box displaying when "compiled code" is dragged upon a chart (so that no further confirmation is requested by the EA/script before it's executed right away...)

Regards,

Kevin
Author:  Durante [ Thu Mar 14, 2013 4:20 pm ]
Post subject:  Re: Utility Procedures / Code Snippets

Code: Select all

//#property show_inputs
Not exactly sure what you mean but if you have something like this near the top of your script you could delete it
Author:  forextrader-radioman [ Thu Mar 14, 2013 5:10 pm ]
Post subject:  Re: Utility Procedures / Code Snippets

(sorry, wrong forum ... moved my posting...)

Dietmar
Author:  KevinT [ Fri Mar 15, 2013 3:36 am ]
Post subject:  Re: Utility Procedures / Code Snippets

Durante wrote:

Code: Select all

//#property show_inputs
Not exactly sure what you mean but if you have something like this near the top of your script you could delete it
Thanks Durante,

Commenting out #property show_inputs, nailed it for the scripts :D

As for the EAs (at least some SH eas ;)) other method of calling the dialog box must have been used! :cry:
Author:  AnotherBrian [ Tue Jul 16, 2013 3:11 am ]
Post subject:  Line Description

Since Empty4 doesn't specifically tell us we can add a description to a line using code, I never tried to do it and thought it was another shortfall, until recently!

If you read the help from the MT objects functions you would think that you can only use this function call on OBJ_LABELs and OBJ_TEXT but that's not the case, when ever you create any objects you can fill in the description field too.

With the Show Object Descriptions enabled in options, you can not only show the object names on the chart but do it within your program with out having to go to the dialogue box to type in the name in the description field.

Create a line object with in your code and add this line right after you create the line object

Code: Select all

ObjectSetText( Object Name, string discription, 0, "", CLR_NONE);
You can only fill the description field when you create the object and you can not change it afterwards.
All times are UTC Page 4 of 7