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

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 trilliantrader, 04-18-2024, 08:16 AM
              5 responses
              22 views
              0 likes
              Last Post trilliantrader  
              Started by Davidtowleii, Today, 12:15 AM
              0 responses
              3 views
              0 likes
              Last Post Davidtowleii  
              Started by guillembm, Yesterday, 11:25 AM
              2 responses
              9 views
              0 likes
              Last Post guillembm  
              Started by junkone, 04-21-2024, 07:17 AM
              9 responses
              70 views
              0 likes
              Last Post jeronymite  
              Started by mgco4you, Yesterday, 09:46 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X