I want to stop EA in Dec, Jan only

 

I want to stop order by some moths.

For example, from Feb to Nov, EA will trade but in Dec and Jan, EA stop trade.

I put Stop moths in the array.

If buy signal>0 and check to see if it is trade month or not.

However, it is not working properly.

Can you give me some advices what the problem is?


 int month_stop[]={1,12};
 
  for(int j=0;j<2;j++){
         
 int EA_stop_month=month_stop[j];  
          if(buy_signal>0 &&month_stop[j]!=Month())
{ BUY trade() ******;}

}
 

Do not double post.

I have removed your other post.

 
kajironpu:

I want to stop order by some moths.

For example, from Feb to Nov, EA will trade but in Dec and Jan, EA stop trade.

I put Stop moths in the array.

If buy signal>0 and check to see if it is trade month or not.

However, it is not working properly.

Can you give me some advices what the problem is?


Maybe I'm just blind (I haven't checked your code) but I don't see anything why your code doesn't work properly. Try something like this:
   int month_stop[]={1,12};
   int month_current=Month();
   int month_count=ArraySize(month_stop);
   
   for(int j=0;j<month_count;j++)
      if(month_current==month_stop[j]) return;
   
   if(buy_signal>0)
      { BUY trade() ******;}
 

Petr

Thank you so much for your advice.

I got it with your code.

If current month ==stop month,  then not go to next code (return).

If current month !=stop month, just go to next code  ->buy/sell condition.

That is good idea. Thank you very much.

Reason: