Utility Procedures / Code Snippets

User avatar
babalu4u
Trader
Posts: 173
Joined: Fri Apr 13, 2012 6:52 pm
Location: Slovenia - EU

Re: Utility Procedures / Code Snippets

Post by babalu4u »

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);
}
User avatar
mobthehop
Trader
Posts: 362
Joined: Wed Nov 16, 2011 12:16 am

Re: Utility Procedures / Code Snippets

Post by mobthehop »

Thanks for sharing!
icon
Trader
Posts: 18
Joined: Thu Apr 12, 2012 4:49 pm

Re: Utility Procedures / Code Snippets

Post by icon »

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
AnotherBrian

Re: Utility Procedures / Code Snippets

Post by AnotherBrian »

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....
icon
Trader
Posts: 18
Joined: Thu Apr 12, 2012 4:49 pm

Re: Utility Procedures / Code Snippets

Post by icon »

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
User avatar
KevinT
Trader
Posts: 113
Joined: Fri Jan 06, 2012 4:23 am

Re: Utility Procedures / Code Snippets

Post by KevinT »

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
User avatar
Durante
Trader
Posts: 26
Joined: Wed Dec 28, 2011 11:59 am
Location: Brisbane, Australia

Re: Utility Procedures / Code Snippets

Post by Durante »

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
User avatar
forextrader-radioman
Trader
Posts: 156
Joined: Sun Nov 27, 2011 11:11 am
Location: Hamburg/Germany

Re: Utility Procedures / Code Snippets

Post by forextrader-radioman »

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

Dietmar
Last edited by forextrader-radioman on Fri Mar 15, 2013 7:09 am, edited 1 time in total.
„Reality is merely an illusion, albeit a very persistent one.” (Albert Einstein) "Realität ist lediglich eine Illusion, allerdings eine sehr hartnäckige."
User avatar
KevinT
Trader
Posts: 113
Joined: Fri Jan 06, 2012 4:23 am

Re: Utility Procedures / Code Snippets

Post by KevinT »

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:
AnotherBrian

Line Description

Post by AnotherBrian »

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.
Post Reply

Return to “Coders Hangout”