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 pibrew, Today, 06:37 AM
          0 responses
          1 view
          0 likes
          Last Post pibrew
          by pibrew
           
          Started by rbeckmann05, Yesterday, 06:48 PM
          1 response
          14 views
          0 likes
          Last Post bltdavid  
          Started by llanqui, Today, 03:53 AM
          0 responses
          6 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          11 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          15 views
          0 likes
          Last Post AaronKoRn  
          Working...
          X