Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawText crashes script...

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

    DrawText crashes script...

    This works:

    Code:
     
    protected override void OnBarUpdate()
    {
    double Pressure;
    int BidPressure=GetCurrentBidVolume();
    int AskPressure=GetCurrentAskVolume();
    if (BidPressure>AskPressure)
    {
    Pressure=BidPressure/AskPressure;
    DrawArrowUp("Pressure",0,Close[0]+(Pressure/100),Color.Red);
    }
    else
    {
    Pressure=-AskPressure/BidPressure;
    DrawArrowDown("Pressure",0,Close[0]+(Pressure/100),Color.Green);
    }
    }
    This doesn't:

    Code:
     
     
    protected override void OnBarUpdate()
    {
    double Pressure;
    int BidPressure=GetCurrentBidVolume();
    int AskPressure=GetCurrentAskVolume();
    if (BidPressure>AskPressure)
    {
    Pressure=BidPressure/AskPressure;
    DrawArrowUp("Pressure",0,Close[0]+(Pressure/100),Color.Red);
    }
    else
    {
    Pressure=-AskPressure/BidPressure;
    DrawArrowDown("Pressure",0,Close[0]+(Pressure/100),Color.Green);
    }
    DrawText("PressureText",Pressure.ToString(),0,Close[0],Color.Black);
    }
    ?

    #2
    Hello Dhunnewell,

    That code is compiling and drawing text for me. What issue are you having with DrawText? Please check the log tab and report if there are any error messages.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Yup, got the following:
      3/3/2010 4:05:26 PM,Default,Error on calling the 'OnBarUpdate' method for indicator 'BidAskRatio' on bar 0: BidAskRatio.DrawText: startBarsAgo out of valid range 0 through 0, was 1.,

      Yes, there are pleny of bars on the chart! I think perhaps it is because the assignmentof my vars:
      BidPressure=GetCurrentBidVolume()
      BidPressure=GetCurrentAskVolume()
      is limiting the scope to the current bar?

      Comment


        #4
        please note that the script sent indeed used 0 for start barsago and It is when this value is 1 that the script fails:

        DrawArrowUp("Pressure",0,Close[0]+(Pressure/100),Color.Red);

        should be:

        DrawArrowUp("Pressure",1,Close[0]+(Pressure/100),Color.Red);

        Comment


          #5
          Hello,

          You're running into the issue below:



          You'll need a CurrentBar check.

          Code:
           
          if (CurrentBar < startBarsAgo)
             return;
          startBarsAgo is whatever value you plug in for this parameter on your DrawText() statement.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            protected override void OnBarUpdate()
            {
            if(CurrentBar < 1)return;
            double Pressure;
            int BidPressure=GetCurrentBidVolume();
            int AskPressure=GetCurrentAskVolume();
            if (BidPressure>AskPressure)
            {
            Pressure=BidPressure/AskPressure;
            DrawArrowUp("Pressure",0,Close[0]+(Pressure/100),Color.Red);
            }
            else
            {
            Pressure=-AskPressure/BidPressure;
            DrawArrowDown("Pressure",0,Close[0]+(Pressure/100),Color.Green);
            }
            DrawText("PressureText",Pressure.ToString(),0,Clos e[0],Color.Black);
            }

            Edit: Oops sorry, I see it was answered
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment


              #7
              Thx, that did it!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              579 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              554 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X