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

Look Back Period Since Position Exit

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

    Look Back Period Since Position Exit

    Hi guys,
    I'm working on a strategy involving the keltner channel indicator. The strategy consists of taking longs when price touches the lower band and vice versa with the top. I managed to get the action of taking longs and shorts to work. Problem is the strategy consists of price crossing above/below the midline of the keltner channel in order to provide the next signal to enter. Currently with the action I set up, the strategy enters a trade then either hits the profit target or gets stopped out and then enters again when price touches the lower or upper bands. I'm trying to create a condition where price has to cross above/below the midline in order to trigger the next entry signal. I've played around with the "Look back period" but this isn't accurate since price can linger in between the midline and lower/upper bands without touching both. Ideally I need to create a condition that says "since last position exit(profit or stop) price needs to cross above/below midline in order to trigger the next long or short." Thank you.

    #2
    Hello traderdanny,

    Welcome to the NinjaTrader forums.

    I'm focusing on specific sentence that I think is your inquiry "I'm trying to create a condition where price has to cross above/below the midline in order to trigger the next entry signal."

    It sounds like you already have Price > Close selected on the left, CrossAbove as the operator in the center, and Indicator > Keltner channel with the Plot set to Midline on the right for the first condition and Strategy > Position on the left, equals in the center, and Strategy > Market Position set to Long on the right.

    Are finding that this conditions is not evaluating as true when expected?

    Use prints to understand why.
    Below is a link to a forum post that demonstrates using prints to understand behavior. Please watch the video 'Debugging using prints with the Strategy Builder'.


    I am happy to assist with analyzing the output from prints.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your response Chelsea. The action is currently working based on the condition but the condition isn’t exactly where I need it to be. I need the strategy to register that after I exit a market position(profit or stop) I don’t want the strategy to take another long until price crosses the midline of the Keltner channel. Currently if I get stopped out the strategy just re enters right away since it’s under the lower channel. Or if I take profit and price doesn’t cross above the midline but returns to the bottom band it also enters a trade again.

      Comment


        #4
        Hello traderdanny,

        You could require the position to be flat and the close crosses above the midline.

        A condition with cross above / below would be comparing the previous bars values for two series with the current bars values for two series. This would not be the same as choosing Less than as the operator in the center.

        Are you wanting to wait an additional bar?

        Is the script running with Calculate set to OnBarClose?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,
          I'm not sure what you mean by two series. Currently my action keeps entering a long position when price touches the lower band of the keltner channel which is what I want it to do. However, I need to cross above the midline of the keltner channel once the position is closed in order to re enter the next trade.

          I do have an IF condition of CrossAbove(Close, keltnerema(Close, 9, 140). Midline, 100). This however forces me to use a look back period of 100 in order for the action to work. My strategy can't work on a set number for the look back period.

          I need a condition stating IF price(close) crosses above keltnerema midline SINCE the last market position whether it was a stop or profit then the action of taking a long on the bottom keltner channel should be completed. Heres my action code if it helps you out. EnterLongLimit(1, (keltnerema(9, 140).Lower[0] + (2 * TickSize)), @''"");

          What exactly would this type of coding look like?

          Thanks for your help.

          Comment


            #6
            Hello traderdanny,

            Two series just means two inputs like two indicators or two price series.

            When you say that you need to use 100 for the lookback, are you getting an error or just seeing that the condition is not true when using other values?

            For a condition with the lookback since the alast entry you could use BarsSinceEntryExecution



            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by sidlercom80, 10-28-2023, 08:49 AM
            168 responses
            2,262 views
            0 likes
            Last Post sidlercom80  
            Started by Barry Milan, Yesterday, 10:35 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by WeyldFalcon, 12-10-2020, 06:48 PM
            14 responses
            1,429 views
            0 likes
            Last Post Handclap0241  
            Started by DJ888, 04-16-2024, 06:09 PM
            2 responses
            9 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            41 views
            0 likes
            Last Post jeronymite  
            Working...
            X