NexusFi: Find Your Edge


Home Menu

 





ThinkScript Help - Sell after 2 consecutive down days after buy


Discussion in ThinkOrSwim

Updated
    1. trending_up 2,671 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

ThinkScript Help - Sell after 2 consecutive down days after buy

  #1 (permalink)
sdean87
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]);

Reply With Quote




Last Updated on June 5, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts