Here is my current code... can anyone help?
(I also know the high and low finding routine is hardcoded now for three periods, that is an issue I have not made it to yet)
protected override void OnBarUpdate()
{
DrawTextFixed("tempdate",Bars.SessionBegin.ToString(),TextPosition.BottomRight);
this.m_bFibsSet = true;
if(this.m_LastCurrentDate != Bars.SessionBegin)
{
this.m_LastCurrentDate = Bars.SessionBegin;
this.m_bFibsSet = false;
}
if(!this.m_bFibsSet && CurrentBar != 0)
{
if(Bars.Period.Id != PeriodType.Minute)
{
this.m_bFibsSet = true; //only plot this on minute charts
}
else
{
int nBarLength = Bars.Period.Value;
if(nBarLength > 10)
{
this.m_bFibsSet = true; //this is for 10-min charts or smaller
}
else
{
//we only want the most current session
//if( Bars.SessionBegin.Day == DateTime.Now.Day &&
// Bars.SessionBegin.Month == DateTime.Now.Month &&
// Bars.SessionBegin.Year == DateTime.Now.Year)
{
//we now need to find how many minutes have ticked by since the open
//how many minutes in a bar
int nNumBars = NumberOfMinutes/Bars.Period.Value;
if(Bars.BarsSinceSession == nNumBars)
{
//find the high
double nHigh = Math.Max(Math.Max(High[2],High[1]),High[0]);
double nLow = Math.Min(Math.Min(Low[2],Low[1]),Low[0]);
DrawFibonacciRetracements("TheFib",2,nHigh,0,nLow);
this.m_bFibsSet = true;
//DrawTextFixed("tempdate",this.m_LastCurrentDate.ToString(),TextPosition.BottomRight);
}
}
}
}
}

Comment