• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 seagraph, Today, 03:27 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post seagraph  
                  Started by dedouglas, Today, 02:54 PM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by elkhatabi, 08-01-2019, 06:36 PM
                  5 responses
                  52 views
                  0 likes
                  Last Post NinjaTrader_RyanL  
                  Started by mr_trade, Today, 01:01 PM
                  4 responses
                  19 views
                  0 likes
                  Last Post mr_trade  
                  Started by Renorail, Today, 12:31 PM
                  1 response
                  13 views
                  0 likes
                  Last Post NinjaTrader_PaulH  
                  Working...
                  X