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

Enter only if the delta of high and open is less than the Stop loss

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

    Enter only if the delta of high and open is less than the Stop loss

    I want to enter a trade only if the prior bar delta of high and close is less than my stop loss. I thought I could set a variable as I did not see a delta function in the price section of conditions. I thought maybe I should set variables but I cant seem to figure out a way to get to my goal.

    This seems like it should be a basic question but I may not be searching for it correctly as I cant seem to find an answer.

    Any help is appreciated.

    #2
    Hi Holligoly,
    I assume, this question is for the StrategyBuilder, not NinjaScript. The StrategyBuilder is somewhat limited in terms of math calculations, but what you have in mind is still possible, even without Custom Series. A variable (double) is enough here because, you only use OHLC which is anyway available. I created a short video just for the High[1] - Close[1] calculation.

    Have fun.
    NT-Roland

    Comment


      #3
      Hello Holligoly,

      I'd like to clarify what you are trying to achieve.

      What do you mean by bar delta? Do you mean the high minus the close (High[0] - Close[0])?

      How are you trying to compare this to a stop price? For example if the high at 4210.25 minus the close 4209.75 is .5, this would be far below the stop price.

      NT-Roland is correct, in that the only math available in the Strategy Builder is with the Offset on Series objects.

      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thank you so much Roland and Chelsea. Sorry I was in a bit of hiatus there and didn't reply sooner. Both of you nailed what i was trying to do. I am basically trying to enter only if the wick of the prior bar is smaller than my stop loss. Which I think means high minus the close (High[0] - Close[0]).

        Roland... I followed your way and I have the variable set. Thank you so much for that!. Now, is there a way to create 'DeltaHighClose' before we get to the Conditions and actions page? I want to use 'DeltaHighClose' in the conditions section..i.e my condition statement would be "if 'DeltaHighClose' < 21 pips, then sell short." I am new to Strategy builder so may be missing something.

        Thank you so much for all the help!
        Last edited by Holligoly; 06-12-2021, 06:37 PM.

        Comment


          #5
          Hello Holligoly,

          Are you wanting to subtract the difference between the high and close from the high?

          So if the High[0] - Close[0] is .5, and High[0] is 100 then, High[0] - (High[0] - Close[0]) would be 99.5.

          To create the DeltaHighClose variable select the Inputs and Variables page. In the Variables area click add, select Double as the type, type DeltaHighClose in the Name, click OK.

          The variable will appear at the bottom of the Condition Builder.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thanks Chelsea. I actually want strategy builder to enter on the next bar if the difference between the high and the close of the bar is less than my stop loss.

            Click image for larger version  Name:	Entry and no entry.png Views:	0 Size:	43.9 KB ID:	1160468
            This is what I want to do.

            So if I am following the conversation correctly, I will first have to calculate the length of the wick and then compare it to my stoploss and then take the trade. So I create a double and compare it to my stoploss and then in conditions specify that if the wick is shorter take the trade. Same applies for shorts.

            Thank you!
            Last edited by Holligoly; 06-17-2021, 08:20 PM.

            Comment


              #7
              Hello Holligoly,

              Thanks for your reply.

              The screenshots are always a help to clarify things.

              So in your first screenshot you have identified that you want to know the length of the wick of a down bar. A down bar is identified as Close < Open. The wick on the bottom of a down bar would be calculated as Close - Low.

              The first part of the condition would need to be Close[1] < Open[1] and Close[0] > Open[0] so it takes the two bars for the first part of the condition and any order placed would only be placed on the next bar. When you show "enter long here" do you mean at the low of that bar or do you mean just at that bar?

              I am confused and it is not clear exactly what you mean by "length of the wick and then compare it to my stoploss". Calculating the wick is no issue as previously shown in other posts but what is not known is how does that price difference relate to your stop loss? Are you setting the number of ticks for your stopLoss?
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Yes. I am going by the # of ticks. So I guess I have to keep a running count of the ticks in the wick after each bar closes and since I am skipping a candle to enter, my running total will be over written?

                Second... even if I know the # of ticks in the wick, how do I access that information before the conditions page? I need that info before I get to the conditions page. how do I set it up to do that? Thats my question.

                Also "enter long here" means close of the down bar. So price will have to retrace to that for the trade to happen.
                Last edited by Holligoly; 06-19-2021, 07:54 PM.

                Comment


                  #9
                  Hello Holligoly,

                  I wanted to further clarify.

                  " if the difference between the high and the close of the bar is less than my stop loss"

                  If the High is 100, and the Close is 99, then the difference is 1.

                  1 would be all the way at the bottom of the price scale. I would expect your stop to be much closer to the trading action and not at 1, or the difference between the high and the low.
                  Is your stop at a price of 1.00 at the bottom of the price scale?

                  Previously I had suggested that you want to subtract this from the current close, however I feel you were saying that is incorrect.


                  If you want a number of ticks, you can divide the difference by the TickSize.

                  (High[0] - Close[0]) / TickSize

                  If this was the ES with a TickSize of .25, and the High is 100 and the Close is 99, then this would produce 4 as 1 divided by .25 is 4 ticks.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    "If this was the ES with a TickSize of .25, and the High is 100 and the Close is 99, then this would produce 4 as 1 divided by .25 is 4 ticks."

                    Thanks Chelsea. That's what I wanted.

                    My question though is how to programmatically have that calculation done before I get to the conditions page. Cause I have to set that calculated value as a condition. I only have one set for the long and one set for the short.

                    Comment


                      #11
                      Hello Holligol,

                      This cannot be done before you get to the conditions page in the Strategy Builder.

                      The only math available in the Strategy Builder is with offsets. Set the offset to Ticks and type the number of ticks you would like to offset the value.

                      Below is a link to a forum post with helpful information about getting started with NinjaScript and C# and includes a link to the Strategy Builder 301 training video.


                      Also, below is a link to an example script that uses offsets.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        "This cannot be done before you get to the conditions page in the Strategy Builder."

                        So without using ninja script I cannot do this?

                        I am kind of surprised as the strategy builder has the ability to get a calculated value. What good is a calculated value unless used in a condition? I mean why have the capability to calculate a value if it cant be used in a trade?

                        Thanks for the help. Appreciate it!

                        Comment


                          #13
                          Hello Holligoly,

                          Thank you for your reply.

                          Chelsea is out of the office today, but basically, the NinjaScript Strategy Builder isn't really meant to handle complicated math. You could certainly use a Set on the Conditions and Actions screen as your first set that has no conditions so it would be calculated anew on each bar using Offsets, as Chelsea mentioned, however, it's really quite limited in what you can do with it. You could then utilize the value calculated in later sets that do have conditions. The intent of the Strategy Builder is really to get you started with NinjaScript, not to allow you to do anything you could do with manual coding.

                          Please let us know if we may be of further assistance to you.
                          Kate W.NinjaTrader Customer Service

                          Comment


                            #14
                            "You could then utilize the value calculated in later sets that do have conditions"

                            I will try it out. if it works, that would solve my problem!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by mmenigma, Yesterday, 03:25 PM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by kujista, Today, 05:44 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post kujista
                            by kujista
                             
                            Started by ZenCortexCLICK, Today, 04:58 AM
                            0 responses
                            9 views
                            0 likes
                            Last Post ZenCortexCLICK  
                            Started by sidlercom80, 10-28-2023, 08:49 AM
                            172 responses
                            2,281 views
                            0 likes
                            Last Post sidlercom80  
                            Started by Irukandji, Yesterday, 02:53 AM
                            2 responses
                            18 views
                            0 likes
                            Last Post Irukandji  
                            Working...
                            X