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 Jimmyk, 01-26-2018, 05:19 AM
          6 responses
          835 views
          0 likes
          Last Post emuns
          by emuns
           
          Started by jxs_xrj, 01-12-2020, 09:49 AM
          6 responses
          3,290 views
          1 like
          Last Post jgualdronc  
          Started by Touch-Ups, Today, 10:36 AM
          0 responses
          10 views
          0 likes
          Last Post Touch-Ups  
          Started by geddyisodin, 04-25-2024, 05:20 AM
          11 responses
          62 views
          0 likes
          Last Post halgo_boulder  
          Started by Option Whisperer, Today, 09:55 AM
          0 responses
          8 views
          0 likes
          Last Post Option Whisperer  
          Working...
          X