Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where is the problem

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

    Where is the problem

    You will find hereunder the core of an indicator which plots correctly as long as I don't use oscib[0] (oscil[0]/SMA(test,252)[0] is OK) but does not plot anything with the complete code. Does anyone can tell me what is wrong and how to solve this problem?

    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Oscillateur"));
    CalculateOnBarClose =
    false;
    Overlay =
    false;
    PriceTypeSupported =
    true;
    test=
    new DataSeries(this);
    oscil=
    new DataSeries(this);
    oscib=
    new DataSeries(this);
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {

    test.Set(
    100*Math.Abs((SMA(fast)[0]-SMA(slow)[0]))/Close[0]);
    oscil.Set(
    100*(SMA(fast)[0]-SMA(slow)[0])/Close[0]);
    oscib.Set(
    100*(SMA(fast)[1]-SMA(slow)[1])/Close[1]);
    Value.Set((oscil[
    0]-oscib[0])/SMA(test,252)[0]);

    }

    #2
    You're try to access a dataseries object that is not present at the start of the chart, see this tip here -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks a lot for this fast answer

      Code is now running correctly

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rtwave, 04-12-2024, 09:30 AM
      2 responses
      20 views
      0 likes
      Last Post rtwave
      by rtwave
       
      Started by tsantospinto, 04-12-2024, 07:04 PM
      5 responses
      68 views
      0 likes
      Last Post tsantospinto  
      Started by cre8able, Today, 03:20 PM
      0 responses
      7 views
      0 likes
      Last Post cre8able  
      Started by Fran888, 02-16-2024, 10:48 AM
      3 responses
      49 views
      0 likes
      Last Post Sam2515
      by Sam2515
       
      Started by martin70, 03-24-2023, 04:58 AM
      15 responses
      115 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X