How to take a strategy and put it into a study (bottom)


Category:
0
0

I like the Strat_PivotRev_SlowDRevSTRATEGY (1).ts, and would like to copy it into a study, so I can use it to trade and as a bottom indicator showing buys and sells.   There are a lot of statements in this strategy  Thinkscript, and I have not been able to pick out the correct ones to use. I could go into the condition wizard, and try to rewrite everything, but I thought it would be easier to copy the necessary statements from the strategy. Thanks for your help.

RESOLVED
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on January 21, 2017 4:31 pm
952 views
3
Private answer

Ok, so to save space we will not be posting the entire code here. We only need to work with the last four lines of code anyway. Lines of code that begin with “AddOrder”? Well those are the statements that plot the theoretical buy and sell orders. We have one pair to handle the long entries and exits. We have another pair to handle the short entries and exits.

The “AddOrder()” function takes several arguments that tell the Thinkscript compiler what to do. The first argument is the order type: “OrderType.BUY_AUTO” for example. The second argument is the condition (true/false). In this case the second argument is the defined variable named “longEntry”. Read more here:http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AddOrder.html

We can plot that condition simply:

plot signalToBuy = longEntry;

Then we can do the same for the other four AddOrder statements. Then we remove all the statements that begin with “AddOrder”, and add a line that forces the study to plot on the lower subgraph “declare lower;”.

Here is what it looks like when we’re done:

declare lower;
plot signalToBuy = longEntry;
plot signalToExitLong = longExit;
plot signalToShort = shortEntry;
plot signalToExitShort = shortExit;

And this very same modification can be used to convert this strategy to a custom scan. Just remember that a scan can only have one active plot at a time.

Hope it helps. Be sure to up-vote any answers that best solve your question!

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 21, 2017 5:54 pm
0

Thanks Mr. Hahn; you have a unique talent to be able to explain thinkscript to a thinkscript illiterate.

( at January 22, 2017 9:08 am)