Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

simple indicator is not plotting correctly

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

    simple indicator is not plotting correctly

    Hi guys,

    I coded a really simple indicator plotting Open / High / Low / Close as a line overlaying the price chart...

    • I'm working on a longterm chart SP 500 ES-Contract 1970 - 2011 showing yearly candlesticks.
    • When I try adding my indicator the data of the indicaotr (= OHLC of each bar) is shown correctly in the databox but is only drawn on the chart beginning with 1990 = 20 bars after start
    • On a monthly or daily chart the same problem occurs -> for the first 20 bars no Line is drawn but shown in databox correctly, afterwards everything alright

    As the calculation logic doesn't require any lookback-period I don't understand why it doesn't work. Thinking of a bug I already updated to Version 7.0.1000.6 but didn't help. Despereately I also tried changing values Infinite/256Barslookback and also calculate bar on close true/false. Nothing helps...

    here is the code how the values are assigned to the 4 Plots

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.SeaGreen), PlotStyle.Line, "OpenLine"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Orchid), PlotStyle.Line, "HighLine"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DodgerBlue), PlotStyle.Line, "LowLine"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Firebrick), PlotStyle.Line, "CloseLine"));
    Overlay = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.

    OpenLine.Set(Open[0]);
    HighLine.Set(High[0]);
    LowLine.Set(Low[0]);
    CloseLine.Set(Close[0]);
    }


    #2
    Koalboy, please try adding this to your Initialize() section:
    Code:
    Initialize()
    {
    BarsRequired = 1;
    }
    AustinNinjaTrader Customer Service

    Comment


      #3
      hi austin,

      that solved the problem but:

      I added the built-in RSI indicator with input parameters 3/3 and the same problem occured -> again 20 bars lag if it should be calculated on the 4th bar already (due to input parameter).

      As I don't want to change the coding logic of the built-in indicators can you tell me if this 20bars lag is intended and why?

      thx

      Comment


        #4
        koalboy, the behavior for all indicators (unless otherwise told so) is to wait for 20 bars before running calculations, to "smooth" out any possible error stemming from a lack of bars.
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by f.saeidi, Today, 10:19 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by kujista, Today, 06:23 AM
        5 responses
        15 views
        0 likes
        Last Post kujista
        by kujista
         
        Started by traderqz, Yesterday, 09:06 AM
        3 responses
        20 views
        0 likes
        Last Post NinjaTrader_ThomasC  
        Started by traderqz, Today, 12:06 AM
        3 responses
        6 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by RideMe, 04-07-2024, 04:54 PM
        5 responses
        28 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X