Peachtree City, Georgia, USA
Posts: 1 since Jul 2014
Thanks Given: 0
Thanks Received: 0
|
I am new to think script. I am trying to script a strategy. I have been able to script the purchase conditions but there is something wrong with my sell condition which I have not been able to figure out. In words, I want to sell when the PercentR has crossed below 80 and when there is a close that is lower than the low of the day on which the PercentR crossed below 80, I want to sell on the next day open.
My script is as follows:
def test=reference PercentR(30,20,80);
def retestlo=if test crosses below 80 then low else retestlo;
AddOrder(OrderType.SELL_TO_CLOSE, retestlo>close, open[-1]);
Once the PercentR has crossed below 80, the low of that day stays in effect until the next time that the PercentR crosses below 80 (which can only happen if it has crossed above 80 in between).
Thanks for your help.
|