| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| CandleStickTrailingStop Weirdness https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3127 |
Page 1 of 1 |
| Author: | Radar [ Thu Sep 05, 2013 6:24 pm ] |
| Post subject: | CandleStickTrailingStop Weirdness |
Hey Gang, I'm trying to get a candlestick trailing stoploss working, but have come across a very strange situation... The trailing stop works fine for Buys, but for Sells, I have to insert either an alert, or Sleep(1);... Here's the code, (adapted from Steve's shell)... Code: Select all Your help will be greatly appreciated. Have fun! Radar =8^) |
|
| Author: | MrLong [ Thu Sep 05, 2013 6:43 pm ] |
| Post subject: | Re: CandleStickTrailingStop Weirdness |
Try removing line 14, that the only difference. if (NewStop > OrderOpenPrice() ) continue; <<== No reason why the stop wouldn't be higher then OrderOpenPrice() if (OrderType() == OP_SELL) { if ((BreakEven) && (sl > OrderOpenPrice())) continue; if (iHigh(NULL, CstTimeFrame, CstTrailCandles) < OrderOpenPrice()) if ((!BreakEven) && (sl > OrderOpenPrice())) sl = OrderOpenPrice(); if (iHigh(NULL, CstTimeFrame, CstTrailCandles) < sl) if (iHigh(NULL, CstTimeFrame, CstTrailCandles) > (Ask + ((MarketInfo(Symbol(), MODE_STOPLEVEL)/factor)/10))) Alert("If I remove this alert, candlesticktrailingstop only works for Buys"); // Why? Why?? WHY??? { NewStop = NormalizeDouble(iHigh(NULL, CstTimeFrame, CstTrailCandles), Digits); //Check that the new stop is < the old. Exit the function if not. if (NewStop > OrderStopLoss() || CloseEnough(NewStop, OrderStopLoss()) ) continue; if (NewStop > OrderOpenPrice() ) continue; modify = true; }//if (iHigh(NULL, CstTimeFrame, CstTrailCandles) < sl) }//if (OrderType() == OP_SELL) |
|
| Author: | Lifesys [ Fri Sep 06, 2013 4:56 am ] |
| Post subject: | Re: CandleStickTrailingStop Weirdness |
Hi Radar Another point is that OrderStopLoss() is not an integer so Code: Select all Code: Select all Paul |
|
| Author: | Radar [ Fri Sep 06, 2013 10:26 am ] |
| Post subject: | Re: CandleStickTrailingStop Weirdness |
Sorted, thanks MrLong: I tried commenting that line out, but got the same result. You pointed out an error in my thinking... Why was I trying to ensure that sl was at open before moving stops, when I already have BreakEven to do that? Too many late nights, I guess. Paul: That hit the spot, thanks It's the weekend, so a looong sleep is in order Have fun, gentlemen Radar =8^) |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|