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 won't plot when alert is written in

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

    Indicator won't plot when alert is written in

    I have the following code, it works fairly well, sometimes it stops ploting but it displays the current value at the side of the screen which is what I want always. When I include the section of code for generating the alert it does not plot and it does not display the current value.

    protectedoverridevoid OnBarUpdate()
    {
    if (Bars.PercentComplete>0)
    {
    Plot0.Set(Volume[0] /Bars.PercentComplete);
    }

    /*
    if (Volume[0] /Bars.PercentComplete >Volume[1])
    {
    Alert("myAlert", NinjaTrader.Cbi.Priority.High, "PRV", "Alert1.wav", 30, Color.Black, Color.Yellow);
    }
    */
    }
    Last edited by maxpi; 10-24-2007, 01:19 PM.

    #2
    Is there any funny stuff in the logs?

    Comment


      #3
      I never think to go to the logs, sorry... it was trying to reference the bar before bar[0]...

      I still wonder why, when updating every tick, it stops plotting at times, I can use it when it does that but it's annoying. If I reapply the indicators it brings the plot up to date.
      Last edited by maxpi; 10-24-2007, 02:09 PM.

      Comment


        #4
        Glad it's resolved for you.

        Comment


          #5
          I think this code might solve a couple of problems that I saw in the code...

          Code:
          protected override void OnBarUpdate()
          {
            if (CurrentBar == 0) return;     // So we can access one bar back (Volume[1]).
          
            if (Bars.PercentComplete > 0)    // Has current bar started yet?
            {                                // Yes.
               Plot0.Set( Volume[0] / Bars.PercentComplete );  // Pro-rate current volume.
          
               if ( (Volume[0] / Bars.PercentComplete) > Volume[1] )
               {
                   Alert( "myAlert", NinjaTrader.Cbi.Priority.High, "PRV", 
                           "Alert1.wav", 30, Color.Black, Color.Yellow );
               }
               return;
            }
          
            //
            // Current bar has not started yet...
            //
            Plot0.Set( Volume[1] );    // Display volume for last bar instead.
          }
          ...what I noticed was a potential divide-by-zero if PercentComplete was zero, and an access violation on the first bar if the Alert code was un-commented.

          Hope this helps.

          KBJ

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AttiM, 02-14-2024, 05:20 PM
          11 responses
          184 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by fernandobr, Today, 09:11 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by timmbbo, Today, 08:59 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by KennyK, 05-29-2017, 02:02 AM
          2 responses
          1,281 views
          0 likes
          Last Post marcus2300  
          Started by itrader46, Today, 09:04 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X