Help Simple Code

 

hi,

can anyone explain me how to do this simple code:

i have an expert advisor, and i have to tell him to stop open new trades for a certain period of time.

practically after that the program close le last trade , this code must stop the ea for a while(like 30m o 1h).

sorry fot the bad english 

thanks  

 
/* 1) */  Sleep(30*60000); // 30 min, but NOT so good!

/* 2) */ datetime NextTrade = 0; // globally defined
         ...
         OnTick(){
             ... 
             if (TimeCurrent() < NextTrade) return;
             ...

             If (Stop30Min) NextTrade = TimeCurrent()+30*60; // for 30 min
             ...
 

thanks

i read in this forum that sleep doesn't work in the tester

is that true? 

 

 

 
goghi:

i have an expert advisor, and i have to tell him to stop open new trades for a certain period of time.

practically after that the program close le last trade , this code must stop the ea for a while(like 30m o 1h).

i read in this forum that sleep doesn't work in the tester


  1. Check if any order has been open more more than x and close it. (OrderSelect loop and OrderOpenTime)
  2. Check if you have a trades open before you open a new one. (Same OrderSelect loop)
  3. Does not.
  4. EAs must be coded to recover. PC reboot, accidental terminal close, etc. Any of those and you've lost the sleep, or Gooly's NextTrade. How are you going to resume?

 
goghi:

thanks

i read in this forum that sleep doesn't work in the tester

is that true? 

 

 

look it up in the reference. 'should be ones habit: read the reference,Book, Documentation (links at the top of the page!) or google before asking!

 

thank for helping me

i have a last question

why this works :double Buy3_1 = iRSI(NULL, 0, 5, PRICE_CLOSE, Current + 0);

and this doesn't : double Buy5_1 = iDeMarker(NULL, 0, 5, 1, PRICE_CLOSE, Current + 0);

i can't understand

it says 'iDeMarker' - wrong parameters count

 

the same thing happens with MFI 

 

ps I searched for the answer in this forum but I have not found the solution 

 

If you look at iRSI in the documentation, you'll see that it takes 5 parameters (symbol, timeframe, period, applied price and shift).

If you look at iDeMarker in the documentation, you'll see that it takes only 4 parameters (symbol, timeframe, period and shift).

You've provided too many parameters, hence the error. 

Reason: