Announcement

Collapse
No announcement yet.

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.

    Comment


      #3
      Thanks, I will check it out!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      54 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      72 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X