♥ 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; def value = Average(bollinger_price, length) – num_devs_dn * stdev(bollinger_price, length); addOrder(OrderType.BUY_AUTO, condition, Max(open[-1], value), tickColor = GetColor(0), arrowColor = GetColor(0));
input price = close; def buy = reference EhlersStochastic(price, length, cutoffLength, over_bought, over_sold, mode).Buy; AddOrder(OrderType.BUY_AUTO, !IsNaN(buy), tickColor = Color.UPTICK, arrowColor = Color.UPTICK, name = “EhlersStochLE”);
Marked as spam
|
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
|
|
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
|
Please log in to post questions.
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.
Thanks Pete!