Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Executing too many entries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Executing too many entries

    Hi, it seems my strategy is ignoring the market position line in Sim & Replay (not tested Live yet) and is triggering another entry when the CrossBelow event occurs while already short 1 position. Is there something I'm missing here?

    Code:
    protected override void Initialize()
            {
                Add(anaCurrentDayVWAPV36(anaBandTypeVWAPD36.Variance_Distance, anaSessionTypeVWAPD36.ETH, 1, 2, 3, 
                    anaSessionCountVWAPD36.First));
                Add(EMA(20));
    
                CalculateOnBarClose = true;
            }
     protected override void OnBarUpdate()
            {
    
                if (Position.MarketPosition == MarketPosition.Flat
                    && CrossBelow(EMA(20), anaCurrentDayVWAPV36(anaBandTypeVWAPD36.Variance_Distance, 
                    anaSessionTypeVWAPD36.ETH, 1, 2, 3, anaSessionCountVWAPD36.First).SessionVWAP, 1)
                    && ToTime(Time[0]) > ToTime(15, 00, 0)
                    && ToTime(Time[0]) < ToTime(23, 59, 0))
                    {
                    atmStrategyId = GetAtmStrategyUniqueId();
                    orderId = GetAtmStrategyUniqueId();
                    AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, Low[0], 0, TimeInForce.Day, orderId, "VWAPcross", atmStrategyId);
                    }[INDENT]}[/INDENT]
    Backtesting using a standard entry and profit target/stop loss instead of the ATM strategy works fine. Also, EntriesPerDirection is set to 1. Could it be something to do with CrossBelow or the custom VWAP indicator? Thanks

    #2
    Hello,

    Can you please clarify that you are able to use this AtmStrategyCreate() method when backtesting?

    The Atm Strategy methods would not be accessible during backtesting. If you were to run this strategy as is in the strategy analyzer, you would not see the ATM strategy trigger.
    MatthewNinjaTrader Product Management

    Comment


      #3
      No, as stated in the first post, backtesting using a standard entry and profit target/stop loss instead of the ATM strategy works fine. The issue occurs when the strategy is run in Sim/Replay with the ATM code inserted (as shown). Thanks

      Comment


        #4
        Sorry, can you please clarify if it runs without issues using the standard entry and profit target/stop loss in Sim and Replay? Or is the issue only one using the ATMStrategyCreate and in Sim?

        If you're using the ATM strategy, you should be using GetAtmStrategyMarketPosition() to check this position:



        If you see the same behavior, I would suggest running some Print() statements to check your market position under these environments to ensure your position is reported as flat/long/short around this time.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Ahh GetAtmStrategyMarketPosition() solves the problem; thanks for your help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          646 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          367 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          569 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X