Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetCurrentBid(); not working?

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

  • TiggerTrader
    replied
    Nevermind, we passed in the mail. I got it and it works now, thanks.........

    Sorry for the struggle.

    Leave a comment:


  • TiggerTrader
    replied
    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?

    Leave a comment:


  • koganam
    replied
    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.

    Leave a comment:


  • NinjaTrader_RyanM1
    replied
    If you're looking for more information on the error you're getting, please see my post #20 in this thread.

    Leave a comment:


  • TiggerTrader
    replied
    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.

    Leave a comment:


  • koganam
    replied
    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 ?

    Leave a comment:


  • TiggerTrader
    replied
    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?

    Leave a comment:


  • koganam
    replied
    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.

    Leave a comment:


  • NinjaTrader_RyanM1
    replied
    Your log does not show that much activity. Make sure you aren't filtering categories in the log tab. Right Click > Filter by category > Check all these.

    Leave a comment:


  • TiggerTrader
    replied
    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.
    Attached Files

    Leave a comment:


  • koganam
    replied
    Originally posted by TiggerTrader View Post
    The Log tab shows only my trade activity, no errors or warnings of any kind.
    That is not possible. Please note the time, refresh the chart to reload the indicator, then look in the log for the entries that match the EXACT time that you loaded the indicator. There is a lot of information in the log, so you have to look for what is there by matching the times that the problem may have occurred.

    Leave a comment:


  • TiggerTrader
    replied
    The Log tab shows only my trade activity, no errors or warnings of any kind.

    Leave a comment:


  • koganam
    replied
    Originally posted by TiggerTrader View Post
    Ooops... sorry again. I've tried both. You pick, situation for Ask is also borken. You can use either. When DrawRay is commented out, you get a stream of current prices happening. When you compile it in, only 11877 once.
    Now, that we have cleared that up, please go and look in the Log tab of the Control Center and tell me what the log says about the situation. I have been asking for more than 3 hours now. Is there any particular reason why you prefer not to look where I am requesting you to look?

    Leave a comment:


  • TiggerTrader
    replied
    Ooops... sorry again. I've tried both. You pick, situation for Ask is also borken. You can use either. When DrawRay is commented out, you get a stream of current prices happening. When you compile it in, only 11877 once.

    Leave a comment:


  • koganam
    replied
    Originally posted by TiggerTrader View Post
    This originally started as a way to draw a line above and below the current price to represent potential stop points for a trade. They would move up and down with the current price. It didn't work so I try to "debug" by printing the current price. At that time "GetCurrentBid()" showed an odd number like 11877 even tho the current price was 12121 on the YM 89 tick chart I am using. I comment out the DrawRay line and then the GetCurrentBid() prints out the current price correctly as it changes. Whereas when DrawRay is in the compile, GetCurrentBid() only prints 11877 once and nothing else.

    Does that clear it up?

    P.S. Thanks for your help so far, I appreciate it.
    Not for me it does not. GetCurrentBid() is not the same thing as GetCurrentAsk(). You keep writing about GetCurrentBid(), and when I ask about it, you respond with some statement about GetCurrentAsk().

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by SalmaTrader, 07-07-2026, 10:26 PM
0 responses
35 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
12 views
0 likes
Last Post CaptainJack  
Started by kinfxhk, 06-17-2026, 04:15 AM
0 responses
18 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 06-17-2026, 04:06 AM
0 responses
20 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Working...
X