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

Indicator not drawing to current bar

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

    Indicator not drawing to current bar

    I have an indicator that I'm using to identify swing highs. But it doesn't draw to the last bar. I'm drawing to Time[0] which I thought would draw the line all the way to the current bar that is forming. What did I miss?



    PHP Code:
                if (Count == CurrentBar)
                {
                for (
    int x 0swingHighs.Countx++)
                    {
                        
    Draw.Line(this"swingHigh" swingHighs[x].swingHLStartTimefalse,
                            
    swingHighs[x].swingHLStartTime,
                            
    swingHighs[x].swingHLValue,
                            
    Time[0],
                            
    swingHighs[x].swingHLValue,
                            
    swingHighs[x].EQH == ?  Brushes.Green Brushes.Lime,
                            
    swingHighs[x].EQH == 1  DashStyleHelper.Dash DashStyleHelper.Solid,
                            
    swingHighs[x].EQHtrue);
                    }
    &
    #8203; 
    Click image for larger version

Name:	image.png
Views:	33
Size:	2.3 KB
ID:	1294960

    #2
    Oops. I realized I'm using OnBarClose so it wont draw until the bar closes. I don't want to change that so how do I draw the end of the line 1 bar over when using DateTime for the 2 ends of the line?

    When I'm using bar indexing, I would just make it -1.

    How do I shift the end 1 bar to the right?

    Comment


      #3
      Hello cre8able,

      Thanks for your post.

      When using Calculate.OnBarClose the OnBarUpdate() logic in your script will only process at the close of each bar. This means all calculations and actions will occur when the bar closes.

      For an indicator to calculate logic intrabar and draw objects on the currently building bar instead of the bar that closed the script should be set to Calculate.OnPriceChange or Calculate.OnEachTick.

      Calculate: https://ninjatrader.com/support/help.../calculate.htm

      Passing in a negative value for the barsAgo is not supported and would have to be used at your own discretion.

      If you want only some of your logic to occur OnBarClose and other logic to occur OnPriceChange/OnEachTick then you could use IsFirstTickOfBar in the script to separate that logic.

      Please see the reference sample below which demonstrates a technique used for those who need to separate their logic to calculate some values on each tick and others only on the close of a bar. You will set your host script to Calculate.OnEachTick and use if(IsFirstTickOfBar) and place all code that needs to calculate once every bar within that condition check. Then place all code that you want to calculate OnEachTick outside of the IsFirstTickOfBar condition check.

      SampleEnterOnceExitEveryTick -https://ninjatrader.com/support/help...either_cal.htm
      Brandon H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by geddyisodin, 04-25-2024, 05:20 AM
      8 responses
      61 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      4 responses
      3,288 views
      1 like
      Last Post jgualdronc  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      5 views
      0 likes
      Last Post Option Whisperer  
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      22 views
      0 likes
      Last Post halgo_boulder  
      Started by mishhh, 05-25-2010, 08:54 AM
      19 responses
      6,189 views
      0 likes
      Last Post rene69851  
      Working...
      X