Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Spread Strategy As Indicator, StrategyPlot
Collapse
X
-
Spread Strategy As Indicator, StrategyPlot
I may be an idiot but I have been trying to get a strategy to print a spread of two tickers for me with zero luck. Anyone have an example? I can't even get ANYTHING to print on the StrategyPlot... user error I know but I would appreciate the help of a small tip or pointer.Tags: None
-
Thanks, here it is. When I add this strategy, for example to a NYA chart, I get two StrategyPlot indicators at the bottom but nothing shows up in them.
Code:public class ZenVolAnalysis : Strategy { #region Variables // Wizard generated variables // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { CalculateOnBarClose = false; //Add(PeriodType.Minute, 3); Add("VOL", PeriodType.Minute, 30); Add("UVOL", PeriodType.Minute, 30); Add("DVOL", PeriodType.Minute, 30); /* Add our blank placeholder indicators. The parameter we pass in is used to distinguish the two indicators from each other. */ Add(StrategyPlot(0)); Add(StrategyPlot(1)); StrategyPlot(0).Plots[0].PlotStyle = PlotStyle.Bar; StrategyPlot(1).Plots[0].PlotStyle = PlotStyle.Bar; // Set the color for the indicator plots StrategyPlot(0).Plots[0].Pen.Color = Color.LawnGreen; StrategyPlot(1).Plots[0].Pen.Color = Color.Crimson; // Set the panel which the plots will be placed on. 1 = price panel, 2 = panel under the price panel, etc. StrategyPlot(0).PanelUI = 2; StrategyPlot(1).PanelUI = 3; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if(Input[0] != 0) { StrategyPlot(0).Value.Set(Math.Round(BarsArray[1][0]/Input[0],2)); StrategyPlot(1).Value.Set(Math.Round(BarsArray[2][0]/Input[0],2)); } }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
47 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
22 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
15 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
21 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
23 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment