Converting TOS Prebuilt Strategies into Scans


Category:
0
0

How do I convert the prebuilt Strategies into scans for example the BollingerBandsLE, EhlersStochLE and the two Ichimoku Strategies that you shared?

input length = 20;
input num_devs_dn = 2.0;
input bollinger_price = close;
input lower_band_price = close;

def value = Average(bollinger_price, length) – num_devs_dn * stdev(bollinger_price, length);
def condition = lower_band_price crosses above value and high[-1] >= value;

addOrder(OrderType.BUY_AUTO, condition, Max(open[-1], value), tickColor = GetColor(0), arrowColor = GetColor(0));

 

input price = close;
input length = 20;
input cutoffLength = 10;
input over_bought = 0.8;
input over_sold = 0.2;
input mode = {default Predictive, Conventional};

def buy = reference EhlersStochastic(price, length, cutoffLength, over_bought, over_sold, mode).Buy;
def sell = reference EhlersStochastic(price, length, cutoffLength, over_bought, over_sold, mode).Sell;

AddOrder(OrderType.BUY_AUTO, !IsNaN(buy), tickColor = Color.UPTICK, arrowColor = Color.UPTICK, name = “EhlersStochLE”);
AddOrder(OrderType.SELL_AUTO, !IsNaN(sell), tickColor = Color.DOWNTICK, arrowColor = Color.DOWNTICK, name = “EhlersStochSE”);

Marked as spam
Posted by (Questions: 15, Answers: 23)
Asked on August 9, 2017 10:23 am
302 views
0
Private answer

Begin here: https://www.hahn-tech.com/thinkorswim-scan-to-strategy/

And don’t forget to check if they already have a built in study filter that does the job. Many of the popular studies are included in the built in study filters when creating a custom Scan.

After this, give it a shot. Then come back here with your code, working or not, and we’ll see if we can help you get it completed.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 9, 2017 12:00 pm
0
Private answer

Hi Pete. Thanks, I re-watched a couple of videos and was able to get the Bollinger Band strategy and the Ichimoku to work. However, I have not been able to get EhlersStoch. The following is what I have on it. I greatly appreciate your help!

 

Ehler_StochLE_Scan

input price = close;

input length = 20;

input cutoffLength = 10;

input over_bought = 0.8;

input over_sold = 0.2;

input mode = {default Predictive, Conventional};

 

def condition = reference EhlersStochastic(price, length, cutoffLength, over_bought, over_sold, mode).Buy;

#def sell = reference EhlersStochastic(price, length, cutoffLength, over_bought, over_sold, mode).Sell;

 

plot scan = condition;

#AddOrder(OrderType.BUY_AUTO, !IsNaN(buy), tickColor = Color.UPTICK, arrowColor = Color.UPTICK, name = “EhlersStochLE”);

#AddOrder(OrderType.SELL_AUTO, !IsNaN(sell), tickColor = Color.DOWNTICK, arrowColor = Color.DOWNTICK, name = “EhlersStochSE”);

Marked as spam
Posted by (Questions: 15, Answers: 23)
Answered on August 10, 2017 12:05 pm
0

I see two problems here. One is the Ehlers studies require a tremendous amount of historical data before the values can be used. In most cases, this exceeds the amount of historical data available to the scan engine. (two years at the daily time frame).
The second issue I see is that you are referencing the Buy plot from the EhlersStochastic. The Buy plot is not a true/false condition and therefore cannot be used directly as a scan criteria. If you look at the source code for that study you will find the Buy plot is set to one of two values. One value is 0.5 and the other value is Doulbe.NaN.
So you might be able to get this working if you modify your plot scan statement to:
plot scan = !IsNaN(condition);
This checks if condition is something other than Double.NaN.

( at August 10, 2017 3:42 pm)
0

Thanks Pete!

( at August 11, 2017 4:28 am)