Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Strategy

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

    Simple Strategy

    I put together a simple strategy to test some thoughts on order handling. To keep things very basic, I' kust using a SMA. When it is going up, I add a long at each bar close. When it turns down, I exit all positions and start adding shorts on each down bar. The problem is occuring on the changes from up to down, or visa versa. The strategy does a sell or "buy to cover", and also does a close position. What happens is I end up with same amount of contracts, heading in the opposite direction, instead of starting at 1 again. Am I missing something here? Thx.

    I have attached a pic of the code and also the orders tab...
    Attached Files

    #2
    Originally posted by BradB View Post
    I put together a simple strategy to test some thoughts on order handling. To keep things very basic, I' kust using a SMA. When it is going up, I add a long at each bar close. When it turns down, I exit all positions and start adding shorts on each down bar. The problem is occuring on the changes from up to down, or visa versa. The strategy does a sell or "buy to cover", and also does a close position. What happens is I end up with same amount of contracts, heading in the opposite direction, instead of starting at 1 again. Am I missing something here? Thx.

    I have attached a pic of the code and also the orders tab...
    Try simply eliminate ExitLong and ExitShort

    When you EnterLong,it will automatically close your short positions and viceversa.

    See how it goes.

    Comment


      #3
      Thanks, that works fine, but what I don't understand is... If the position was closed with the ExitLong or ExitShort, there should be no orders left when the next EnterLong or EnterShort fires.

      Comment


        #4
        Originally posted by BradB View Post
        Thanks, that works fine, but what I don't understand is... If the position was closed with the ExitLong or ExitShort, there should be no orders left when the next EnterLong or EnterShort fires.
        I am not sure exactly how NinjaTrader handles things internally, but what I suspect that since you are exiting and entering on the same tick, NT simply does not have enough time to report that position is flat before you EnterLong or EnterShort

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X