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 cmoran13, Yesterday, 01:02 PM
        0 responses
        29 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        21 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        160 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        95 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        148 views
        2 likes
        Last Post CaptainJack  
        Working...
        X