Create 3 Studies.
Ex.
Study # 1
Name:
AANonRecursive
Coding:
plot BuyLong = 1;
plot SellLong = 1;
Study # 2
Name:
AARecursive
Coding: This can be whatever study you're trying to push through with the recursive definition(s)
Paste the ATRTrailingStop study
Delete everything from def BuySignal... and down
Add the following...
plot BuyLong = close > trail;
plot SellLong = close < trail;
Study # 3
Name:
AAMoneyMaker
Coding:
plot BuyLong = 1;
plot SellLong = 1;
________________________________________________________________________________
Go to the thinkscript of a new buy order and replace the default coding with...AAMoneyMaker()."BuyLong"
Go to the AAMoneyMaker Study and replace the coding with AARecursive Study
Go back to the buyorder thinkscript. The window will do a flash. There shouldn't be a recursive error and your recursive study should be plotted on the chart. Click ok and you're ready to submit your buy order
You can pair this with a sell order using 1st trgs seq. Just replace AAMoneyMaker()."BuyLong" with AAMoneyMaker()."SellLong" in your sell order thinkscript
Go ahead and save this as a template
________________________________________________________________________________
When you try to reuse the template always check the thinkscript for errors. You MAY find that the recursive error comes back. Here is how you fix it.
Replace AAMoneyMaker Study coding with coding from AANonRecursive Study
Go to the order thinkscript and delete the thinkscript coding, AAMoneyMaker()."BuyLong" or AAMoneyMaker()."SellLong"
In that same window, go to the condition wizard tab and build out what was just deleted, AAMoneyMaker()."BuyLong" or AAMoneyMaker()."SellLong"
Recursive error should be absent and chart should be plotted (Just a straight line at "1" value)
Replace AAMoneyMaker Study coding with coding from AARecursive Study
Go back to your order thinkscript. Recursive error should be absent and chart should be plotted with AARecursive Study conditions
________________________________________________________________________________
After all that you should be back in business. Make sure to always check the order thinkscript before submitting for two reasons
- Check for recursive errors that need correction
- Bypass the 155 character thinkscript restriction
This may seem tedious but once you get it down it should take only a few mins. I use this method to setup 4 Long pair and 4 Short pair orders all within 5 mins. This method is 3 days old so there is room for improvement, i'm sure. No screenshots, sorry.
I had the same problem so I wrote a chandelier exit which gets close.
Thanks for that valuable feedback Stephen!