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 get price of a horizontal line
Collapse
X
-
How to get price of a horizontal line
I have drawn a horizontal line at the opening of trading day. I need a variable to represent the price at that line. "double closePrice = Bars.GetClose(barIndex);" at the exact time of starting trading would seem applicable but does not compile. Any suggestions?Tags: None
-
Hello Pete77,
What is the compile error you are getting?
Is barIndex defined as an integer and holding a value of the CurrentBar number when Bars.IsFirstBarOfSession is true?
To get the price of a horizontal line:
private HorizontalLine myLine;
myLine = Draw.HorizontalLine(this, "myHLine" + CurrentBar, Close[0], Brushes.Blue);
Print(myLine.StartAnchor);
Below is a link to the help guide.
Chelsea B.NinjaTrader Customer Service
- Likes 1
-
I have been looking for days for information on your statment: "Is barIndex defined as an integer and holding a value of the CurrentBar number when Bars.IsFirstBarOfSession is true?" Can you give me little help on this? My code now compiles but does not draw the line nor output any print statement.
(Myname should now be Pete99 instead of 77).
Comment
-
Hello Pete77,
What is barIndex?
Where is this defined?
What is the value of barIndex?
Where is this value assigned?
Is this value assigned any where?
Provide output from prints.
Print the time of the bar and all values in the condition that causes the object to be drawn, and print the y value the object is being drawn at.
Below is a link to a forum post that demonstrates using prints to understand behavior.
Chelsea B.NinjaTrader Customer Service
Comment
-
I realize I have a lot to learn. May I show you where I am at?
In both indicator and strategy I have been able to draw a horizontal line at 8:30, using "Close[0] of the 8:30 bar. I have used Close[0] as the Y value for adding other horizontal lines like Close[0] + 30 ticks. But Close[0] at 8:30 does not work for me for other objects like CrossAbove, Instantiate the line, etc. and printing Close[0] just gives me assorted numbers on the output window that mean nothing.
Obviously, I must make the index value stick at 8:30. "Define the index as integer". How to do this is where I am stuck.
Comment
-
Hello Pete77,
int is short for Integer.
To define a variable as an integer:
Code:private int myVariable;
Code:myVariable = 5;
Code:Print(myVariable);
Code:if (CurrentBar > myVariable) { Print(Close[myVariable]); }
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
7 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
18 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
4 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
12 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
||
Started by timmbbo, Today, 08:59 AM
|
2 responses
13 views
0 likes
|
Last Post
by bltdavid
Today, 04:10 PM
|
Comment