DrawText("7",true,"T", 2 ,High[2],0,Color.Blue,new Font("Arial", 8),StringAlignment.Center,Color.Black,Color.Yellow,10 );
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!
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
NinjaTrader
How to refer to a specefic bar
Collapse
X
-
How to refer to a specefic bar
I am trying to DrawText on a specific bar but how do I refer to that bar, I have tried many things but with no success
Code:Tags: None
-
Hello,
This line of code is correct however you will need to add an additional check to ensure enough bars have been loaded before hand. If you go to tools -> output window you would see an error message
This can be avoided with a current bar check at the start of your OnBarUpdate()
example
if(CurrentBar < 2)
return;
Let me know if I can further assist.LanceNinjaTrader Customer Service
-
Thank you for the very fast reply,
when I enter the if statement it worked fine for 2 bars ago, and then I modified it to
Code:if (CurrentBar < 200) return;
Comment
-
You are correct in noticing Count will be the total number of bars on the chart.
However when an indicator is run it starts processing on bar 0 and will evaluate from left to right. The error is then being generated because it's trying to place a drawing object where there is no data at the very start
CurrentBar allows you to see the current bar that's being processed where as Count give total bars on the chart
Let me know if I can further assist.LanceNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by helpwanted, Today, 03:06 AM
|
1 response
16 views
0 likes
|
Last Post Today, 03:35 AM | ||
Started by Brevo, Today, 01:45 AM
|
0 responses
11 views
0 likes
|
Last Post
by Brevo
Today, 01:45 AM
|
||
Started by aussugardefender, Today, 01:07 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 01:07 AM | ||
Started by pvincent, 06-23-2022, 12:53 PM
|
14 responses
244 views
0 likes
|
Last Post
by Nyman
Today, 12:47 AM
|
||
Started by TraderG23, 12-08-2023, 07:56 AM
|
9 responses
387 views
1 like
|
Last Post
by Gavini
Today, 12:29 AM
|
Comment