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

Regression channel strategy

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

    Regression channel strategy

    Hello,

    I'm trying to build a strategy based on linear regression channel indicator. The idea is to enter short when price crosses above upper let's say 2 standard deviations line and to enter to enter long when price crosses below lower 2 standard deviations band. Unfortunately I have had no luck so far. Could somebody help me with this, please

    #2
    Hello Alex Ledenev,

    From the given details I couldn't really point a direction as I don't know what you tried or what was wrong when you tried it. If you can provide more details about what you tried and what the result was we could try to provide more help with the added context.



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

    Comment


      #3
      Hello Jessy ,
      Thank you for your reply and your willingness to help. You are 100% right, from my post it's unclear what I'm trying to do, so let me give you more details.
      The goal of the strategy is to enter long when the price crosses below lower band of the regression channel and enter short when the price crosses above the upper band. Below the width of the channel is two standard deviations both ways and I want to enter short if the price crosses above 15951

      Click image for larger version

Name:	1.jpg
Views:	321
Size:	229.0 KB
ID:	1177183

      I want to build strategy that will enter position if either band is crossed and take 4 ticks profit. Stop-15 ticks. So here how I tried to do it
      Click image for larger version

Name:	2.jpg
Views:	294
Size:	296.5 KB
ID:	1177184Click image for larger version

Name:	3.jpg
Views:	292
Size:	99.8 KB
ID:	1177185
      I tried to backtest it and even got some results, but when I turn this strategy on on the chart nothing happens. Long position won't open when the price breaks through the lower band and I don't see my mistake unfortunately. Hope this clarifies what I'm struggling with and if you need any additional information, please let me know. Thank you again for your help

      Comment


        #4
        Hello Alex Ledenev,

        A CrossAbove is considered when the previous bar value is lower, and the next bar value is at or above.

        Please note that GetCurrentBid does not have any historical values like a Price Series (I. E. Open, High, Low, Close) So it is not well used with Crossover conditions which compare the previous value of a PriceSeries/Indicator to the current value of the PriceSeries/Indicator. I would suggest using Close in your crossover condition, or to consider making larger conditions using less than/greater than.

        As another tip, it can be helpful to add debug prints so you can see the exact same values the strategy is processing in its logic, when that logic is processed. This can make it clear why some conditions are evaluating the way they are when you expect otherwise.

        Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk


        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello Alex Ledenev,

          A CrossAbove is considered when the previous bar value is lower, and the next bar value is at or above.

          Please note that GetCurrentBid does not have any historical values like a Price Series (I. E. Open, High, Low, Close) So it is not well used with Crossover conditions which compare the previous value of a PriceSeries/Indicator to the current value of the PriceSeries/Indicator. I would suggest using Close in your crossover condition, or to consider making larger conditions using less than/greater than.

          As another tip, it can be helpful to add debug prints so you can see the exact same values the strategy is processing in its logic, when that logic is processed. This can make it clear why some conditions are evaluating the way they are when you expect otherwise.

          Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk

          Hello Jim,
          Thank you very much for your reply. As you advised I changed to CrossBelow when the price hits upper band of the Regression Channel and boom, the strategy started to work, but only in case of upper band and entering short position. Now I'm struggling with opposite scenario: when the price hits lower band I want to enter into a long position and for some reason, I don't really understand why, it doesn't work. I mean, the programming logic is the same ( I only changed settings to the appropriate band and trade direction) but it just doesn't want to work. Also the color of the Buy strategy name remains yellow while the color of the working Sell strategy turned to green and strategy works like a charm. Click image for larger version

Name:	4.jpg
Views:	291
Size:	54.1 KB
ID:	1177415
          Any idea what can be wrong with my programming? Thank you very much in advance.

          Comment


            #6
            Hello Alex Ledenev,

            A Yellow strategy means you enabled it with WaitUntilFlat, and the strategy detected it would be in the middle of a position based on the processed historical data. The strategy is waiting for the position to close before the strategy can enter with an entry order. Please be sure to review the Running NinjaScript Strategies documentation below for clarity on Strategy/Account positions and how the Start Behaviors work. Strategy vs. Account Position and Syncing Account Positions are important to review to understand what a Yellow strategy means.

            Running NinjaScript Strategies - https://ninjatrader.com/support/help...strategies.htm

            It is quite likely that you do not see your buy take place because the strategy is in a position, waiting for the position to become flat before it can enter live.

            Please also confirm with prints that the strategy is reaching your order submission methods when you expect.
            JimNinjaTrader Customer Service

            Comment


              #7
              Alex Ledenev, did you ever get regression channel working?

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by lightsun47, Today, 03:51 PM
              0 responses
              4 views
              0 likes
              Last Post lightsun47  
              Started by 00nevest, Today, 02:27 PM
              1 response
              8 views
              0 likes
              Last Post 00nevest  
              Started by futtrader, 04-21-2024, 01:50 AM
              4 responses
              44 views
              0 likes
              Last Post futtrader  
              Started by Option Whisperer, Today, 09:55 AM
              1 response
              13 views
              0 likes
              Last Post bltdavid  
              Started by port119, Today, 02:43 PM
              0 responses
              9 views
              0 likes
              Last Post port119
              by port119
               
              Working...
              X