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 alifarahani, Today, 09:40 AM
              3 responses
              15 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by RookieTrader, Today, 09:37 AM
              4 responses
              18 views
              0 likes
              Last Post RookieTrader  
              Started by PaulMohn, Today, 12:36 PM
              0 responses
              5 views
              0 likes
              Last Post PaulMohn  
              Started by love2code2trade, 04-17-2024, 01:45 PM
              4 responses
              40 views
              0 likes
              Last Post love2code2trade  
              Started by junkone, Today, 11:37 AM
              3 responses
              26 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X