I want to add an input parameter to control the number of trades per direction. I found some code online that should do this. But, the problem I'm running into is that we know the order is filled by an EnterLong or EnterShort statement so we can increment or decrement the counter. In my code, I'm using EnterLongStopMarket and EnterLongStopLimit orders so we're not in an order until it is filled.
Any suggestions on how to do this? Here's the current sample code:
protected override void OnBarUpdate()
{
//Reset condition
if (CrossBelow(SMA(20), SMA(89), 1))
{
longtrade= 0; //reset long trigger
}
//Enter Trade
if (CrossAbove(CCI(20), 0, 1) && longtrade <= 3)
{
EnterLong(1, "Long 1a");
if (longtrade == 0)
{
longtrade = 1;
}
if (longtrade >0)
{
longtrade = longtrade + 1;
}
}
}
Comment