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 f.saeidi, Today, 08:01 PM
|
0 responses
2 views
0 likes
|
Last Post
by f.saeidi
Today, 08:01 PM
|
||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Today, 07:51 PM
|
0 responses
3 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
5 responses
96 views
1 like
|
Last Post
by caryc123
Today, 07:47 PM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
6 responses
49 views
0 likes
|
Last Post
by algospoke
Today, 06:18 PM
|
||
Started by arvidvanstaey, Today, 02:19 PM
|
4 responses
11 views
0 likes
|
Last Post Today, 04:08 PM |
Comment