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
I think, I will confirm, that I have seen the same issue in the Strategy Tester, not sure how exactly this could happen, I'll try it again with some more error reporting added to make sure.
OK, one mystery solved . . . I didn't realise the Spread used in the Strategy Tester is taken from the History data, in particular the M1 data. The reason I have invalid stops in my Strategy Tester run is because the spread is bigger than my SL. I'll add a test for this.
Konstantin83:
2013.03.10 11:19:18 2012.01.04 15:00:00 failed buy stop 1.00 EURUSD at 1.30505 sl: 1.28375 tp: 1.30375 [Invalid stops]
I dont understand invalid stop. the sl is below the buy sl: 1.28375 <1.30505 ?
CopyHigh(_Symbol,_Period,TimeCurrent(),5,hg);
Top = NormalizeDouble(rates[ArrayMaximum(hg,0,WHOLE_ARRAY)].high,_Digits);
- misunderstood design.
Choose among the values of the maximum double and use that instead of the integer index
thank Konstantin83:
but i dont understand what you say.
top is the highest of last 5 candles and top is double and not integer index
dan5:
I dont understand invalid stop. the sl is below the buy sl: 1.28375 <1.30505 ?
Don't take "Invalid stops" too literally. It isn't just about Stop Loss, it also can be the entry price and/or the TP. When you get an error print the following information, it will help you work out what has gone wrong:
dan5:
2013.03.10 11:19:18 2012.01.04 15:00:00 failed buy stop 1.00 EURUSD at 1.30505 sl: 1.28375 tp: 1.30375 [Invalid stops]
I dont understand invalid stop. the sl is below the buy sl: 1.28375 <1.30505 ?
Did you notice that the entry 1.30505 is > the TP 1.30375 ?
thank you for your help i modifie my sl and tp it's ok now
mrequest.sl = NormalizeDouble( mrequest.price + STP*_Point,_Digits); // Stop Loss
mrequest.tp = NormalizeDouble( mrequest.price - TKP*_Point,_Digits);// Take Profit
instead of:
mrequest.sl = NormalizeDouble(latest_price.bid + STP*_Point,_Digits); // Stop Loss
mrequest.tp = NormalizeDouble(latest_price.bid - TKP*_Point,_Digits); // Take Profit
thank you for your help i modifie my sl and tp it's ok now
mrequest.sl = NormalizeDouble( mrequest.price + STP*_Point,_Digits); // Stop Loss
mrequest.tp = NormalizeDouble( mrequest.price - TKP*_Point,_Digits);// Take Profit
instead of:
mrequest.sl = NormalizeDouble(latest_price.bid + STP*_Point,_Digits); // Stop Loss
mrequest.tp = NormalizeDouble(latest_price.bid - TKP*_Point,_Digits); // Take Profit
That's good news, hope you didn't mind me subverting your thread, but I think we both got something useful out of it in the end :-)
Did you find an other solution what I propose with OnTradeTransaction to proceed with sl & tp on a Market Execution (ECN broker) case ?
The code I suggested in this post https://www.mql5.com/en/forum/11051#comment_446272 works OK as far as I can tell, I assumed it wasn't working in the Strategy Tester due to my assumption about the spread being fixed (as in MT4) being incorrect. My code now works in the Strategy Tester and in Demo for symbols with execution type of Instant or Exchange execution, my code determines the type and sends the appropriate request(s). Ideally I would like my code to automatically handle any execution type.