DaveParticipant
Senior
HI, Could somebody look at the attached code and see if there is a problem with it?. Although I’ve managed a few successful ‘assisted creation back tests’, I’m totally new to writing it!. What I’m trying to do first is to place an order when price breaks either above or below the high/low of the 8.00 – 8.15(UK) m15 candle but when I run this in a backtest nothing happens?.
Thanks, Dave
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
MaxPrice = highest[1](high)
MinPrice = lowest[1](low)
IF (TIME = 081500) AND (close > MaxPrice) THEN
BUY 1 PERPOINT AT MARKET
ENDIF
IF (TIME = 081500) AND (close < MinPrice) THEN
SELL 1 PERPOINT AT MARKET
ENDIF
SET STOP PLOSS 25
SET TARGET PPROFIT 10
To make a breakout system you should first have a look on this video I made to how to build a break out box: http://www.prorealcode.com/blog/video-tutorials/create-breakout-box-2-hours/
Then add pending stop orders at found levels to be sure trades will be successfully executed at that prices instead of testing if the close of the next candlestick is above or below which is often too late because of the not inside bar look (code is only read once at Close).
Let us know how it goes and any additional questions.
DaveParticipant
Senior
Thanks Nicolas, If only I had seen the video beforehand – I could have saved myself a couple of hours of hair pulling!!. I will report back when I have tried a few ideas. Dave