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 SalmaTrader, 07-07-2026, 10:26 PM
              0 responses
              36 views
              0 likes
              Last Post SalmaTrader  
              Started by CarlTrading, 07-05-2026, 01:16 PM
              0 responses
              20 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 06-17-2026, 10:32 AM
              0 responses
              14 views
              0 likes
              Last Post CaptainJack  
              Started by kinfxhk, 06-17-2026, 04:15 AM
              0 responses
              19 views
              0 likes
              Last Post kinfxhk
              by kinfxhk
               
              Started by kinfxhk, 06-17-2026, 04:06 AM
              0 responses
              22 views
              0 likes
              Last Post kinfxhk
              by kinfxhk
               
              Working...
              X