I've written a simple thinkscript strategy that implements Larry William's smash day strategy. I've set it up to either choose the bullish or bearish setup on input. It works well on the bullish side, but the bearish side isn't doing what I [think] I've written in the code. When looking at the bearish set up it SHOULD open the trade at the smash day's low on the next day but it seems to be opening the trade at the smash day's high. What am I doing wrong? Any help is much appreciated! Here it is:
Also meant to specify that the code is written assuming daily charts only.
Code:
#LW Smash day strategy
input positionType = {default bull, bear};
input stop = yes; #Placeholder
input stoplossper = 10; #placeholder
#Bullish smash day setup
def condition1 = close < open;
def condition2 = close < low[1];
#Bearish smash day setup
def condition4 = close > open;
def condition5 = close > high[1];
def smashDay;
def openDay;
def openPrice;
def closePrice;
def openType;
def closeType;
switch (positionType) {
case bear:
smashDay = condition4 and condition5;
openDay = smashDay and low[-1] < low;
openPrice = low;
closePrice = close[-1];
openType = OrderType.SELL_TO_OPEN;
closeType = OrderType.BUY_TO_CLOSE;
default:
smashDay = condition1 and condition2;
openDay = smashDay and high[-1] > high;
openPrice = high;
closePrice = open[-1];
openType = OrderType.BUY_TO_OPEN;
closeType = OrderType.SELL_TO_CLOSE;
}
AddOrder(openType, openDay, name = "Open @ " + openPrice);
def entryprice = entryPrice();
AddOrder(closeType, !IsNaN(entryprice), price=closePrice, name = "Close @ " + closePrice + " | " + entryprice);
Also meant to specify that the code is written assuming daily charts only.
Last edited by a moderator: