View Full Version : Strategy Plots Multi Instrument
raz0rback
06-23-2008, 07:05 PM
Gday all,
I am trying to PLOT multiple instruments in my strategies. I have looked at the samples and docs and i think i have added the multi instruments correctly. However I dont know the syntax for drawing a plot line in the UI panels.
Here is my code structure:
protected override void Initialize()
{
CalculateOnBarClose = false;
Add("ZN 09-08", PeriodType.Minute, 1); //BarsArray 1
Add("^TRIN", PeriodType.Minute, 1); //BarsArray 2
Add(StrategyPlot(0));
StrategyPlot(0).Plots[0].Pen.Color = Color.YellowGreen;
StrategyPlot(0).PanelUI = 2;
Add(StrategyPlot(1));
StrategyPlot(1).Plots[0].Pen.Color = Color.YellowGreen;
StrategyPlot(1).PanelUI = 3;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
StrategyPlot(0).Value.Set(EMA(BarsArray[1],5)[0]);
StrategyPlot(1).Value.Set(Closes[2][0]);
}
What am i missing?
Cheers.
NinjaTrader_Josh
06-23-2008, 09:44 PM
Hi raz0rback,
What do you mean by plot lines? Each StrategyPlot() you add will essentially be 1 line. You could add more StrategyPlot()s and set them to take the value of whatever line you want to draw and use the .PanelUI to put them into whichever panel you want.
raz0rback
06-23-2008, 10:50 PM
thanks for the quick reply Josh.
What you suggest is what I thought would happen. However, what is happening is the 2 indicator panels are being created but not line is plotted.
is there some other code i need to enter the data into the strategyplot dataseries and then to draw the plot of that dataseries?
NinjaTrader_Josh
06-23-2008, 11:45 PM
I think code wise that should do it. Only thing I can think of is if you actually have enough data in your bar series to populate it. Please try switching it to one instrument different time periods to check your code for if it works or not. Also check out the Control Center for fishy error messages.
raz0rback
06-26-2008, 01:52 AM
Josh,
I have spent several hours trying to resolve this problem. I have recently tried running the "SampleStrategyPlot" file on my system.
I have found the same error.
Charts do not show the strategy plots at all.
Is this a bug with ninja? I cant figure this out.
Steve
raz0rback
06-26-2008, 01:57 AM
Josh,
Further to that, there is no error msgs. The strategy seems to request the data for the multiple instruments but not plotting. I have also tried just using one instrument and plotting multiple timeframes to no avail.
any help is appreciated.
NinjaTrader_Josh
06-26-2008, 02:13 AM
What version of NinjaTrader are you running? Please take note that it will not work for backtesting in the Strategy Analyzer. Not a bug; rather a limitation.
raz0rback
06-26-2008, 02:16 AM
6.5.1000.4
Machine ID: 83E3881DF8EDA04D7E1399A5332FBFD1
.NET Version: 2.0.50727.1434
Expiration: 31/12/2099
Really not sure what is going on but as I said it doesnt display the sample so there must be some underlying issue.
Thanks
NinjaTrader_Josh
06-26-2008, 03:18 AM
Are you backtesting or are you live? Please confirm running SampleStrategyPlot on a 1min chart of AAPL that has data for at least a few days.
1. Connect to your data feed
2. Open a 1min chart of AAPL
3. Wait for chart to populate
4. Throw SampleStrategyPlot on the chart
5. Confirm that you see two plot lines on the price panel
Please beware that you need enough data for all time periods/instruments.
raz0rback
06-26-2008, 03:23 AM
backtesting.
i have tried running the sample on the same version of NT on another machine. Same result. Both are vista 64bit. Not sure if that has anything to do with it.
gee mate you work hard. shouldnt you be sleeping at these hours?
NinjaTrader_Josh
06-26-2008, 03:25 AM
Backtesting will not work. The feature only works on realtime charts.
raz0rback
06-26-2008, 08:46 AM
its always the simple things that baffle people.
cheers mate.
ATI user
10-09-2008, 05:31 AM
Hi raz0rback,
What do you mean by plot lines? Each StrategyPlot() you add will essentially be 1 line. You could add more StrategyPlot()s and set them to take the value of whatever line you want to draw and use the .PanelUI to put them into whichever panel you want.
Josh
I have been plotting from my strategy for months thanks to strategyplot. I now want to plot a channel..i.e. upper and lower boundaries to the main plot.
Based on what you are saying "...essentially be 1 line...", do I have to add separate strategyplots for each line?...or is there an easier way (such as adding the 2 extra lines to the exiting strategplot indicator...which I have not been able to get working so far)
Thanks
ps. adding the two extra strategy plots works fine...just thought there might be a more elegant solution than adding more indicators
NinjaTrader_Josh
10-09-2008, 08:26 AM
ATI user,
Unfortunately there is no other solution we can currently offer you.
ATI user
10-09-2008, 10:28 AM
Thanks Josh
Is there a way to shade the area between the two outer indicators?
NinjaTrader_Josh
10-09-2008, 10:30 AM
Try using DrawRegion() and pass in the two separate indicators as inputs.
ATI user
10-09-2008, 10:53 AM
doh...thanks...worked great
michael fantoni
08-20-2011, 11:08 AM
Hello there.
I have a question. Given a chart and an instrument plotted, say 6S, with its indicators in different panels, is it possible to add a further panel with an indicator which has as input series another instrument, say 6E?
There was a post about RSI but no further discussion.
Regards
NinjaTrader_Bertrand
08-20-2011, 02:02 PM
michael fantoni, yes you can do this on a MultiSeries chart, here you could use all the bars series as input series to other indicators in the UI :
http://www.ninjatrader.com/support/helpGuides/nt7/working_with_indicators.htm
michael fantoni
08-21-2011, 03:15 PM
Thank you Bertrand.
I have another question, somehow unrelated but I couldnt find any thread in the forum. Lets take a chart with various indicators plotted in their respective panels. I would like to create a signal at once when some conditions are met. For example, lets say that CCI=48 and RSI=34. I would like the respective bars of each separate panel to be, say, yellow IFF above. I saw how to do it for a single indicator, in fact I managed to replicate it for mine but I would need some cross reference from several indicators at once, cross relate indicators. Is it possible?
Regards
NinjaTrader_Bertrand
08-22-2011, 02:31 AM
michael, yes this would be possible either with custom coding in the NinjaScript editor or creating a strategy that would change the bar color as needed when your multiple indicators conditions trigger the signal as envisioned :
http://www.ninjatrader.com/support/helpGuides/nt7/strategy_wizard.htm
michael fantoni
08-22-2011, 07:00 AM
Thank you Bertrand.
I will go through the link. If you are aware of any example of such a thing uploaded in the forum or anywhere else, please do let me know.
Regards
michael fantoni
08-23-2011, 09:15 AM
Hi there
Anyone can help?
Im very new at programming. Im trying to convert Value.Set[0] to double for the momentum indicator. If I use the following command line:
protected override void OnBarUpdate()
{
Value.Set(CurrentBar == 0 ? 0 : Input[0] - Input[Math.Min(CurrentBar, Period)]);
if(Value[0]>0)
PlotColors[0][0] = upColor;
else
PlotColors[0][0] = dnColor;}
then it works as it should but if I try to use a non-integer figure it says error clearly. Where am I supposed to specify that I want Value.Set[0] a double? I tried few things and when it was compiling fine without errors then ninjatrader would shut down as soon as I would load the indicator on the chart.
Regards
NinjaTrader_Bertrand
08-23-2011, 09:56 AM
michael fantoni, I'm not exactly sure what you're trying to create here or comparing, but the main value series of the indicator would be a double value.
Can you please attach the indicator that would produce the crash so we can check into?
michael fantoni
08-23-2011, 10:07 AM
Hi Bertrand and thank you.
I managed to do what I meant. Unfortunately, I deleted the indicator I was fiddling around with to start afresh and avoid using it and I cant remember what I put into it. I should keep all the scripts from now on.
Thank you and regards.
NinjaTrader_Bertrand
08-23-2011, 10:11 AM
Yes, that's probably best for the learning experience : glad to hear you managed to get it resolved.