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

MTF indicator don't plot correct online, but plot good on history

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

    MTF indicator don't plot correct online, but plot good on history

    Hello.

    I made simplest Multu-timeframe indicator. It must plot indicator from another timeframe.

    It works on history, but on line it works not correct.

    This is screenshot and text of indicator.
    Please tell me: is this NT7 bug, or I did something wrong?


    protected override void Initialize()
    {
    Add(new Plot( new Pen( Color.Blue, 1), PlotStyle.Line, "MA"));
    Add(new Plot( new Pen( Color.Blue, 2), PlotStyle.Line, "Sma"));

    Add(new Line(Color.FromKnownColor(KnownColor.Blue), 0, "LevelUp"));
    Add(new Line(Color.FromKnownColor(KnownColor.Blue), 0, "LevelDn"));
    //Add(new Line(Color.FromKnownColor(KnownColor.Blue), 0, "ZeroLine"));

    Add(BarsPeriod.Id, Tf);

    CalculateOnBarClose = false;
    Overlay = false;
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1 ) { d = iMyOsc(Level, PeriodMA, PeriodPrice, Type).MA[0]; return; }

    Lines[0].Value = Level;
    Lines[1].Value = -Level;

    MA.Set(d);
    Sma.Set(SMA(Values[0], 5)[0]);

    if (Values[0][0] >= Level) BackColor = Color.LightGreen;
    if (Values[0][0] <= -Level) BackColor = Color.Pink;
    }
    Attached Files
    Last edited by fx.practic; 08-19-2010, 01:35 AM. Reason: MTF, mulyu, timeframe, multuply, indicator, plot, history, on-line
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    fx.practic, has the called indiator iMyOsc any hard coded CalculateOnBarClose reference in it's Initialize()?

    If yes, please remove it completely and only set this property from the calling indicator / strategy.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      iMyOsc:

      protected override void Initialize()
      {
      Add(new Plot(new Pen (Color.FromKnownColor(KnownColor.Transparent), 2), PlotStyle.Line, "Inc"));
      Add(new Plot(new Pen (Color.FromKnownColor(KnownColor.RoyalBlue), 2), PlotStyle.Line, "MA"));
      Add(new Plot(new Pen (Color.FromKnownColor(KnownColor.Transparent), 1), PlotStyle.Dot, "Signal"));

      Add(new Line(new Pen(Color.DarkBlue, 2), Level, "UpLine"));
      Add(new Line(new Pen(Color.DarkBlue, 2), -Level, "DnLine"));
      Add(new Line(new Pen(Color.DarkBlue, 1), 0, "ZeroLine"));
      Overlay = false;
      CalculateOnBarClose = false;
      }


      protected override void OnBarUpdate()
      {
      // ---------------- Initializing --------------------------------------------------
      //
      Lines[0].Value = Level;
      Lines[1].Value = -Level;
      if ( Bars.CurrentBar < (1+PeriodMA) || Bars.CurrentBar < (1+PeriodPrice)) return;
      // ---------------------------------------------------------------------------------

      // --------------- Indicator's lines counting --------
      //
      Inc.Set((Close[0] - Close[PeriodPrice])/TickSize);
      MA.Set(MAs(Values[0], PeriodMA, true, Type)[0]);
      // -------------------------------------------------

      // ------------------------------------------ Signals counting ------------------------------------------------
      //
      Signal.Set( 0 );
      if ( Values[1][1] >= Level && Values[1][2] <= Values[1][1] && Values[1][1] > Values[1][0] ) Signal.Set( -2 );
      if ( Values[1][1] <= -Level && Values[1][2] >= Values[1][1] && Values[1][1] < Values[1][0] ) Signal.Set( 2 );
      // ------------------------------------------------------------------------------------------------------------
      }
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment


        #4
        Thanks - please remove the CalculateOnBarClose completely from it's Initialize() method, recompile your scrips and then reapply a new instance of your MTF indicator to check.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Prirmary indicatror was without this string. I add string "CalculateOnBarClose = false;" when tried solve the problem.

          So, without this string indicator work in same way.
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment


            #6
            fx.practic, can you please export the full code you use now and then contact me at support at ninjatrader dot com with it so I can take a look?

            Thanks
            BertrandNinjaTrader Customer Service

            Comment


              #7
              &quot;CalculateOnBarClose = false;&quot; removed

              Just for case, tried without "CalculateOnBarClose = false;"
              Attached Files
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment


                #8
                Thanks, do you see any errors in the log tab as you apply your indicator?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  I sent iMyOsc.cs and iMyOsc2ndTf.sc at [email protected] for Bertrand.
                  fx.practic
                  NinjaTrader Ecosystem Vendor - fx.practic

                  Comment


                    #10
                    There no mistakes at log

                    I don't see arrors at log.
                    Attached Files
                    fx.practic
                    NinjaTrader Ecosystem Vendor - fx.practic

                    Comment


                      #11
                      Thanks, just received your code sample, will look into matters.
                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by andrewtrades, Today, 04:57 PM
                      1 response
                      8 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by chbruno, Today, 04:10 PM
                      0 responses
                      6 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
                      7 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