What Code Do I Use To Set EA To Only Work On 30M Chart?

 

I have an EA and I just want it to work on the 30M chart eventhough it is on a 1H or 5M. Or diplay it only work on a 30 M chart. This is so I do not need to keep remembering which Timeframe I use on each EA I use. How do I code this??

Thanks

 
eatrader:
I have an EA and I just want it to work on the 30M chart eventhough it is on a 1H or 5M. Or diplay it only work on a 30 M chart. This is so I do not need to keep remembering which Timeframe I use on each EA I use. How do I code this?? Thanks

EA will only work on the chart it's attached to. However, if your EA is using indicators you can code them to call their values from a time frame other than the chart they are attached to.

Example would be if your EA is on a 1H or a 5M chart you could call a moving average from a 30M time frame.

iMA(NULL,PERIOD_M30,13,0,MODE_SMMA,PRICE_CLOSE,0);

Hope this helps.

 

Or you can do this to avoid plotting the EA on the wrong chart

Start()

{

if(Period()!=30){Comment("Wrong time frame! M30 only");return(-1);}

}

Reason: