I did this, and some alerts come in seeming accurate, and a few show technical conditions that shouldn't pass my logic. I added to my historical check:
if(Historical)
{
if(Time[0].Date == DateTime.Today)
{
Print("Historical data: " + Time[0]);
}
return;
}
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
Add(PeriodType.Day,1);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
//2
protected override void OnBarUpdate()
{
if(Historical)
{
if(Time[0].Date == DateTime.Today)
{
Print("Historical data: " + Time[0]);
}
return;
}
for (int index = 0; index < BarsArray.Length; index++)
{
if (CurrentBars[index] < (slowMA+12)) return;
}
if(BarsInProgress == 0)
{
int retraceType = 0;
//Is current intraday action favorable?
if((Close[0] > Open[0]) && (EMA(5)[0] > EMA(10)[0]))
{
int uptrendCheckCount = 0;
int countOfClosesOverSlowEma = 0;
double todaysEstimatedDailySlowMovAvg = (EMA(Closes[1],slowMA)[0] + Math.Abs(EMA(Closes[1],slowMA)[0] - EMA(Closes[1],slowMA)[1]));
double keyPriceViolationLevelPriorDay = EMA(Closes[1],slowMA)[0] * 1.025;
double keyPriceViolationLevelToday = todaysEstimatedDailySlowMovAvg * 1.025;
//Make sure current price is > today's estimated slow daily MA.
if(Close[0] > todaysEstimatedDailySlowMovAvg)
{
//Check for uptrend on daily
for(int i = 0;i < 10;i++)
{
//Count up mov avg lines are stacked daily bars
if((EMA(Closes[1],fastMA)[i] >= EMA(Closes[1],medMA)[i]) && (EMA(Closes[1],medMA)[i] >= EMA(Closes[1],slowMA)[i]))
uptrendCheckCount++;
//Count up past closes >= slow ma line-small buffer (.1%) daily bars
if(Closes[1][i] >= EMA(Closes[1],slowMA)[i] * .999)
countOfClosesOverSlowEma++;
}
if((countOfClosesOverSlowEma == 10) && (uptrendCheckCount == 10)) //if it's an uptrend
{
//if close yesterday violated level, or
if(Closes[1][0] <= keyPriceViolationLevelPriorDay) retraceType = 1;
//if today's price level has been violated,
else if(Low[LowestBar(Low,Bars.BarsSinceSession-1)] < keyPriceViolationLevelToday) retraceType = 2;
}
}
}
Plot0.Set(retraceType);
}
}

Comment