Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Weird behavior with order entry

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

    Weird behavior with order entry

    Click image for larger version  Name:	nt-capture.png Views:	6 Size:	561.2 KB ID:	1271977Hi all,
    I'm seeing some very weird behavior (with very simple code) with a strategy giving impossible fills.

    I've tried different timeframes (ticks/minutes/etc)
    It tends to only happen when using CrossAbove or CrossBelow
    Any idea what's going on? It's not even entering on crosses sometimes - not to mention the fill price

    Code:
    ////for brevity - in OnStateChange under State == State.DataLoaded
    ema21 = EMA(Close, 21);
    
    //OnBarUpdate()
    if (CrossAbove(Close, ema21, 1))
    {
    EnterLong(2, "Long");
    }



    Last edited by kvroman; 10-08-2023, 11:52 AM.

    #2
    check the close, is it previous close of candle or current candle like 'close[1]' or close[0].

    Comment


      #3
      I changed it to Close[0] - still compiled but didn't fix the issue

      Comment


        #4
        Figured it out. Thanks for helping, sorry for wasting your time!

        Comment


          #5
          Did you apply the close in multiple parts of the code . Also knowing what you want to achieve in the strategy will help in coding the steps .
          Close[0] > ema(9)[0];
          Last edited by Emma1; 10-08-2023, 02:19 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          43 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          21 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          30 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          50 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          40 views
          0 likes
          Last Post CarlTrading  
          Working...
          X