Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
GetCurrentBid(); not working?
Collapse
X
-
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.
-
Now I am confused. At 1924EDT today you wrote: "... No effect. Also, doing just that 1 change BROKE GetCurrentBid." I ask about that and you show me a line that talks about GetCurrentAsk(). Are we talking about the same things here?Originally posted by TiggerTrader View Postline 48: Print( GetCurrentAsk() );
Leave a comment:
-
TiggerTrader,
The ray draws as far as 20 bars back, which causes issues for the first 20 bars in the series. This type of error can usually be seen in log tab of control center, and is explained in more detail here.
To resolve, use this line to prevent processing for the first few bars:
if (CurrentBar < 20) return;
There is also a separate RemoveDrawObject line. This is not needed if you only want to replace the drawing object. If the tag stays the same the draw object is replaced to use the most recent values. RemoveDrawObject is used only if you want to remove it completely.
Leave a comment:
-
Except for using variables to hold some more of the parameters, I do not see a difference between this last file and the StopTest.cs file. I still cannot see any GetCurrentBid() in the StopLinesJPW.cs file. On what line is the statement?Originally posted by TiggerTrader View Postoops... wrong file. Here it is. When you comment out the DrawRay, the correct price gets printed as the price changes. When you put it back, bad price only once.
As the file is no different, I am still expecting you to look in the log and tell me the error that you see there. There MUST be one. Again, have you looked at the Log tab in the Control Center, for the last exact time that you tried to load the indicatorLast edited by koganam; 06-22-2011, 08:50 AM.
Leave a comment:
-
oops... wrong file. Here it is. When you comment out the DrawRay, the correct price gets printed as the price changes. When you put it back, bad price only once.Attached Files
Leave a comment:
-
We must be talking about different indicators. I downloaded the StopTest.cs file that you posted. I did not see any GetCurrentBid() call in there. The file that I downloaded MUST be creating an error in your log. Have you looked at the Log tab in the Control Center, for the last exact time that you tried to load the indicator (StopTest.cs)?Originally posted by TiggerTrader View PostNo error, just stops printing the current price and prints a garbage price once.
Leave a comment:
-
No error, just stops printing the current price and prints a garbage price once.
Leave a comment:
-
What is the error in your log?Originally posted by TiggerTrader View PostNo effect. Also, doing just that 1 change BROKE GetCurrentBid. Now it prints 11877 once and only once. This is frustrating. All I want is to draw a line above and below the current price as it changes.
StopTest.cs does not contain "GetCurrentBid()".Last edited by koganam; 06-22-2011, 07:43 AM.
Leave a comment:
-
No effect. Also, doing just that 1 change BROKE GetCurrentBid. Now it prints 11877 once and only once. This is frustrating. All I want is to draw a line above and below the current price as it changes.
Leave a comment:
-
The DrawRay() method that you are using requires the autoScale parameter.Originally posted by TiggerTrader View PostOK, so I've tried to reduce my problem. Started a new indicator. Now I can't get DrawRay to work...grrrrr... This version does print the correct price, but no ray is drawn. Help file doesn't help me see why it's not working. Please see attached script. I'm sure it's some small detail I missed.
Code:DrawRay("UpTrendLine", [COLOR=Red][B]false,[/B][/COLOR] 20, GetCurrentAsk()+5, 5, GetCurrentAsk()+5, upTrendColor, DashStyle.Solid, 2);
Leave a comment:
-
OK, so I've tried to reduce my problem. Started a new indicator. Now I can't get DrawRay to work...grrrrr... This version does print the correct price, but no ray is drawn. Help file doesn't help me see why it's not working. Please see attached script. I'm sure it's some small detail I missed.Attached Files
Leave a comment:
-
On Historical bars, that would make no difference, as the values can only be calculated on bar close anyway. (A Historical bar is one structure that has only one set of values for any bar. i.e., there is no intrabar granularity on Historical bars)Originally posted by TiggerTrader View PostNo, the prev gets set AFTER all the lines are drawn before exiting the routine. So when it runs, it prints the "Drawing Lines" once and only once. Which means the first time thru prevPrice = 0. Also, that doesn't explain why the Historical is kicking out the Print statements and why the
GetCurrentBid() is producing 11826 all the time.
Leave a comment:
-
The results you're getting seem expected to me. You're setting two variables equal to one another and returning out when they're equal. They're equal because you set them so, and return doesn't allow the whole block to be processed.
Keep in mind this is run against all historical bars so you may need to simplify and print all values, along with the corresponding bar index CurrentBar, to track what it's doing.
Leave a comment:
-
No, the prev gets set AFTER all the lines are drawn before exiting the routine. So when it runs, it prints the "Drawing Lines" once and only once. Which means the first time thru prevPrice = 0. Also, that doesn't explain why the Historical is kicking out the Print statements and why the
GetCurrentBid() is producing 11826 all the time.
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
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
20 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
12 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
18 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
20 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Leave a comment: