I try to learn, spent always every free hour I have to learn more.
Paying a coder is not a problem but I prefer learning myself by getting good tips from developers who have past my stadium ;-)
Nature problem: when Indi give signal after first x seconds of new bar, signal must be ignored.
I read different things about it. Possibility of use OnTimer and also that it is not possible.
Could I continue with the sample source or is that not gonna work?
Thank you for your time.
#property strict #define magicnumber 123 input double lots=1; // Lot: input int sleep=30000; // Sleep, in milliseconds: int OnInit() { return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { } void OnTick() { static datetime LastBar=0; if(Time[0]!=LastBar) { LastBar=Time[0]; int tmeLeft=PeriodSeconds()-1 -(int)(TimeCurrent()-Time[0]); EventSetTimer(tmeLeft); } } void OnTimer() { int order; double customindarrow0 = iCustom(Symbol(),0,"cia",0,0); double customindarrow1 = iCustom(Symbol(),0,"cia1",1,0); if(customindarrow0!=0.0) { order=OrderSend(Symbol(),OP_BUY,lots,Ask,0,0,0,"custom buy arrow",magicnumber,0,Blue); Sleep(sleep); if(order==0) { Print("Error Opening Buy Order: ",GetLastError()); } else if(order>0) { Print("Buy Order Opened"); } } if(customindarrow1!=0.0) { order=OrderSend(Symbol(),OP_SELL,lots,Bid,0,0,0,"custom sell arrow",magicnumber,0,Red); Sleep(sleep); if(order==0) { Print("Error Opening Sell Order: ",GetLastError()); } else if(order>0) { Print("Sell Order Opened"); } } EventKillTimer(); }
digisoft:
Can anyone tell what is the best coding for taking trades only in the first 5 (or x) seconds of the current/new candle?
Any help aprreciated!
Thanks.
Maybe:
if(TimeCurrent()<=Time[0]+X) { }
If you are trying to guarantee that the broker will fill the placed order in the first 5 seconds of the new bar, you are fighting a losing battle. From what I have heard, that is hit or miss in the best of situations. If you are only trying to send the order within the first 5 seconds of the new bar, this could possibly work.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can anyone tell what is the best coding for taking trades only in the first 5 (or x) seconds of the current/new candle?
Any help aprreciated!
Thanks.