Larry Williams Smash Day strategy for Thinkorswim

excal666

New member
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:

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:
Solution
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:

#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...
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:

#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, openPrice, name = "Open @ " + openPrice);

def entryprice = entryPrice();
AddOrder(closeType, !IsNaN(entryprice), price=closePrice, name = "Close @ " + closePrice + " | " + entryprice);

[/ICODE]

Also meant to specify that the code is written assuming daily charts only.

i added this to your code,

Code:
addchartbubble(1,low,
entryprice
, (if !IsNaN(entryprice) then color.yellow else color.gray), no);

trades only last for 1 bar , ( a valid entryprice for one 1 bar)
because,
you are using this to close a trade
!IsNaN(entryprice)

if no trade, then it is na
when a trade opens, there is a valid entryprice
then on the next bar the price is not an error , and triggers a close

def entryprice = entryPrice();
AddOrder(closeType, !IsNaN(entryprice), price=closePrice, name = "Close @ " + closePrice + " | " + entryprice);


you need to come up with new rules to trigger a close
 
Solution
i added this to your code,

Code:
addchartbubble(1,low,
entryprice
, (if !IsNaN(entryprice) then color.yellow else color.gray), no);

trades only last for 1 bar , ( a valid entryprice for one 1 bar)
because,
you are using this to close a trade
!IsNaN(entryprice)

if no trade, then it is na
when a trade opens, there is a valid entryprice
then on the next bar the price is not an error , and triggers a close

def entryprice = entryPrice();
AddOrder(closeType, !IsNaN(entryprice), price=closePrice, name = "Close @ " + closePrice + " | " + entryprice);


you need to come up with new rules to trigger a close
Thanks for the assist! I made a few modifications to make it more general. I originally just wanted to see the results after holding the position (long or short) until the next day, but added some to specify the number of days (or bars) to stay in the trade. This makes the close order correctly trigger on the bull side, but still when taking a bearish position, the entry/open price is at the high of the smash(bear) day, not the low as I intended. Any obvious hints as to why?? Just looking at the very first opening bear position, it's not doing it correctly. Here's the modified code:

Code:
input positionType = {default bull, bear};
input openFilter = no;
input ndays = 2;
input stop = yes;  #Placeholder
input stoplossper = 10;  #placeholder

def ema5 = MovingAverage( AverageType.EXPONENTIAL, close, 5 );
def ema13 = MovingAverage( AverageType.EXPONENTIAL, close, 13 );

#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;
   openType = OrderType.SELL_TO_OPEN;
   closeType = OrderType.BUY_TO_CLOSE;
default:
   smashDay = if openFilter then condition1 and condition2 and ema5 >= ema13 else condition1 and condition2;
   openDay = smashDay and high[-1] > high;
   openPrice = high;
   closePrice = open;
   openType = OrderType.BUY_TO_OPEN;
   closeType = OrderType.SELL_TO_CLOSE;
}

AddOrder(openType, openDay, name = "Open @ " + openPrice);

def offset = ndays - 2;
def entry = if(isNaN(EntryPrice()), entry[1], EntryPrice());
def x = barNumber();
def xB = if(entry != entry[1], x, xB[1]);

AddOrder(closeType, x crosses above xB+offset, price=closePrice, name = "Close @ " + closePrice + " | " + entry);
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
201 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top