- Coding help
- Ask!
- Please i need help with my EA !!!! it keeps opening trades whenever sl has been hit even if the conditions to trade are not meet
-
You are looking at a signal. Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 (2017) -
Don't double post! You already had this thread open.
General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)
-
You are looking at a signal. Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 (2017) -
Don't double post! You already had this thread open.
General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)
Thanks!
I find it difficult like this. Is there any way to count the candles from a last crossover of two MA for example, until present candle?
if you post the signal part of your code (or an example of it) we can show you how to make it correct and its easy its not complicated
when you say "signal", you mean the opening conditions?
Like this ?
// Open buy order if( Count.Buy()<1&&tsi>sig && ma<close&& gBuyTicket ==0 && close1<close && (ind_buffer0>ind_buffer2 || ind_buffer1>ind_buffer2 ))
I manage to avoid opening another trade, by inserting another condition for buy/sell signals. Like if the current price is too far ( ATR*1.5) from the base line, do not open trade.
It is a little better, profit wise, but still NOT satisfied with the outcome.
I would still like to try the version to count the candles, if anyone can point me to a direction how to achieve this. ( don't want the code, but an idea, where to start)
Like Ex : if ma5 == ma35 ... extract time when that event happened.
and then substract it from current time, and the result divide by _Period. This should give the number of bars since the event?
I manage to avoid opening another trade, by inserting another condition for buy/sell signals. Like if the current price is too far ( ATR*1.5) from the base line, do not open trade.
It is a little better, profit wise, but still NOT satisfied with the outcome.
I would still like to try the version to count the candles, if anyone can point me to a direction how to achieve this. ( don't want the code, but an idea, where to start)
Like Ex : if ma5 == ma35 ... extract time when that event happened.
and then substract it from current time, and the result divide by _Period. This should give the number of bars since the event?
How to extract event time ??
If you have event time and want to find how many bars passed since use iBarShift and it will give you the exact candles number
But I dont have event time. That is my question. How to catch event time.
Cause I need to somehow to catch the time of the two lines crossing, and then count from that time.
"line1==line2 .. remember what time is it know " -- how do I put that into code? .... :)
tried something..but it not will do anything...
datetime present; datetime time; double bars; if (sig==tsi) { time=iTime(_Symbol,0,1); } present=TimeCurrent(); bars= (double)((time-present)/_Period);Actually I dont the answer to that. I would like you to point me to where should I read so I can answer to that myself.
-
if (sig==tsi)
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum #2 (2013) -
bars= (double)((time-present)/_Period);
This assumes every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (20 June 2006)
No candle if open = close ? - MQL4 programming forum
-
Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 programming forum #2 (2013) - This assumes every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (20 June 2006)
No candle if open = close ? - MQL4 programming forum
Ok..thanks...and 3)..... I was waiting for 3) ..where point me somewhere..:)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use