• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks, I will check it out!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bosajin, Today, 06:27 PM
      0 responses
      2 views
      0 likes
      Last Post bosajin
      by bosajin
       
      Started by saltminer, Today, 06:11 PM
      0 responses
      2 views
      0 likes
      Last Post saltminer  
      Started by epitoma, Today, 05:21 PM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by BatBart, Today, 01:24 PM
      1 response
      23 views
      0 likes
      Last Post NinjaTrader_Melissa  
      Started by ezrakoper, Today, 03:05 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X