In the code it is calculating the pivots before making any entry decision so I dont quite understand how this is happening. Here is the calculation and entry logic,
protected override void OnBarUpdate()
{
if(CurrentBars[1] <= 1)
return;
if(CurrentBars[1] == null)
return;
if(BarsInProgress != 0)
return;
// If there is a new session add one to session count.
if(Bars.SessionBreak)
sessionCount++;
#region Calculate and Draw Pivots
// Calculate Pivot Points
pp = Math.Round((Highs[1][1] + Lows[1][1] + Closes[1][1])/3,2);
r1 = Math.Round((2 * pp) - Lows[1][1],2);
s1 = Math.Round((2 * pp) - Highs[1][1],2);
r2 = Math.Round(pp + (Highs[1][1] - Lows[1][1]),2);
s2 = Math.Round(pp - (Highs[1][1] - Lows[1][1]),2);
r3 = Math.Round(r1 + (Highs[1][1] - Lows[1][1]),2);
s3 = Math.Round(s1 - (Highs[1][1] - Lows[1][1]),2);
// Draw Pivot Points
DrawLine("r3" + sessionCount, false, Bars.BarsSinceSession, r3, 0, r3 ,Color.Crimson,DashStyle.Dash,2);
DrawLine("r2" + sessionCount, false, Bars.BarsSinceSession, r2, 0, r2 ,Color.Crimson,DashStyle.Dash,2);
DrawLine("r1" + sessionCount, false, Bars.BarsSinceSession, r1, 0, r1 ,Color.Crimson,DashStyle.Dash,2);
DrawLine("pp" + sessionCount, false, Bars.BarsSinceSession, pp, 0, pp ,Color.Black,DashStyle.Dash,2);
DrawLine("s1" + sessionCount, false, Bars.BarsSinceSession, s1, 0, s1 ,Color.DarkGreen,DashStyle.Dash,2);
DrawLine("s2" + sessionCount, false, Bars.BarsSinceSession, s2, 0, s2 ,Color.DarkGreen,DashStyle.Dash,2);
DrawLine("s3" + sessionCount, false, Bars.BarsSinceSession, s3, 0, s3 ,Color.DarkGreen,DashStyle.Dash,2);
// Draw Lables
DrawText("r3l" + sessionCount, "R3 " + r3, 0, r3 + TickSize*1, Color.Crimson);
DrawText("r2l" + sessionCount, "R2 " + r2, 0, r2 + TickSize*1, Color.Crimson);
DrawText("r1l" + sessionCount, "R1 " + r1, 0, r1 + TickSize*1, Color.Crimson);
DrawText("pp1" + sessionCount, "pp " + pp, 0, pp + TickSize*1, Color.Black);
DrawText("s1l" + sessionCount, "S1 " + s1, 0, s1 + TickSize*1, Color.DarkGreen);
DrawText("s2l" + sessionCount, "S2 " + s2, 0, s2 + TickSize*1, Color.DarkGreen);
DrawText("s3l" + sessionCount, "S3 " + s3, 0, s3 + TickSize*1, Color.DarkGreen);
#endregion
// Entry Logic
Print (ToTime(Time[0]));
if((ToTime(Time[0])) == 80000);
{
if(EMA(fEMA)[0]>EMA(sEMA)[0]) // LONG ENTRYS
{
if(Open[0] > pp && Open[0] < r1)
{
longEntryPP = EnterLongLimit(0,true, 1,pp + entryAllowance * TickSize , "Long Entry PP");
}
else if(Open[0] > r1 && Open[0] < r2)
{
longEntryR1 = EnterLongLimit(0,true, 1,r1 + entryAllowance * TickSize, "Long Entry R1");
}
else if(Open[0] > r2 && Open[0] < r3)
{
longEntryR2 = EnterLongLimit(0,true, 1,r2 + entryAllowance * TickSize, "Long Entry R2");
}
else if(Open[0] > s1 && Open[0] < pp)
{
longEntryS1 = EnterLongLimit(0,true, 1,s1 + entryAllowance * TickSize, "Long Entry S1");
}
else if(Open[0] > s2 && Open[0] < s1)
{
longEntryS2 = EnterLongLimit(0,true, 1,s2 + entryAllowance * TickSize, "Long Entry S2");
}
else if(Open[0] > s3 && Open[0] < s2)
{
longEntryS3 = EnterLongLimit(0,true, 1,s3 + entryAllowance * TickSize, "Long Entry S3");
}
}
if(EMA(fEMA)[0]<EMA(sEMA)[0]) // SHORT ENTRYS
{
if(Open[0] > pp && Open[0] < r1)
{
shortEntryR1 = EnterShortLimit(0,true, 1,r1 - entryAllowance * TickSize, "Short Entry R1");
}
else if(Open[0] > r1 && Open[0] < r2)
{
shortEntryR2 = EnterShortLimit(0,true, 1,r2 - entryAllowance * TickSize, "Short Entry R2");
}
else if(Open[0] > r2 && Open[0] < r3)
{
shortEntryR3 = EnterShortLimit(0,true, 1,r3 - entryAllowance * TickSize, "Short Entry R3");
}
else if(Open[0] > s1 && Open[0] < pp)
{
shortEntryPP = EnterShortLimit(0,true, 1,pp - entryAllowance * TickSize, "Short Entry PP");
}
else if(Open[0] > s2 && Open[0] < s1)
{
shortEntryS1 = EnterShortLimit(0,true, 1,s1 - entryAllowance * TickSize, "Short Entry S1");
}
else if(Open[0] > s3 && Open[0] < s2)
{
shortEntryS2 = EnterShortLimit(0,true, 1,s2 - entryAllowance * TickSize, "Short Entry S2");
}
}
}
}

Comment