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
DrawLine in a multi-insrument strategy
Collapse
X
-
DrawLine in a multi-insrument strategy
Hello- I'm having problems getting the DrawHorizontalLine statement to work. It's a multi-instrument strategy. Here's the statement with the associated overloads I'm using: DrawHorizontalLine("tag1", Closes[0][0], Color.Black); The chart that is plotted is the primary instrument but I don't see any lines.
Tags: None
-
Hello ciro1963,
Thank you for your note.
May I confirm the strategy was compiled after adding the code and the strategy is enabled on the chart?
Have you used prints to determine on which bar times an object should be appearing? (prints appear in the output window)
If you right-click the chart, select Drawing Tools > select Remove Drawing Objects, do you find that Horizontal lines is appearing?Chelsea B.NinjaTrader Customer Service
-
The statement: DrawHorizontalLine("tag1", Closes[0][0], Color.Black) doesn't appear to wok by itself. The statement is located under a buy condition block I wrote in my strategy. I'm trying to get it to plot in the strategy chart in strategy analyzer (backtester). I'm not sure if I need to initialize anything for this particular statement. Maybe "ADD plot" function in the Initialize section? Th print statements do prove that I'm entering the condition block at various points in time.In fact, I am able to draw a backround color if I enter the condition using the BackColorAll = Color.Green statement.So some of the drawing snippets work properly.
Comment
-
Hello ciro1963,
I am not able to reproduce this behavior where the line does not appear.
I have copied and pasted your line of code into a strategy and I am finding when the strategy is enabled this is drawing on the last bar without issue as expected.
Screenshot and test script attached.
On your end, please test this script. When setting Enabled to true and clicking OK do you see a line appear on your chart?
If not, may I have a screenshot of your chart so I may confirm there is data on the chart and that the strategy is enabled?Chelsea B.NinjaTrader Customer Service
Comment
-
Hi ChelseaB- I ran your script it works. I see what's happening now. The line that is drawn is the most recent closing price of the instrument in question. It does not dynamically change as the price of the stock changes. It just draws the most recent price. How can I get this line to update through time so I can scroll back to see historical level. Ultimately I want this line not to be the closing price but rather some factor of the closing price.
Comment
-
Hello ciro1963,
You want one line that moves to different prices?
That's fine to do.
I have demonstrated the issue is not calling DrawHorizontalLine(). This works fine.
The issue is with the logic in your script.
This brings us back to post #4.
May we see the output from your prints and the code of the print?
Is this being printed in the action block of the condition set or outside of it?Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
94 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
6 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
158 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
7 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
||
Started by zstheorist, Yesterday, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Yesterday, 07:52 PM
|
Comment