will_lipe:
Hi there,
i am having a hard time trying to figure out why this script below is opening more than one position, as you can see, it opens a sell order when all the criteria are true, the problem is, when price hits stop(high) or take profit(lowestprice) and goes back to order price(close) it reopens the position. What can i do to change that,i need a insight, if anybody read this and reply, thank you so far.
try this
if((OrdersTotal()==0)&&(PositionsTotal()==0) && ((high>higheastprice)&&(close<open)&&(open<higheastprice)&&(signal==0)&&(signal1==0)&&(signal2==0)&&(signal3==0)&&(signal4==0)&&(signal5==0))) { trade.SellStop(0.10,close,_Symbol,high,lowestprice,ORDER_TIME_DAY,0,0); } }
if signal is valid, it will still open position.
Thanks for the reply Dua Yong Rew, it makes sense, what could i do to invalid the signal after hit the stop or take profit, do you have any idea? It cound easily have lots of losses if prices keep ranging beetween the price order and the price stop loss, could you give me a clue. Once again, thank you.
You are looking at a signal. Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
MQL4 (in Strategy Tester) - double testing of entry conditions - Strategy Tester - Expert Advisors and Automated Trading - MQL5 programming forum
Guys thanks to the replies, i just found a solution by simple changing the expiration time, now it not opening more positions after stop. If anybody having the same trouble out there i think it may solve.
int CandleTime; datetime Time[]; ArraySetAsSeries(Time,true); CopyTime(_Symbol,PERIOD_H4,0,2,Time); CandleTime = ArrayMaximum(Time,0,2); MqlRates TimeInformation[]; ArraySetAsSeries (TimeInformation, true); int data=CopyRates(Symbol(),PERIOD_H4,0,2,TimeInformation); datetime candletime = TimeInformation[CandleTime].time+300; Comment(" Expiration: ",candletime); if((OrdersTotal()==0)&&(PositionsTotal()==0) && ((high>higheastprice)&&(close<open)&&(open<higheastprice)&&(signal==0)&&(signal1==0)&&(signal2==0)&&(signal3==0)&&(signal4==0)&&(signal5==0))) { trade.SellLimit(0.10,close,_Symbol,high,lowestprice,ORDER_TIME_SPECIFIED,candletime,0); } }


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
Hi there,
i am having a hard time trying to figure out why this script below is opening more than one position, as you can see, it opens a sell order when all the criteria are true, the problem is, when price hits stop(high) or take profit(lowestprice) and goes back to order price(close) it reopens the position. What can i do to change that,i need a insight, if anybody read this and reply, thank you so far.