A great example is of the ES 06-12 on 5/23/2012. Using a 2min chart as primary.
Here's some entry code:
// Variables
private int sma1 = 50;
private int sma2 = 200;
private int ordQ = 1; // Quantity per Order
private int pTot = 100000; // Total Positions Allowed - Allowing 100000 just to let it show all the bad entries it will make
private DataSeries swingLow;
private BoolSeries loTrade1;
private BoolSeries loTrade2;
private DataSeries loBar;
private double trendIndy = 0; // Immediate trend
private int pCount = 0; // Position count - orders already placed
protected override void Initialize()
{
swingLow = new DataSeries(this, MaximumBarsLookBack.Infinite);
loTrade1 = new BoolSeries(this, MaximumBarsLookBack.Infinite);
loTrade2 = new BoolSeries(this, MaximumBarsLookBack.Infinite);
loBar = new DataSeries(this, MaximumBarsLookBack.Infinite);
CalculateOnBarClose = false;
EntriesPerDirection = pTot;
EntryHandling = EntryHandling.AllEntries;
ExitOnClose = false;
}
protected override void OnBarUpdate()
{
if (CurrentBars[0] < sma2)
return;
if (BarsInProgress == 0)
{
trendIndy = SMA(sma1)[0] - SMA(sma2)[0];
// Determine swing low points
if (Low[2] >= Low[1] &&
Low[1] < Low[0])
{
swingLow.Set(Low[1]);
loTrade1.Set(true);
loBar.Set(CurrentBar);
// Indicate on the chart where the value came from
DrawTriangleUp("ua" + CurrentBar, false, 1, swingLow[0] - 2 * TickSize, Color.Green);
}
}
if (BarsInProgress == 1)
{
for (int i = 0; i < swingLow.Count; i++)
{
#region LONG ENTRIES
// When price hits a swingLow value...
if (loTrade1[i] == true &&
CrossBelow(DefaultInput, swingLow[i], 1)) // MIGHT NEED TO BE DEFAULTINPUT[0] OR INPUT OR INPUT[0]???
{
// LONG ENTRY
if (Position.MarketPosition != MarketPosition.Short &&
pCount < pTot &&
((trendIndy > 0 && (SMA(BarsArray[0], sma1)[0] < swingLow[i] || SMA(BarsArray[0], sma2)[0] > swingLow[i])) ||
(trendIndy < 0 && (SMA(BarsArray[0], sma1)[0] < swingLow[i] && SMA(BarsArray[0], sma2)[0] > swingLow[i]))))
{
// Enter Long... if meets criteria
EnterLong(ordQ, "long" + loBar[i]);
pCount = pCount + 1;
loTrade1[i] = false;
loTrade2[i] = true;
Print(Times[0][0].ToString() + " LONG ENTER" + pCount + " i " + i + " CurrentBar" + CurrentBar + " fromCurrentBar" + (CurrentBar-i) + " swingLow" + swingLow[i] + " loTrade1" + loTrade1[i] + " loTrade2" + loTrade2[i]);
}
else
{
loTrade1[i] = false;
loTrade2[i] = false;
// Print(Times[0][0].ToString() + " LONG HIT" + " i " + i + pCount + " CurrentBar" + CurrentBar + " fromCurrentBar" + (CurrentBar-i) + " swingLow" + swingLow[i] + " loTrade1" + loTrade1[i] + " loTrade2" + loTrade2[i]);
}
}
#endregion
}
}
What do you think? And I suppose... if anything else looks horribly wrong and bothers you guys, wouldn't mind any additional suggestions!
Thanks in advance for any help you can offer!!!

Comment