I have created a strategy that has a condition to go long or go short based on simple criteria and the long/short criteria are the inverse of each other. It is based on an SMA crossover strategy. I am using an EnterLong() and EnterShort() order for each condition and I have declared a SetStopLoss and SetProfitTarget value declared for each condition.
If I am in a long position, I want to ensure that the position will not close until the target or stop value is reached, even if a short signal appears. In addition, if there is a short signal and I am currently in a long position, I also do not want NT to place another order to go short until the long has reached the target or stop (meaning I only want 1 futures contact to be bought a one time).
Based on the current code (below), it seems that if I am in a long position and a short signal appears, it will close my position out and reverse. I am trying to figure out what rule I am missing to prevent the long form being closed or an additional order from being placed.
Thanks for any information you can provide,
-Dave
protected override void Initialize()
{
EntriesPerDirection = 1;
EntryHandling = EntryHandling.UniqueEntries;
CalculateOnBarClose = false;
}
protected override void OnBarUpdate()
{
if (long criteria)
{
EnterLong(1, "long");
SetStopLoss(CalculationMode. ...);
SetProfitTarget(CalculationMode ...);
}
// Condition set 2
if (short criteria)
{
EnterShort(DefaultQuantity, "Short");
SetStopLoss(CalculationMode ...);
SetProfitTarget(CalculationMode ...);
}
Comment