Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss with Multiple Bars Objects

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

    SetStopLoss with Multiple Bars Objects

    Hello,

    I was reading the following in the help guide:
    "Should you have multiple Bars objects of the same instrument while using SetStopLoss() in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly"

    I have a strategy that has multiple Bars Objects of the same instrument. One is shorter term bars (eg. 2550 Tick Bars) and longer term bars (eg. 10000 Tick Bars). I open and manage trades from both Bars Objects.

    In the above scenario, If I enter an order on BarsInProgress = 1 and have to wait till the next OnBarsUpdate event associated with BarsInProgress = 0 to place my SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool isSimulatedStop) calls, then doesn't this mean that I will not have a Stop Loss order active until the next OnBarUpdate() for BarsInProgress = 0?

    Or if I place all Entry Orders only on the first Bars Object (i.e. BarsInProgress = 0) so that I can place my SetStopLoss() and my entry logic is say a second Leg (multiple entries on same position) then I still have to wait for next OnBarUpdate() for BarsInProgress = 0;

    Also, if the two Bars Objects were multiples of the other (meaning 2000 Ticks and 10000 Ticks) there would still be two seperate calls to OnBarUpdate() and my strategy would be waiting till the next OnBarUpdate() associated with BarsInProgress=0. And therefore, which event is called first? The event associated with 10000 Ticks or 2000 Ticks? Assuming that the Tick count would start on same Tick meaning that if OnBarsUpdate() fires for the 10000 Tick bars would the OnBarsUpdate() for the 2000 Tick bars fire immediately after?

    Confusion has set in. Please help best understand how to use SetStopLoss() with multiple Bars objects.

    Thanks,
    Last edited by tornadoatc; 08-17-2016, 06:17 AM.

    #2
    Hello tornadoatc,

    Thank you for your post.

    First I would like to clarify the reason that the recommendation is to use the primary series in a multiple series script when you use the Set methods (SetStopLoss, SetTrailStop, and SetProfitTarget). This recommendation is made as the Set methods only calculate historically on the primary bar series and there is no option to submit them to the secondary series or any other than the primary bar series.

    If your entry order is on the BarsInProgress == 1, then you must understand that the Set methods would not be active nor executed until the primary series bar is calling OnBarUpdate(). So you are correct, the Set method would not be present until the primary bar series has a close after the secondary bar series. And this is the same case for your second example for the second leg of an entry, but this also applies to all bar series in backtesting and historical calculations.

    When historical data processes the primary series is generally the first called when multiple series update at the same time. There is no guarantee of this and you should make sure your strategy does not rely on the primary series to update first in all cases,

    Please let me know if you have any questions.

    Comment


      #3
      Hello Patrick,

      So if I do not use the SetStopLoss() and SetTrailingStop() would you suggest the next option for strategies with Muti Instruments / timeframes to use the Manage Order types of

      1) ExitLongStopMarket(intbarsInProgressIndex, boolisLiveUntilCancelled, intquantity, doublestopPrice, stringsignalName, stringfromEntrySignal)

      2) ExitShortStopMarket(intbarsInProgressIndex, boolisLiveUntilCancelled, intquantity, doublestopPrice, stringsignalName, stringfromEntrySignal)

      When using these Managed Orders will they automatically get updated as needed in Partial Fill scenarios? Or would I need to monitor execution in OnExecutionUpdate() and call these methods again with the partial fill quantities?

      Thanks,
      Last edited by tornadoatc; 08-17-2016, 03:23 PM.

      Comment


        #4
        Hello tornadoatc,

        Thank you for your response.

        The Exit methods will only close the quantity they have and not enter you in the opposite direction if they had to sell 4 when you were long only 2 for example. However, I would still update the orders in OnExecution() when you see the partial fills if you are using specific quantities in your orders in code.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by FrazMann, Today, 11:21 AM
        0 responses
        3 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        10 responses
        36 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        24 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        19 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X