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

Identifying Consolidation Through Code

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

    Identifying Consolidation Through Code

    Hello, I am currently developing a strategy that takes positions based on the SMA crossover (/ES). I have noticed through my backtesting and tweaking with some of the variables such as when the program is active, I have actual made a somewhat profitable strategy. Here is my problem, I notice when I look at the backtest on the chart, I tend to acquire most of my losers during a choppy consolidation period where the price will go under the SMA, but then in the next candle it will go above it, and orders just keep getting placed and canceled, and it just repeats this process until it has wiped out a lot of gains. I have provided pictures below of what I mean. I am using 15-minute candles with this strategy. I am very familiar with C#, but I am pretty new to the NinjaTrader software and am having trouble trying to code in certain conditions involving consolidation. I basically want my strategy to NOT take positions during a choppy consolidation period, but I have really no clue how to even start writing that out in code. I have considered using some if statements to check if the price has been within a certain x amount of points for the past y minutes, but I just can't figure out where to start with this. Any help is appreciated, thanks!

    This is my first forum post, should I add in my code?
    Attached Files

    #2
    Hello spetsnaz,

    Thanks for your post and welcome to the NinjaTrader forums!

    Slope of the moving average may provide a clue, here is a help guide link to the Slope() method: https://ninjatrader.com/support/help...-us/?slope.htm

    Checking for a break of a swing high or low when the distance between the latest Swing high to swing low is relatively small and/or has been the swing high low for quite a few bars (To clarify, duration between a swing high and low could be consolidation). Here is a link to the Help guide: https://ninjatrader.com/support/help...-us/?swing.htm

    Using multiple moving averages of different periods and then checking to the distance between them may provide evidence of consolidation. You can apply the NinjaTrader indicator "Moving Average ribbon" to quickly see if this would help.

    Perhaps other members of the community will provide further suggestions on ways to detect chop.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks, I will check it out!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by terofs, Yesterday, 04:18 PM
      1 response
      21 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by CommonWhale, Today, 09:55 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Gerik, Today, 09:40 AM
      2 responses
      7 views
      0 likes
      Last Post Gerik
      by Gerik
       
      Started by RookieTrader, Today, 09:37 AM
      2 responses
      13 views
      0 likes
      Last Post RookieTrader  
      Started by alifarahani, Today, 09:40 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X