Help Simple Code

Back to topics list To post a new topic, please log in or register
avatar
5
goghi 2015.01.05 21:32
 

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  

avatar
2017
gooly 2015.01.05 22:41 #
 
/* 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
             ...

avatar
5
goghi 2015.01.05 22:56 #
 

thanks

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

is that true? 

 

 

avatar
12985
WHRoeder 2015.01.05 22:59 #
 
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?

avatar
2017
gooly 2015.01.05 23:20 #
 
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!


avatar
5
goghi 2015.01.07 23:05 #
 

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 

avatar
735
honest_knave 2015.01.07 23:14 #
 

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. 

 

Back to topics list  

To add comments, please log in or register