简体   繁体   中英

Ninja trader C# code not work for loop skips

I'm coding a trading strategy in NinjaTrader with C#.I'm new to C#.

It seems something wrong with my code:

private bool _enterLong;
private bool _enterShort;

private void SetEntrySignal()
{

   if (Slope(EMA(20), 5, 0) > -0.01 && Slope(EMA(20), 5, 0) < 0.01)
   {
      _enterLong = Close[0] > Open[0];
      _enterLong &= Open[0] > High[1];
   }
   _enterShort = Close[0] < Open[0];
   _enterShort &= Open[0] < Low[1];
}

Because the _enterLong signal hasn't been triggered,only short(sell) signal has been triggered.So Is any syntax wrong with this part C# code?

I am only guessing here.

private bool _enterLong;
private bool _enterShort;

private void SetEntrySignal()
{

   if (Slope(EMA(20), 5, 0) > -0.01 && Slope(EMA(20), 5, 0) < 0.01)
   {
      _enterLong = Close[0] > Open[0];
      _enterLong &= Open[0] > High[1];
   }
   else
   {
      _enterShort = Close[0] < Open[0];
      _enterShort &= Open[0] < Low[1];
    }
}

Note if this is not your question, or makes no sense, i will delete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM