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 jaybedreamin, Today, 05:56 PM
        0 responses
        3 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        9 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Working...
        X