if (Historical) return;
if (Position.MarketPosition == MarketPosition.Flat)
{
//Greg> Trade Counter resets value every new bars
if(FirstTickOfBar)
{
x = 0;
}
//Greg> Trade Counter checks for your entry condition and that the value is less than your trade count
if (CrossAbove(SMA(Fast), SMA(Slow), 1) && x <= myTradeCounter //will count from zero to myTradeCounter, probably one more than intended?
&& Close[0] >= SessionPivots(true, PivotRange.Daily, PivotType.All, HLCCalculationMode.CalcFromIntradayData, ProfileType.TPO, 0, 0, 0).L3[0])
{
//Greg> Trade Counter attempts to enter long
EnterLong(DefaultQuantity, "BuyMkt");
//Greg> Trade Counter increments the trade count by 1
x++;
}
//Greg> Trade Counter resets value every new bars
if(FirstTickOfBar)
{
x = 0; //resets the counter, negating the increment if any. You probably want separate counters for short and long.
}
//Greg> Trade Counter checks for your entry condition and that the value is less than your trade count
else if (CrossBelow(SMA(Fast), SMA(Slow), 1) && x <= myTradeCounter //Bearish trade conditions; replace with your own
&& Close[0] <= SessionPivots(true, PivotRange.Daily, PivotType.All, HLCCalculationMode.CalcFromIntradayData, ProfileType.TPO, 0, 0, 0).H3[0])
{
//Greg> Trade Counter attempts to enter long
EnterShort(DefaultQuantity, "SellMkt");
//Greg> Trade Counter increments the trade count by 1
x++;
}
}


Comment