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

GetCurrentBid(); not working?

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

    #31
    Originally posted by TiggerTrader View Post
    Here is the export of the log. I closed a position at 11:51:56, you see the entry. I cleared the output window. I Refreshed the indicator. The ouput window shows 1 entry of 11877. And this is the log, no error. It is an Excel CSV saved as TXT.

    This is a simple script. I would think anyone could load it and try it and see the same results. Try it if you like.
    Yes, I could load the script but I do not want to put it on my machine during trading hours. Moreover, I am trying to help you to use the nice facility that Ninja Trader has so thoughtfully provided for tracking errors, so that next time you will be able to quickly see for yourself where potential errors might arise.

    At this stage, I can say for certain that we are talking at cross purposes, because I am absolutely certain that if the indicator is showing no output, then there is an error in the log. If you insist that there is no error, then I can be of no further help at this time.

    After market hours, I may be more amenable to loading a known defective indicator into my system.

    Comment


      #32
      Ta Da!!!!

      startBarsAgo out of valid range. Hmmm... Too bad the Help file couldn't of told me that. Both start & end MUST be 0. According to the log file. But that doesn't make sense. How can it draw a line?

      Comment


        #33
        Originally posted by TiggerTrader View Post
        Ta Da!!!!

        startBarsAgo out of valid range. Hmmm... Too bad the Help file couldn't of told me that. Both start & end MUST be 0. According to the log file. But that doesn't make sense. How can it draw a line?
        Might you be able to paste the exact text in here ?

        Comment


          #34
          The Line of code (modified the values a couple times):
          DrawRay("UpTrendLine", false, 1, GetCurrentBid()+5, 0, GetCurrentBid()+5, upTrendColor, DashStyle.Solid, LineWidth);
          Errors:
          Error on calling the 'OnBarUpdate' method for indicator 'StopLinesJPW' on bar 0: StopLinesJPW.DrawRay: startBarsAgo out of valid range 0 through 0 was 1.

          Error on calling the 'OnBarUpdate' method for indicator 'StopLinesJPW' on bar 0: StopLinesJPW.DrawRay: endBarsAgo out of valid range 0 through 0 was 5.

          Comment


            #35
            If you're looking for more information on the error you're getting, please see my post #20 in this thread.
            Ryan M.NinjaTrader Customer Service

            Comment


              #36
              Originally posted by TiggerTrader View Post
              The Line of code (modified the values a couple times):
              DrawRay("UpTrendLine", false, 1, GetCurrentBid()+5, 0, GetCurrentBid()+5, upTrendColor, DashStyle.Solid, LineWidth);
              Errors:
              Error on calling the 'OnBarUpdate' method for indicator 'StopLinesJPW' on bar 0: StopLinesJPW.DrawRay: startBarsAgo out of valid range 0 through 0 was 1.

              Error on calling the 'OnBarUpdate' method for indicator 'StopLinesJPW' on bar 0: StopLinesJPW.DrawRay: endBarsAgo out of valid range 0 through 0 was 5.
              Now that we have that, let us see if we can decode what it is telling us.
              • StopLinesJPW.DrawRay: startBarsAgo out of valid range 0 through 0 was 1.
              • ...
              • StopLinesJPW.DrawRay: endBarsAgo out of valid range 0 through 0 was 5.

              So now, we know for certain that the DrawRay() line is the problem, and the index values are the issue.

              That leads me to propose 3 possible solutions:

              1. This is what I call the elegant approach, because it makes the call stand absolutely on its own, with no dependence on the intended or side-effects of any other statement. Essentially, we will start drawing from as many bars back as we have on the chart until we have 20 bars; then we will draw from 20 bars back.
              Code:
              DrawRay("UpTrendLine", false, Math.Min(CurrentBar, 20), GetCurrentAsk(), Math.Min(CurrentBar, 5), GetCurrentAsk(), upTrendColor, DashStyle.Solid, LineWidth);
              2. This next one is the sledge hammer approach. It says that we will not even continue processing anything unless we have the minimum 20 bars we need for the DrawRay() statement. Now, of course, if you later decide to let DrawRay() draw from further back, then this statement's side effect will be to create the same original error. We do this by placing this statement as the first statement in the OnBarUpdate() method.
              Code:
              if (CurrentBar < 20) return;
              3. Somewhat in between these methods, is what we shall call the ball-peen (maybe, plastic? ) hammer approach, where we put the filter onto the DrawRay() statement itself thus:
              Code:
              if (CurrentBar >= 20) DrawRay("UpTrendLine", false, 20, GetCurrentAsk(),  5, GetCurrentAsk(), upTrendColor,  DashStyle.Solid, LineWidth);
              Here, because the filter is on the Drawing statement itself, the line is immune from the intended or side-effects of any other statement. However, you still are basically using a hammer to delay processing this line until there are enough bars.
              Last edited by koganam; 06-22-2011, 12:04 PM.

              Comment


                #37
                Interesting, but I am at a total loss for understanding it.

                Here's new code:
                Print( GetCurrentBid() );

                Print( CurrentBar );

                if (CurrentBar < 20) return;

                DrawRay("UpTrendLine", false, 20, GetCurrentBid()+5, CurrentBar, GetCurrentBid()+5, upTrendColor, DashStyle.Solid, LineWidth);

                This seems to be working somewhat, but oviously I have no idea how DrawRay is supposed to work. What I want is a line that starts 5 or so bars to the left and continues to the right side of the chart. I have a line going to the left starting from 21 bars ago. How do I reverse that?

                This code:
                DrawRay("UpTrendLine", false, CurrentBar, GetCurrentBid()+5, 0, GetCurrentBid()+5, upTrendColor, DashStyle.Solid, LineWidth);

                Produces a horizontal line. How do I get it to only start the line maybe 5 bars back?

                Comment


                  #38
                  Nevermind, we passed in the mail. I got it and it works now, thanks.........

                  Sorry for the struggle.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by AaronKoRn, Today, 09:49 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post AaronKoRn  
                  Started by carnitron, Today, 08:42 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post carnitron  
                  Started by strategist007, Today, 07:51 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post strategist007  
                  Started by StockTrader88, 03-06-2021, 08:58 AM
                  44 responses
                  3,980 views
                  3 likes
                  Last Post jhudas88  
                  Started by rbeckmann05, Today, 06:48 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post rbeckmann05  
                  Working...
                  X