Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automated Strategy?

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

    Automated Strategy?

    I have built an automated strategy with the strategy wizard and would like to know how to add a breakeven once its so many ticks in profit it will move stoploss to breakeven plus 1 tick?

    #2
    Hello kinkeadfx,

    To have a breakeven movement you will need to use exit orders instead of SetStopLoss() or SetTrailStop().

    Then you will need to use custom logic to control when the order is moved.

    Attached is an example I have created for other clients. This is just to give you an idea of how to make this kind of logic for the Strategy Wizard. (I also have custom code made in unlocked strategies if you would like this as well)
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I would like to have your custom unlocked code as well.
      Thank you!

      Comment


        #4
        Hi kinkeadfx,

        Attached is the unlocked code.

        This demonstrates using OnBarUpdate and OnMarketData to move a stop loss (which can be done in an unlocked strategy).

        You don't have to use OnBarUpdate or OnMarketData, this gives a general idea of how to manipulate the stop loss.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          This might be a dumb question but can you use multiple strategies on the same chart?
          Would they work together or coexist?
          Such as a strategy for entry signals and another for exit signals?

          Comment


            #6
            Hi kinkeadfx,

            Yes, you can add multiple strategies and indicators to a chart.

            The strategies and indicators will work independently, but if they are working on the same account and same instrument, they will both be submitting orders that will affect the account position while keeping their own independent strategy position.

            I would not recommend running two strategies on the same instrument on the same account. They will not be able to see orders that are made from outside of that strategy instance.

            Below is a link that describes the strategy position and the account position.
            https://www.youtube.com/watch?v=US9c...A14C398CA140D7
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              So basically i could copy and paste the code from the breakevenwizardexample and add it to my already existing strategy within the wizard in order to add a breakeven to my strategy?

              Comment


                #8
                Hi kinkeadfx,

                I would look to understand how this is working and then try and use the same kind of logic on your script.

                Here is the low down on how this works:

                Condition set 1 checks that the position is flat
                If true:

                Variable0 is set to the trigger price

                Variable1 is the to initial stop price

                Variable2 is set to correct the trigger price one bar after entry

                Variable3 is set to 0 to reset the trigger so that the breakeven only happens once


                Condition set 2 checks that the position is long and Variable2 is 0.
                If true:

                Variable0 is corrected to the entry price plus the trigger amount


                Condition set 3 checks that the position is long, that the close price has met the trigger price, and that Variable2 is set to 0 and ready to trigger.
                Once these are true:

                Variable1 is set to the Position.AvgPrice which is the entry point

                Variable3 is set to 1 so the breakeven is not triggered again

                DrawDiamond is called to mark the chart where the breakeven was triggered


                Condition set 4 checks that we are in a long position
                If true:

                ExitLongStop is called to set the stop to the current value of Variable1 which is set in condition set 1 and then condition set 2
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks very much, Chelsea, for explaining this so clearly.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by michi08, 10-05-2018, 09:31 AM
                  3 responses
                  740 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by sightcareclickhere, Today, 01:55 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post sightcareclickhere  
                  Started by Mindset, 05-06-2023, 09:03 PM
                  9 responses
                  258 views
                  0 likes
                  Last Post ender_wiggum  
                  Started by Mizzouman1, Today, 07:35 AM
                  4 responses
                  18 views
                  0 likes
                  Last Post Mizzouman1  
                  Started by philmg, Today, 01:17 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_ChristopherJ  
                  Working...
                  X