Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

stop and loss without an order

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

    stop and loss without an order

    Dear all,

    First post so please be gentle with me!

    I have created a simple strategy (chopped-down snippet attached) which goes long when one MA crosses above another MA, and goes short when a third MA crosses below a fourth MA. I understand there is no need to cancel any previous short or long position as the EnterLong or EnterShort will do this automatically.

    I am plotting all the MAs and setting CalculateOnBarClose to true in the Initialize method.

    I was setting stop and limit in the initialize method as per the example, but this always resulted in a stop and limit being set before the actual trade was made.

    Immediately upon starting the strategy, it assumes it has a position, and sets stop and limit orders, but does not make the actual trade. The average price for the position is the price when the strategy is started. This was the same effect I got when setting stop and limit in the Initialize method.

    If I manually cancel the stop and limit orders from the chart trader, the strategy seems to be running ok.
    Attached Files

    #2
    Originally posted by ninjohn View Post
    ... Immediately upon starting the strategy, it assumes it has a position, and sets stop and limit orders, but does not make the actual trade. The average price for the position is the price when the strategy is started. This was the same effect I got when setting stop and limit in the Initialize method.

    If I manually cancel the stop and limit orders from the chart trader, the strategy seems to be running ok. ...
    Hopefully you'll also get some more authoritative responses than just mine, but I think you can get some insight into what's happeneing here ...



    Search for the page on "Strategy Position Vs Account Position", and then note section where it says:

    An extremely common scenario…


    An extremely common scenario is starting a NinjaScript strategy in the middle of a trading session, such as one hour after the session has begun.. The NinjaScript strategy is run on each historical bar for the 1st hour of the session (it will actually run on all historical data loaded in a chart) to determine the current position state it would be in if it had been running live since the start of the session. This position state then becomes the Strategy Position for your strategy. Let us assume that during the historical hour your strategy would have entered a LONG 1 position and the position is still open. This would mean the Strategy Position is LONG 1 and since this trade was not actually executed on an account your Account Position is FLAT.


    What can you do in this case?


    If you want your Account Position to match your Strategy Position, you will need to place a manual order into the account the strategy is running on. Continuing from the above example, you would need to place a 1-lot market order for the market being traded into the account the strategy is running on.

    I am guessing that you are running in your SIM account, and starting up midway during the trading session ... ?
    Last edited by AnotherTrader; 03-12-2010, 03:29 AM.

    Comment


      #3
      AnotherTrader, thanks stepping in to help here - this is precisely the issue, when running the strategies in 'immediately submit' mode it will submit the historically working orders as soon as you start the strategy up (since there's a position carrying over from historical data). Thus the manual sync is required so the following executions align in your associated account as well -



      NinjaTrader 7 will provide an auto Sync option to handle this 'under the hood' for you -



      As an alternative you could start the strategy in 'Wait Until Flat' mode essentially taking the first live generated entry signal then and ignoring the historically carried over one...

      BertrandNinjaTrader Customer Service

      Comment


        #4
        Thanks for the prompt response guys, I will make the necessary changes!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by pechtri, 06-22-2023, 02:31 AM
        10 responses
        124 views
        0 likes
        Last Post Leeroy_Jenkins  
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Yesterday, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Yesterday, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Yesterday, 03:01 PM
        2 responses
        22 views
        0 likes
        Last Post helpwanted  
        Working...
        X