I have an EA that runs on the 4 hour chart and opens trade in a grid based on the new candle formation on the 15 minute timeframe.
I am trying to limit the number of trades the EA takes by only allowing a certain number of trades on the 15 minute candle from the 4 hour chart.
For example a new 15 minute bar forms and EA adds 2 trades waits for new 15 minute bar and signal and opens 2 more trades etc…
Can anyone lead me to the right direction to do this? Thank you in advance for your help.
My code for new candle formation:
double lastClose;
bool IsNewCandle()
{
if (iClose(_Symbol,PERIOD_15,1) == lastClose){
return (false);}
if(iClose(_Symbol,PERIOD_15,1)!=lastClose){
lastClose=iClose(_Symbol,gttimeframe,1);
return(true);}
return(false);
}