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

Finding Swings with Swing method - CalculateOnBarClose = false

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

    Finding Swings with Swing method - CalculateOnBarClose = false

    Hi,

    The attached code works very well for finding double tops (DT) with a swing strength of 1. http://screencast.com/t/DHec5Q27

    The problem I have with the indicator though, is, it works perfect to show DTs on past data but does not work proper with "CalculateOnBarClose = false;" Somehow Swing method returns a "number of bars ago" count of 1 bar smaller.

    Is there another workaround except to check for historical and have a second condition, which would blow up source code a lot?

    Maybe it would it be possible to change Swing method accordingly to solve this.

    Thanks

    Thomas


    Code:
                double DT_Tolerance        = Math.Max(ATR(20)[0]/4, 1.1*TickSize);
                int LB_S = 10; //Lookback
            
    //DT
                if (High[1]<=High[0] && Low[1]<=Low[0] && DrawObjects["DT"+(CurrentBar-1)] != null) {RemoveDrawObject("DT"+(CurrentBar-1));} //CandleOutlineColorSeries[1] = Color.Empty;}
                
            //one swing back
                if (((Open[0]>Close[0] && Math.Abs(High[Swing(1).SwingHighBar(1,1,LB_S)]-High[0])<=DT_Tolerance && High[Swing(1).SwingHighBar(1,1,LB_S)]>High[1] && High[1]<High[0]) ||
                     (Open[0]>Close[0] && BarBull()[1]==1 && Math.Abs(High[Swing(1).SwingHighBar(1,1,LB_S)]-MAX(High,2)[0])<=DT_Tolerance && High[Swing(1).SwingHighBar(1,1,LB_S)]>High[2] && High[2]<MAX(High,2)[0]))
                      && Swing(1).SwingHighBar(1,1,LB_S)>1 && Swing(1).SwingHighBar(1,1,LB_S)<Bars.BarsSinceSession)
                {
                    DrawText("DT"+CurrentBar, true, "DT"+Swing(1).SwingHighBar(1,1,LB_S), 0, MAX(High,2)[0]+4*TickSize, 0, Color.Red, new Font ("Arial",FontSize), StringAlignment.Center, Color.Empty, Color.Empty, 0);
                }
                else if (DrawObjects["DT"+(CurrentBar)] != null) {RemoveDrawObject("DT"+(CurrentBar));}
    Last edited by td_910; 12-20-2012, 05:58 PM.

    #2
    Thomas, running with the Swing indicator on CalculateOnBarClose = false you would unfortunately see this limitation - this is on our list to look into for our next major platform update.

    In the meantime, I would suggest to look into splitting up real-time and historical calculations needed for your study.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      could use

      MAX(High, 2)[Swing(1).SwingHighBar(1,1,LB_S)]

      to have a proper price

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cls71, Today, 04:45 AM
      0 responses
      1 view
      0 likes
      Last Post cls71
      by cls71
       
      Started by mjairg, 07-20-2023, 11:57 PM
      3 responses
      213 views
      1 like
      Last Post PaulMohn  
      Started by TheWhiteDragon, 01-21-2019, 12:44 PM
      4 responses
      544 views
      0 likes
      Last Post PaulMohn  
      Started by GLFX005, Today, 03:23 AM
      0 responses
      3 views
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by XXtrader, Yesterday, 11:30 PM
      2 responses
      12 views
      0 likes
      Last Post XXtrader  
      Working...
      X