I was hoping for some quick help completing a simple backtest on thinkscript for a trend following plan:
this strategy will buy if price crosses above the previous day high price and also sell short if the price crosses below the previous day low price, the trade will always be closed out 15 minutes before the market closes and that is all.
this is what I have so far and I don't think its working right on the exits, and maybe the entries too haha.
def price = close;
def longentry = price crosses above high[1];
def shortentry = price crosses below low[1];
addOrder(OrderType.BUY_TO_OPEN, longentry, open[-1]);
addOrder(OrderType.SELL_TO_CLOSE, open[-1]);
addOrder(OrderType.SELL_TO_OPEN, shortentry, open[-1]);
addOrder(OrderType.BUY_TO_CLOSE, open[-1]);
please help me! would be greatly appreciated!! This seems to simple, but I am struggling to make this work.
Thanks!!!!
this strategy will buy if price crosses above the previous day high price and also sell short if the price crosses below the previous day low price, the trade will always be closed out 15 minutes before the market closes and that is all.
this is what I have so far and I don't think its working right on the exits, and maybe the entries too haha.
def price = close;
def longentry = price crosses above high[1];
def shortentry = price crosses below low[1];
addOrder(OrderType.BUY_TO_OPEN, longentry, open[-1]);
addOrder(OrderType.SELL_TO_CLOSE, open[-1]);
addOrder(OrderType.SELL_TO_OPEN, shortentry, open[-1]);
addOrder(OrderType.BUY_TO_CLOSE, open[-1]);
please help me! would be greatly appreciated!! This seems to simple, but I am struggling to make this work.
Thanks!!!!
Last edited by a moderator: