When I use the condition BarsSinceEntry() no orders will submit. Without it, the strategy works fine but I like to avoid submit orders when there was already an order filled within 3 bars ago. I wonder what I do wrong or how I can achieve this (in maybe another way)?
Thank you in advance.
Here below is my condition:
{
// Condition set 2
if (BarsSinceEntry() > 3
&& orderId.Length == 0
&& atmStrategyId.Length == 0
&& CrossBelow(Stochastics(PeriodD, PeriodK, Smooth).K, Stochastics(PeriodD, PeriodK, Smooth).D, 1)
&& Stochastics(PeriodD, PeriodK, Smooth).K[0] <= 25
&& ADX(ADXperiode)[0] <= ADXlevel)
{
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, 0, 0, TimeInForce.Day, orderId, "Rood", atmStrategyId);
}
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status[0]);
Print("The entry order filled amount is: " + status[1]);
Print("The entry order order state is: " + status[2]);
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId = string.Empty;
}

Comment