Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Stop Loss with Multi-Time Frames

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

    Setting Stop Loss with Multi-Time Frames

    In help: SetStopLoss (Navigation: NinjaScript > Language Reference > Strategy > Order Methods > Managed Approach >) the advice is "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."

    I have this condition: Calculating on Ticks. Four time frames all on the same instrument. The instrument is taken from the chart as the Primary Bars Object, (BarsArray[0]). Say this is 100 ticks.

    I have a secondary BarsArray[1] which is 20 ticks and another BarsArray[2] which is 500 ticks. I have order decision logic operating to time the order placement based partly on the 20 Tick Time Frame.

    What does that statement imply in my situation?
    • Does it mean that I have to place orders only when BarsInProgress == 0 (primary)
    • or when BarsInProgress == 1
    • or does it matter.
    Thank you.

    #2
    Hello JGRtrader,

    Thank you for your post.

    If you are using SetStopLoss() yes, you should be placing orders to the primary data series (when BarsInProgress == 0). This ensures the order is correctly processed and any amendments get made correctly.

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Am I understanding this correctly, then, that ALL orders must be placed when BarsInProgress is Primary? If so then does placing orders on Primary, delay their execution rather than going in when I want them too according to the faster time frame?
      Last edited by JGRtrader; 12-30-2021, 11:20 AM. Reason: Edited to add clarity to what my concerns are.

      Comment


        #4
        Hello JGRtrader,

        Thank you for your reply.

        It would not delay their execution, they will be submitted as soon as the entry order fills.

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Kate,

          Thank you for the clarification. I still have one question, do I have to place ALL orders in the primary time frame or just the Stop orders and changes?

          Jim

          Comment


            #6
            Hello JGRtrader,

            Thank you for your reply.

            If you are using SetStopLoss you should be submitting your entry orders to the primary series, yes.

            Please let us know if we may be of further assistance to you.

            Comment


              #7
              Kate, One more question about these stops.

              For the setup described initially in this dialog, if I put default Stop order in State.Dataloaded, can I still change them dynamically in runtime with the orders?

              With multiple time frames do stop order set in DataLoaded need to be specifically entered against the Primary Time Frame or is that the only one active at that time.

              Comment


                #8
                Hello JGRtrader,

                Thank you for your note.

                Apologies for the delay in my reply, I came in to a number of tickets this morning after the holiday weekend and have been working my way through them. You can set up the initial stop order in State.Configure, and then update that stop by calling SetStopLoss again in OnBarUpdate, yes. I'd recommend taking a look at this example script that illustrates modifying a stop that is initially set in State.Configure and modifying that stop to break even in OnBarUpdate:



                There would not be a way to specify which time frame the stop is placed on, as it will automatically be submitted to the primary data series time frame, however, if you have a particular data series specified in a condition, you could trigger changing the stop based on which data series is currently updating in OnBarUpdate. This would not affect which series the order is placed to, however.

                Please let us know if we may be of further assistance to you.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                60 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                134 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                75 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                45 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                50 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X