Thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Plot in Strategies
Collapse
X
-
Plot in Strategies
Is it possible to use plots in strategies instead of Drawing Objects, the same way you would use them in an Indicator? I have dots in a strategy that draw at a specific price under certain conditions. They create a line of dots for a period of time. I would prefer a simple dash (hash), but they are not available in drawing objects.
ThanksTags: None
-
Hi Ken,
Yes, you could follow this sample for plotting within a NinjaScript strategy:
When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the abilityRyan M.NinjaTrader Customer Service
-
I've successfully added strategy plots but they seem to use a lot of code. For 3 dotted lines it uses this code:
protectedoverridevoid Initialize()
{
Add(StrategyPlot(0)); // Buy Entry Price
StrategyPlot(0).Plots[0].Pen.Color = Color.Lime;
StrategyPlot(0).Plots[0].Pen.Width = 3;
StrategyPlot(0).Plots[0].Pen.DashStyle = DashStyle.Dash;
StrategyPlot(0).PanelUI = 1;
Add(StrategyPlot(1)); // Buy Target Price
StrategyPlot(1).Plots[0].Pen.Color = Color.White;
StrategyPlot(1).Plots[0].Pen.Width = 3;
StrategyPlot(1).Plots[0].Pen.DashStyle = DashStyle.Dash;
StrategyPlot(1).PanelUI = 1;
Add(StrategyPlot(2)); // Buy Stop Price
StrategyPlot(2).Plots[0].Pen.Color = Color.Gold;
StrategyPlot(2).Plots[0].Pen.Width = 3;
StrategyPlot(2).Plots[0].Pen.DashStyle = DashStyle.Dash;
StrategyPlot(2).PanelUI = 1;
}
protectedoverridevoid OnBarUpdate()
{
if (condition)
StrategyPlot(0).Value.Set(EntryPrice); // Buy Entry Price
if (condition)
StrategyPlot(1).Value.Set(TargetPrice); // Buy Target Price
if (condition)
StrategyPlot(2).Value.Set(StopPrice); // Buy Stop Price
}
Is there a more condensed or effecient way of accomplishing this and can "StrategyPlot(0)" be named something else like "EntryPricePlot"? This seems to use a lot of lines of code..
Thanks
Comment
-
StrategyPlot is a dummy indicator, basically a placeholder for what you do with the plots in the strategy. You can name your own dummy indicator whatever you like.
A strategies main purpose is for automated order placement, not charting. This structure is required in order to have the strategy do things that are generally more suited for an indicator.Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by WHICKED, Today, 12:56 PM
|
1 response
8 views
0 likes
|
Last Post Today, 01:17 PM | ||
Started by cre8able, Today, 01:16 PM
|
0 responses
1 view
0 likes
|
Last Post
by cre8able
Today, 01:16 PM
|
||
Started by chbruno, 04-24-2024, 04:10 PM
|
2 responses
47 views
0 likes
|
Last Post
by chbruno
Today, 01:15 PM
|
||
Started by WHICKED, Today, 12:45 PM
|
1 response
11 views
0 likes
|
Last Post Today, 01:08 PM | ||
Started by samish18, Today, 01:01 PM
|
0 responses
5 views
0 likes
|
Last Post
by samish18
Today, 01:01 PM
|
Comment