Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm having a hard time understanding how to program a multi timeframe NinjaTrader indicator.
What I'm trying to do is really simple:
I want to plot the value of a data series which was calculated using daily data and apply it to a minute chart.
As a simple example, let's say I had an indicator (please see HiLoOpen attached below) that calculates the average of the previous day high, the previous day low, and the current day open. This data would be saved in a data series called HiLoOpenPlot:
HiLoOpenPlot[0] = (High[1]+Low[1]+Open[0])/3
To make this DataSeries accessible from another indicator, I would include the following in the Properties region:
[Browsable(false)]
[XmlIgnore]
public Series<double> Callable_HiLoOpen
{
get { return HiLoOpenPlot; }
}
I have a second indicator called HiLoOpenINTRADAY (also attached below), which is supposed to draw the current value of HiLoOpenPlot[0] (calculated using day bars) as a horizontal line on a minute chart:
Predictably, if I put HiLoOpenINTRADAY, on a minute chart it does not draw a horizontal line based on day bars, but rather on minute bars.
After reading through the Multi Time Frame & Instruments article in the NinjaTrader 8 Help Guide and the info on the AddDataSeries() method, I attempted to create another indicator -- HiLoOpenVersion2 (please see the indicator attached to this post). This indicator also isn't drawing the expected horizontal line.
At this point, I am at a loss as to how to proceed. I've spent the past three days and countless hours on this and I'm hitting a brick wall. I don't want to ask someone to do the coding for me, but I could really use some detailed guidance on how to approach this... it can't be too difficult to make this work.
Trading: The one I'm creating in the present....Index Futures mini/micro, ZF
Posts: 2,311 since Nov 2011
Thanks Given: 7,341
Thanks Received: 4,518
Use this instead...
Close[0] (primary dataseries current closing price) vs Closes[0][0] (this is also the primary dataseries closing price) vs Closes[1][0] (this is the the first of the secondary dataseries added in the indicator and it's current closing price)
as I did here....
also add this
And remove your current CurrentBar code or comment it out.
Ron
...My calamity is My providence, outwardly it is fire and vengeance, but inwardly it is light and mercy...
The steed of this Valley is pain; and if there be no pain this journey will never end.
Buy Low And Sell High (read left to right or right to left....lol)
I've logged out of my trading computer for the day as it is getting late where I live, but I will use your suggestion tomorrow morning and let you know how it goes.
Ron, I made the changes suggested in your reply from yesterday:
These changes are reflected in the attached indicator file HiLoOpenVersion3.
An interesting problem has arisen: If I apply the indicator to a chart with an interval of day or higher, the expected horizontal line is drawn. However, if I apply the indicator to a chart with an interval of less than a day, the line isn't drawn.
Do you know of any way to get the line to plot on a chart with an intraday interval?
Ron, I made the changes suggested in your reply from yesterday:
private Double MyPriceLevel = 0;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "HiLoOpenVersion2";
Calculate = Calculate.OnPriceChange;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
BarsRequiredToPlot = 10;
}
else if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Day, 1);
}
}
protected override void OnBarUpdate()
{
if(CurrentBars[0] <= BarsRequiredToPlot || CurrentBars[1] <= BarsRequiredToPlot)
return;
if (BarsInProgress == 1)
{
MyPriceLevel = (Highs[1][1]+Lows[1][1]+Opens[1][0])/3;
Draw.HorizontalLine(this,"Horiz1",MyPriceLevel,Brushes.Gold,DashStyleHelper.Solid,2);
}
if (BarsInProgress == 0)
{
}
}
These changes are reflected in the attached indicator file HiLoOpenVersion3.
An interesting problem has arisen: If I apply the indicator to a chart with an interval of day or higher, the expected horizontal line is drawn. However, if I apply the indicator to a chart with an interval of less than a day, the line isn't drawn.
Do you know of any way to get the line to plot on a chart with an intraday interval?
I did something similar recently. I plot on the lower timeframe when I have processed all the higher timeframes, on the last but one bar of the last secondary timeframe:
if (BarsInProgress > 0 && CurrentBar == (BarsArray[BarsArray.Count() - 1].Count - 2))
{
// Plot here
}
Ron and iq200 thanks for the feedback! I've had little opportunity to work on this in the past few days. I will post back here as soon as I'm back up to speed on this.
I have made some progress, but its getting obvious that I've gone beyond my level of programming experience.
To illustrate the problem I'm having, the code below is supposed to draw a line at the level of the previous day's high on an intraday chart. Unfortunately, the line is at the high of two days ago.
I'm missing something in the code, but can't figure out what.
Trading: The one I'm creating in the present....Index Futures mini/micro, ZF
Posts: 2,311 since Nov 2011
Thanks Given: 7,341
Thanks Received: 4,518
w4w4w
I have made some progress, but its getting obvious that I've gone beyond my level of programming experience.
To illustrate the problem I'm having, the code below is supposed to draw a line at the level of the previous day's high on an intraday chart. Unfortunately, the line is at the high of two days ago.
I'm missing something in the code, but can't figure out what.