Chicago IL/US
Posts: 1 since Jun 2016
Thanks Given: 0
Thanks Received: 0
|
Hi all,
After opening a long position I want to only close my position after 2 consecutive down days. The issue I am having is I am using the close price, which is fine, but I want to start assessing my condition from the day I open my position not any previous days because if I buy after it being down 2 days in a row it will close my position the day I open it. I want it to be open for a minimum of 2 days.
I am wondering if I can get the date on which the buy occurs or start the condition 2 days after the buy. I have posted the code below. Thanks in advanced, I really appreciate and help even if you can point me in the right direction.
#if the close price is less than the previous day(indicating down) and the previous day is less than the day before that(indicating down) sell to close my position.
def triggerSell = if((close[0]<close[1]) and (close[1] < close[2]),1,0);
AddOrder(OrderType.SELL_TO_CLOSE, triggerSell, open[-1],10000/open, Color.ORANGE, Color.ORANGE, "Sell @ " + open[-1]);
|