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

indicator plotting only close instead of my custom value

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

    indicator plotting only close instead of my custom value

    i am trying this in market analyser and why does this code keep plotting the close price instead of my custom 1 if condition matches.
    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.

    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(
    new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    CalculateOnBarClose =
    false;
    Overlay =
    false;
    PriceTypeSupported =
    false;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    if(FirstTickOfBar || (VolumeMA==null)){
    VolumeMA=triggerRatio* EMA(Volume,
    15)[1];
    }



    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    if(Volume[0]>= VolumeMA){

    Plot0.Set(
    1);
    }

    }

    #2
    Please run it on a chart and try to debug it to see where the values are set. If you are on CalculateOnBarClose = false you need to set the value of the bar on every single tick if you want it to persist.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      you can see how i added my indicator to the chart

      it shows that it took parameter of 2.
      the chart looks excatly like how my indicator should work
      the indicator shows orange line when the criteria matched.
      The market analyser is showing the price plotted for the same indicator and same parameters. my indicator does not plot the price at all.

      i dont know where the market analyser is getting it from.
      protected override void OnBarUpdate()
      {
      if (CurrentBar<20)
      return;


      if(FirstTickOfBar || (VolumeMA==null)){
      VolumeMA=triggerRatio* EMA(Volume,15)[1];
      }



      // Use this method for calculating your indicator values. Assign a value to each
      // plot below by replacing 'Close[0]' with your own formula.
      if(Volume[0]>= VolumeMA){

      Plot0.Set(1);
      }
      }

      Comment


        #4
        I suggest you add some Print() lines into your indicator then and run it from the MA while examining the Output Window.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          pl explain something to me. why does the market analyser show something that is not shown in the chart window for the same indicator.
          i have only 1 plot statement in my code which is
          Plot0.Set(1);

          Comment


            #6
            Please Print() values to see what your indicator is doing. I cannot explain anything until we get some debugging going.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              protectedoverridevoid Initialize()
              {
              Add(
              new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
              CalculateOnBarClose =
              false;
              Overlay =
              false;
              PriceTypeSupported =
              false;
              }

              protectedoverridevoid OnBarUpdate()
              {
              if (CurrentBar<20)
              return;


              if(FirstTickOfBar || (VolumeMA==null)){
              VolumeMA=triggerRatio* EMA(Volume,
              15)[1];
              }

              if(Volume[0]>= VolumeMA){

              Plot0.Set(
              1);
              Print(
              "inside Plot" + Plot0[0]);
              }
              Print(
              "Outside Plot" + Plot0[0]);
              }

              IT seems to be assigning the price somewhere. but i dont see my code doing it.
              the PRint statemetn is printing the price even though i am not assigning it anywhere.

              Comment


                #8
                When you don't set the plot, it automatically takes the price. Please follow the suggestion in post #2.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  1. why is there a differece in behaviour between a market analyser and the chart. the chart did not show any values at all for the bars i did not set the value.
                  2. what value can you set when there is none to set?
                  if(Volume[0]>= VolumeMA){

                  Plot0.Set(
                  1
                  );
                  }

                  else
                  {
                  // what value do i set
                  Plot0.Set(?);
                  }

                  Comment


                    #10
                    1. For sure there is a difference. Especially in regards to how many bars lookback there is. If you want to know what is going on with your indicator you need to follow the values on every single step. See when it takes the 1. See when it does not take it.

                    2. You need to decide what you want that value to be. Whether that is set what it is from your previous set, or a new value.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      i dont want any values to. would it take a null or something like that.

                      Comment


                        #12
                        That is not the issue here. You need to set it on EVERY single tick if you want your setting to persist.

                        Tick #1 of bar = you set plot to 1
                        Tick #2 of bar = you fail to set the plot value therefore the plot is now taking on values of the close price
                        Tick #3 and so on = will continue to take the close price because you are not setting the plot to 1.

                        Therefore MA = you see close price.

                        If you want to set a null value please read this article for the .Reset section. http://www.ninjatrader-support.com/H...taSeriesObject
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          ok. i understand that there is dummy close value set for each bar. does the reset set the value of the bar back to the dummy value or does it provide zero value for the bar.
                          i tried
                          Plot0.Reset(0);

                          and it put the close value back to the bar in market analyser. how do i get a novalue for the bar?

                          Comment


                            #14
                            It will hold a dummy value. I suggest you just set the plot to 0.
                            Josh P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Shansen, 08-30-2019, 10:18 PM
                            24 responses
                            942 views
                            0 likes
                            Last Post spwizard  
                            Started by Max238, Today, 01:28 AM
                            0 responses
                            9 views
                            0 likes
                            Last Post Max238
                            by Max238
                             
                            Started by rocketman7, Today, 01:00 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post rocketman7  
                            Started by wzgy0920, 04-20-2024, 06:09 PM
                            2 responses
                            28 views
                            0 likes
                            Last Post wzgy0920  
                            Started by wzgy0920, 02-22-2024, 01:11 AM
                            5 responses
                            33 views
                            0 likes
                            Last Post wzgy0920  
                            Working...
                            X