Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Custom trade stop based off of the close of a previous candle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom trade stop based off of the close of a previous candle

    Hello,

    My apologies if this topic has already been addressed.

    I am currently working on a strategy where I am entering at the close of the candle which crosses the 2 StDev BollingerBand (either at the upper or lower) and then exiting once the price closes across the center line of the BollingerBand. This part is working perfectly for me. What I am struggling with is my intended stop. I am wanting to have the the strategy exit if the price returns and closes past the close of the bar which signaled me to enter... if that makes any sense. So, lets say the upper BollingerBand is at 100, the price closes at 100.2, it then returns to 99.8, the center line is at 99.5 so it doesn't exit, and then the price goes up again and closes at 101. I would want my strategy to exit at this point and then wait to try to enter again once the price crosses below the BollingerBand center line.

    Is there anyone who could help me with this? I recognize I would need to probably start a counter once the price entered so that I could tell the strategy how far to look back but other than that I am stuck.

    Any help would be appreciated.


    #2
    Hello Kensonprib,

    Thank you for your post.

    So, basically you want to exit if, while in the position, the price crosses back over the Bollinger upper or lower band (whichever the original order was triggered by), if it didn't hit the center line and get exited?

    You could set a condition that checks whether the position is long or short and then also checks for the price crossing above the upper or below the lower band depending on the position's direction, and exits if it does, that'd be the simplest way. You don't really need a counter, all you really need to know is that the price crossed back over again while you're in the position.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Kate, thanks for the response. To answer your question, I don't want it to exit again when it crosses the bollingerband but rather exit when the high closes higher than the closing price which triggered the entry... the reason I state it like that is because by the time the price returns to my entrance point it could be multiple candles away from the entrance and at that point the bollingerband spread could be much greater. Do you see my dilemma? I need to be able to create a new variable when I enter the trade which notes the price. Then if the stock closes beyond that price before closing past the bollingerband's center line it will exit.

      Comment


        #4
        Hello Kensonprib,

        Thank you for your reply.

        You could certainly create a double variable called EntryPrice that you reset to 0 when flat. Then, when the order is triggered, save the Close price of the bar to your variable. At that point then all you'd have to do is check that the current close price is greater/less (depending on direction of the entry) and if so, exit the position and reset your EntryPrice variable.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,404 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        95 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        7 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        159 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X