I have created 2 strategies (let's call them Strategy A and B) in NT 8 and both of them go long or short based on certain criterias. It doesn't matter which one goes long/short first A or B, the system does not not go long/short on the other strategy even though all the criterias are met.
Each long/shirt entry has it's own unique signal name. The strategy dialog box for both A and B have Entry Handling = "Unique entries" and Entry per direction = 1. The start behavior is set to "Immediately submit, synchronize account" for both A and B.
Based on the above setup, even though the criteria are met for both, I can only get one of them to fire long or short but not both. Note: Per the criteria A and/or B can only go long or short. They cannot have a scenario where one goes long and the other short.
Can someone let me know if there is another setting that needs to be set either in code or on the strategy window to get both of them to fire off, with their own proft target and stop loss?
I have provided a snippet of the code below. The code will be the same for A and B with the exception of the time, long and short entry values. These values are setup in the strategy window.
public class StrategyA : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"StrategyA";
Name = "StrategyA";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling =EntryHandling.UniqueEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 1;
LongMaxEntry = 1;
LongMinEntry = 1;
ProfitTargetPrice = 1;
StopLossTicks = 1;
ShortMaxEntry = 1;
ShortMinEntry = 1;
LongEnabled = false;
ShortEnabled = false;
DefaultQuantity = 1;
}
else if (State == State.Configure)
{
SetProfitTarget("StrategyA", CalculationMode.Price, ProfitTargetPrice);
SetStopLoss("StrategyA", CalculationMode.Ticks, StopLossTicks, false);
}
}
protected override void OnBarUpdate()
{
//Print("Order Name " Order.Name + " " + Time[0]);
// Condition set 1
if (ToTime(Time[0]) >= ToTime(startMHours, startMinutes, startSeconds)
&& GetCurrentBid() > LongMaxEntry
&& GetCurrentBid() < LongMinEntry
&& true == LongEnabled)
{
EnterLong(DefaultQuantity, "StrategyA");
}
// Condition set 2
if (ToTime(Time[0]) >= ToTime(startMHours, startMinutes, startSeconds)
&& GetCurrentAsk() < ShortMaxEntry
&& GetCurrentAsk() > ShortMinEntry
&& true == ShortEnabled)
{
Print("Enter Short");
EnterShort(DefaultQuantity, "StrategyA");
}
}
Comment