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 andrewtrades, Today, 04:57 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      3 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      6 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X