TOS Strategy Guide question


Category:
0
0

Hi….Love the tutorials. I have a question regarding the TOS Strategy Guide video. (or more precisely the code). How can one make this code for a bear strategy?I’ve tried just reversing all the highs and lows, but I don’t know if that would make for a plausible strategy. Thanks much…..

def pivotLow = low > low[1] and low[1] < low[2] and low[2] < low[3];
def pivotHigh = high < high[1] and high[1] > high[2];
plot pivotLowReversal = ( pivotLow and close > high[1] ) or (
pivotLow[1] and close > high[2] and low > low[2] and high[1] <
high[2] );
plot exitLong = SlowD < SlowD[1] and SlowD[1] < SlowD[2] and highest(pivotLowReversal[0],2) == 0;
def entry;
def exit;
switch (direction) {
case "Long":
entry = pivotLowReversal;
exit = exitLong;
case "Short":
entry = no;
exit = no;
};

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on May 6, 2018 10:12 pm
137 views
0

You are missing some lines of code here. There is a switch/case statement at the end, referencing a missing input named: “direction”. Did you copy and paste the entire code or just a portion of it?

( at May 7, 2018 7:48 am)
0
Here is the code I am currently using in a study. declare lower; def pivotLow = low > low[1] and low[1] < low[2] and low[2] < low[3]; def pivotHigh = high high[2]; plot pivotLowReversal = ( pivotLow and close > high[1] ) or ( pivotLow[1] and close > high[2] and low > low[2] and high[1] < high[2] ); I am currently using this with a 50 SMA scan and a Schaff Trending Cycle. It works well as a bullish scan. I can figure out the 50 SMA and Schaff for a bearish scan, but I\'m having issues changing the pivot scan to a bearish scan. Ideally, I would like to have this as a strategy, but that is currently over my head. Thanks for your help.
( at May 7, 2018 6:34 pm)
0
Private answer

Ok so after a bit more details we have a solution.

First thing, the code provided in the original question was missing some lines. Looks like the author of the post got the code from our video: Thinkorswim Strategy Guide

Second thing, the code provided in the response to my request for additional information contained an error: def pivotHigh = high high[2];

I will correct that in my solution, posted here:

declare lower;
def pivotHigh = high < high[1] and high[1] > high[2];
def pivotHighReversal = ( pivotHigh and close < low[1] ) or ( pivotHigh[2] and close < low[2] and high < high[2] and low[1] > low[2] );

I copied the last two lines from the original code provided with the video. The original code was designed with a user input to switch between long and short signals. There really was no need to rip this code apart to separate the signals.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 7, 2018 7:47 pm