Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Darvas Box

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

    Darvas Box

    Hi,

    I would like to create an condition to enter trade position using the Darvas indicator.

    1) I would like to tract the previous candle low to be same as the low or Darvas Box - then enter long trade.

    2) I would like to tract the previous candle high to be same as the high or Darvas Box - then enter short trade.

    Can this be done?
    Attached Files

    #2
    Hello neshnix89,

    Thanks for your post.

    Yes, you could create conditions in a strategy that checks if the previous High/Low price is equal to the upper or lower plot of the Darvas indicator and call an Entry order method to place an order.

    The Strategy Builder (New > Strategy Builder) could be used to set up your conditions and actions to accomplish this.

    See the attached example that demonstrates how to create a condition that checks if the previous Low price is equal to the lower plot of the Darvas indicator and calls EnterLong() to place an order.

    Also, see the help guide documentation linked below for more information.
    Conditions: https://ninjatrader.com/support/help...on_builder.htm
    Actions: https://ninjatrader.com/support/help...t8/actions.htm

    Let us know if we may assist further.
    Attached Files
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Dear BrandonH,

      Appreciate the help. I have few more question.

      1) If currently we have on going order, and the condition for newer order on the opposite side came, how do we close the current order and open the new order?
      2) How do I set my stop loss to be the high or low of the trigger candle and the take profit to be the 1 to 1 with my stop loss.

      Comment


        #4
        Hello neshnix89,

        Thanks for your note.

        1. As stated in the Managed Approach help guide page: Entry() methods will reverse the position automatically. For example if you are in a 1 contract long position and now call EnterShort() -> you will see 2 executions, one to close the prior long position and the other to get you into the desired 1 contract short position.

        2. A stop loss or profit target could be created in the Stops and Targets screen of the Strategy Builder. You would assign the value to the stop loss to be the High/Low price of the candle that was used for your comparison. For example, if you are using the previous bar High price (High[1]), then you would set the stop loss to be the High price with a 'Bars ago' value of 1.

        See the help guide documentation below for more information.

        Managed Approach: https://ninjatrader.com/support/help...d_approach.htm
        Stops and Targets Screen: https://ninjatrader.com/support/help...dTargetsScreen

        Here is a link to our publicly available training videos, 'Strategy Builder 301' and 'NinjaScript Editor 401', which you may find helpful.

        Strategy Builder 301 — https://www.youtube.com/watch?v=_KQF2Sv27oE&t=13s
        NinjaScript Editor 401 - https://youtu.be/H7aDpWoWUQs?list=PL...We0Nf&index=14

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Dear BrandonH,

          How do I set take profit to be the 1 to 1 with my stop loss? I do not see this in the training material. Appreciate the help.

          Comment


            #6
            Hello nishnix89,

            Thanks for your note.

            By "set take profit to be 1 to 1 with my stop loss", do you mean that you would like the profit target and stop loss to be an equal distance from the entry order?

            If so, then you would need to assign a value to your stop loss that is an equal distance from the entry as the value set for your profit target.

            For example, if you create a profit target in the Stops and Targets screen and that profit target is set to a value of 10 Ticks from the entry order, you would also need to set the value of the stop loss to be 10 Ticks from the entry order.

            Let us know if we may assist further.

            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Dear Brandon H,

              Attached in picture are my stop lost target. Its not fixed for every trade. I would like the profit target to be the same as stop loss ticks value. For example if my SL is 10 ticks below the entry, i want my TP to be 10 ticks above my entry and this changes from one order to another.
              Attached Files

              Comment


                #8
                Hello neshnix89,

                Thanks for your note.

                If you are assigning your profit target to be placed at the High price of the previous candle, you would need to create custom logic in your script that calculates how far the previous candle High price is from the entry price, assign that value to a variable, and use that variable for your stop loss.

                Unfortunately, a limitation of the Strategy Builder is that only simple math could be used for offsets when it comes to calculations. You would need to unlock your script from the Strategy Builder and manually code this logic into your strategy.

                Since you are using the Strategy Builder to create your strategy, something you could consider if you want the profit target and stop loss to be '1 to 1' is setting your profit target and stop loss to the same Tick value from the entry price. For example, assign a value of 10 Ticks to the profit target and to the stop loss so that both orders are placed 10 Ticks from the entry order.

                Let us know if we may assist further.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  I also wanted to create a strategy for this but find trouble referencing when to buy/sell given the strategy builder parameters. I took the zip file from (post #2) above and tried to make changes from that with no success. I want the strategy to place a trade if the price were to close outside of the bands. For example, enter a long position if price closed below the lower red line, then close the position once price closes back above the red line. Click image for larger version  Name:	Screen Shot 2022-10-15 at 7.22.50 PM.png Views:	0 Size:	122.7 KB ID:	1219643
                  Last edited by chasep7328; 10-15-2022, 05:31 PM.

                  Comment


                    #10
                    Hello chasep7328,

                    Thanks for your note.

                    Is the lower red line from an indicator plot?

                    If so, you could create a condition that checks if the Close price is less than the red plot of that indicator and call an action of EnterLong(). You could create another condition that checks if the Close price is greater than the red plot of that indicator and call your ExitLong() action to exit the position.

                    See this help guide page for more information about using the Strategy Builder.
                    Conditions: https://ninjatrader.com/support/help...on_builder.htm
                    Actions: https://ninjatrader.com/support/help...t8/actions.htm

                    Let me know if I may assist further.
                    Brandon H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Segwin, 05-07-2018, 02:15 PM
                    14 responses
                    1,789 views
                    0 likes
                    Last Post aligator  
                    Started by Jimmyk, 01-26-2018, 05:19 AM
                    6 responses
                    837 views
                    0 likes
                    Last Post emuns
                    by emuns
                     
                    Started by jxs_xrj, 01-12-2020, 09:49 AM
                    6 responses
                    3,293 views
                    1 like
                    Last Post jgualdronc  
                    Started by Touch-Ups, Today, 10:36 AM
                    0 responses
                    13 views
                    0 likes
                    Last Post Touch-Ups  
                    Started by geddyisodin, 04-25-2024, 05:20 AM
                    11 responses
                    63 views
                    0 likes
                    Last Post halgo_boulder  
                    Working...
                    X