DEFPARAMFlatBefore=090000// Cancel any pending orders, close any positions andprevent placement of additional orders by the trading system before 9:30:00 in the timezone of the strategy.
DEFPARAMFlatAfter=172900// Cancel any pending orders, close any positions and preventplacement of additional orders by the trading system after 16:00:00 in the time zone ofthe strategy.
ONCEPreviousStatus=0
IFBarIndex=0THEN
XClose=TotalPrice
XOpen=(Open+Close)/2
ELSE
XClose=TotalPrice
XOpen=(XOpen[1]+Xclose[1])/2
ENDIF
IFXClose>=XOpenTHEN
IFPreviousStatus<>1THEN
BUY1SHARESATMARKET
PreviousStatus=1
ENDIF
ELSE
IFPreviousStatus<>-1THEN
SELLSHORT1SHARESATMARKET
PreviousStatus=-1
ENDIF
Endif
Hello guys!
I have tried the “built in” trailing stop but it works not good in real trading.
So i heard I need something like the code above. Is it correct that the “bulit in” trailing stop doesn’t work very well?
Maybe I’m doing something wrong…
However, I made a back test with the code above with DAX and some forex in mixed time frames.
Every test failed hard..
Do some of you nice guys have a clue what is happening?
Take care!
// Martin
Well, without implementing the trailing stop function, I can see that your strategy open and sell position accordingly to heiken ashi candlesticks. If the present candlestick direction change, you take position on the opposite direction, it occurs very often and I don’t think that in this case, the trailing stop can do its job!
Okey I see, big thanks. Is there any code to force the built in trailing stop to start in the next candle and not the same one as it´s opens?
// Martin
No, because each conditions are only tested once per bar. But IMO, you should do 2 different trading strategies : one for long orders and another one for short orders, this way trade will not be closed by opposite Heiken Ashi color change and it will give more breathe for your trailing stop to operate. Just my 2 cents.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue