Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 sastrades, Today, 09:59 AM
          0 responses
          1 view
          0 likes
          Last Post sastrades  
          Started by ZeroKuhl, Yesterday, 04:31 PM
          5 responses
          36 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by franatas, Today, 01:53 AM
          2 responses
          14 views
          0 likes
          Last Post franatas  
          Started by DawnTreader, 05-08-2024, 05:58 PM
          8 responses
          33 views
          0 likes
          Last Post DawnTreader  
          Started by haas88, 03-21-2024, 02:22 AM
          19 responses
          221 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X