https://www.mql5.com/en/forum/141967
}
the above link show the example of time condition is used,but my ea used a signal based on current price, so it may continue to have signal, then no signal, then a signal in the same bar again,
how do i, to take the first signal only, and ignore all other signal of the same bar
bool isWaiting; void init(){ isWaiting = false; } int start(){ bool wasWaiting = isWaiting; isWaiting = false; // assume not. : if(OncePerBar) return; : isWaiting = !yourSignal; if(!isWaiting) return; // not yet if(!wasWaiting) return; // previously triggered. // new trigger..
WHRoeder, I am learning a thing or two about programming from your example. But I am using something very simple to work once for each new bar.
datetime CurrentTime; int start() { if (CurrentTime != Time[0]) { CurrentTime = Time[0]; ...get signal... ...do trade... } // end of if } // end of start
Does this solve the question?
//no trading after Open int openbar_intervals=1; int opentimedifference = (Time[0]-OrderOpenTime()); int opentimeintervals = (Period()*60*openbar_intervals);//1min=60 { OrderSelect(lastorder,SELECT_BY_POS,MODE_HISTORY); if(opentimedifference>=opentimeintervals) enableopen = true; else if (opentimedifference<=opentimeintervals) enableopen = false; }
previously i code like this, what's wrong with it?it just totally dont work
- You can NOT use OrderOpenTime() before a successful OrderSelect()
- No test for successful OrderSelect() What are Function return values ? How do I use them ? - MQL4 forum
- Your code only delays one bar, if there is still a open order. If the order has closed, no delay. Your question was about a continuing signal. Your code continues to open new orders on a continuing signal.
- Simply the code
Your code Simpler if(opentimedifference>=opentimeintervals) enableopen = true; else if (opentimedifference<=opentimeintervals) enableopen = false;
enableopen = opentimedifference>=opentimeintervals;
a nice simplify, which i'm weak of, i got tons of the code alike, and my ea is a bit slow, lol
anyway, so, i cant use a orderopentime, then how do i check for the time?
tell me if my logic is wrong
first a signal, if position is open then bool nomoreopenonsamebar= true
then if time0>time,then nomoreopenonsamebar=false, then i can open position again?correct?
how to time0>time??i dont know how to code this man, a little help here?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
https://www.mql5.com/en/forum/141967
}
the above link show the example of time condition is used,but my ea used a signal based on current price, so it may continue to have signal, then no signal, then a signal in the same bar again,
how do i, to take the first signal only, and ignore all other signal of the same bar