Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Place Order After Price Drops 20 Ticks Below Previous High

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

    #31
    Hello maaxk,

    Prints are added in the actions 'Do the following' section under Misc > Print and will appear in the NinjaScript Output window.

    May I confirm you have watched the 'Debugging with the Strategy Builder' video from the support article I have directed you to in post #23?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #32
      Hello Chelsea, I have watched that post but that is for strategy builder not scripts, i have unlocked the scripts and now i am unable to edit it in the builder again.

      I need to know where will i get the prints.

      Comment


        #33
        Hello maaxk,

        In post #17 you stated you are still using the Strategy Builder with this script.

        Did you unlock the script after that point?

        Prints are added in the code of an unlocked script by calling the Print() method.

        See the example prints in the support article and watch the NinjaScript Editor 401 video linked from the article.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #34
          Hello Chelsea,

          Now i have redone the whole thing in the strategy builder along with the print action in the third se and here's the screenshot.

          Please let me know what am i missing and what is going wrong?
          Click image for larger version

Name:	image.png
Views:	114
Size:	257.2 KB
ID:	1315327
          The encircled PH is the previous high, the underlined price EP is the position on which it should've entered a long position in case of 20 ticks it should've been 4 points higher than that position and the price came lower than that position. The ninjascript output window is showing these figures regardless of whether i run the strategy or not.

          Please let me know what we can do to make it work.

          Thanks!

          Comment


            #35
            Hello maaxk,

            Why is that the previous high?

            What are the rules of determining a previous high?

            Regarding the print, is this in a condition set with no conditions? (See Set 4 in the test script I have provided)

            It does look like there is some number that is printing.

            Be sure to follow the direction in the article and print the time of the bar, all values in the condition, and labels for each value and comparison operator.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #36
              Hello Chelsea,

              These are all the screenshots of the strategy builder step by step from first to last. Please see them and guide me accordingly.

              Click image for larger version  Name:	image.png Views:	0 Size:	25.2 KB ID:	1315330

              Click image for larger version  Name:	image.png Views:	0 Size:	28.8 KB ID:	1315331

              Click image for larger version  Name:	image.png Views:	0 Size:	29.2 KB ID:	1315332

              Click image for larger version  Name:	image.png Views:	0 Size:	31.1 KB ID:	1315333​​

              Thanks!

              Comment


                #37
                Hello Chelsea,

                Why is that the previous high?
                That is the previous high Because that was the point from which the price started decreasing, that was the highest price, that is what we are targeting.

                What are the rules of determining a previous high?
                That is what i am here for, how will i tell the strategy to detect that price from which it started coming down.

                Regarding the print, is this in a condition set with no conditions? (See Set 4 in the test script I have provided)
                I just added print in the third set added an action there.

                It does look like there is some number that is printing.
                These numbers are being printed with or without running the strategy.

                Be sure to follow the direction in the article and print the time of the bar, all values in the condition, and labels for each value and comparison operator.
                Already on that but it should at least do something. also the chart i am running it on is mdMaxPrime

                Below is the screenshot of the output window without running any script or window. Also the out 2 page is empty.
                Click image for larger version

Name:	image.png
Views:	111
Size:	216.5 KB
ID:	1315336

                Thanks!

                Comment


                  #38
                  Hello Chelsea, Its a Kind reminder.

                  Thanks!

                  Comment


                    #39
                    Hello Chelsea,

                    I just run a test on the strategy analyzer and here is the result:

                    Click image for larger version

Name:	image.png
Views:	116
Size:	115.8 KB
ID:	1315403Click image for larger version

Name:	image.png
Views:	102
Size:	236.3 KB
ID:	1315404Click image for larger version

Name:	image.png
Views:	100
Size:	226.1 KB
ID:	1315405

                    ​Well, this is not my goal , I will explain my goal below through a chart:
                    Click image for larger version

Name:	image.png
Views:	102
Size:	214.1 KB
ID:	1315406
                    It doesn't makes any sense on what basis it is entering into these long positions too frequently. Look in the above screenshots, you see the
                    PH Top of the bar
                    that is the Previous high it should consider the arrow head or the peak of the chart where it reaches to a point and then reverses back. That is the point it should consider a s the previous high.
                    Then you see the
                    Entry point in black circle there the price is 1996
                    That is where it should enter the long position and then again wait for another peak or arrowhead to appear in the chart or the same arrowhead moves up and crosses the previous High and makes another Hight than that one. Then it should again enter another long position and after 2 or 3 simultaneous trades the loop should end and not enter any other position.

                    Lemme explain the login in the form of an algorithm below:

                    Conditional Statement in Plain Language
                    1. Determine the Highest Price (Previous High):
                      • Find the highest price point where the market reversed from an uptrend to a downtrend. This becomes your reference price.
                    2. Check for Entry:
                      • If the current price hits a specific entry point (e.g., 1996), enter a long position.
                    3. Monitor for New Peaks:
                      • Keep track of price movements. If the price rises above the previous high, this indicates a new peak.
                    4. Enter New Positions:
                      • If a new peak is reached (price is higher than the previous high), enter another long position.
                    5. Limit the Trades:
                      • Ensure that you only enter a maximum of 2 or 3 positions based on new peaks.
                    6. Stop Trading:
                      • Once you have entered the maximum allowed number of trades, do not enter any more positions.
                    ​Please see these details and let me know how we can achieve this goal. Apart form that i have also posted a couple of replies after your last response please get a look at them too.

                    Thanks!

                    Comment


                      #40
                      Hello maaxk,

                      Add the print to a condition set without any conditions so that this prints for every bar, the same as in the test script I have provided you.

                      Monitor for New Peaks:
                      Keep track of price movements. If the price rises above the previous high, this indicates a new peak.​

                      So a new high is saved if the current bar's high is greater than the previous bars high?

                      Change the condition in Set 2 to Price > High (bars ago 0), Greater, Price > High (bars ago 1).

                      Do you want to reset the high at some point? What would be logic for resetting the saved high?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #41
                        Hello Chelsea,

                        I did it and its still not entering any long trades.
                        Click image for larger version

Name:	image.png
Views:	102
Size:	29.9 KB
ID:	1315473
                        Click image for larger version

Name:	image.png
Views:	101
Size:	27.1 KB
ID:	1315474
                        The conditioning is as follows as i explained in the previous response:

                        Initialize
                        Set tradeCount = 0
                        Set profitTarget = desired profit (e.g., $50 or 2% of entry price)
                        Set entryThreshold = distance below high for entry

                        For each bar in historical data:
                        If trend reversal (arrowhead) found:
                        Set previousHigh = peak price
                        If current bar high > previousHigh:
                        Set currentHigh = current bar high

                        If current price <= currentHigh - entryThreshold:
                        Enter long position
                        Calculate targetPrice = entryPrice + profitTarget
                        Monitor price
                        Close trade when price >= targetPrice
                        Increment tradeCount

                        If tradeCount < 2:
                        If price makes a new high (higher than previousHigh):
                        Update currentHigh
                        Set new entry point = currentHigh - entryThreshold
                        If current price <= new entry point:
                        Enter long position
                        Calculate targetPrice = entryPrice + profitTarget
                        Monitor price
                        Close trade when price >= targetPrice
                        Increment tradeCount

                        If tradeCount >= 2:
                        Stop the strategy

                        Comment


                          #42
                          Hello maaxk,

                          "I did it and its still not entering any long trades."

                          Are you using prints to show the CurrentHighSeries is being updated to each new high?

                          "If trend reversal (arrowhead) found:"

                          What are the rules of a trend reversal or arrowhead?

                          "Set previousHigh = peak price"

                          What are the rules of determining the previous peak price?


                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #43
                            Hello Chelsea:

                            The Print function is as follows:
                            // Set 3
                            if (Close[0] < (CurrentHighSeries[0] + (-20 * TickSize)) )
                            {
                            CurrentHighSeries[0] = High[0];
                            EnterLong(2, "");
                            Print(Convert.ToString(MarketPosition.Long));
                            }


                            Trend Reversal and Previous Peak Price Rules:

                            Trend Reversal and Arrowhead Rules

                            1. Trend Reversal (Arrowhead) Rules:


                            A trend reversal occurs when the direction of the market changes from an uptrend to a downtrend or vice versa. In technical analysis, the term "arrowhead" is often used metaphorically to represent a peak or trough where the trend changes direction. Here’s how you can define a trend reversal in a practical way:
                            • Local Maximum (Peak):
                              • A local maximum is a point where the price reaches a high and then starts to decline. This is a potential reversal point in an uptrend.
                              • Condition: A bar (or candle) where the high price is greater than the highs of its immediate neighboring bars.
                              • Example: If the high of the current bar is higher than the high of the previous bar and the next bar, it could be a peak.
                            • Local Minimum (Trough):
                              • A local minimum is a point where the price reaches a low and then starts to rise. This is a potential reversal point in a downtrend.
                              • Condition: A bar (or candle) where the low price is lower than the lows of its immediate neighboring bars.
                              • Example: If the low of the current bar is lower than the low of the previous bar and the next bar, it could be a trough.
                            • Confirming Reversal:
                              • To confirm a trend reversal, additional indicators or patterns may be used, such as moving averages, trendlines, or other technical analysis tools.
                              • Example: A bearish candlestick pattern or a moving average crossover might confirm the trend reversal indicated by the arrowhead.
                            2. Determining the Previous Peak Price:


                            The "previous peak" refers to the highest price level reached before the trend reversed. Here’s how you can determine it:
                            • Identify the Peak:
                              • Look for the highest point where the price reached before it started to decline. This is the local maximum.
                            • Rules for Peak Detection:
                              • Local Maximum Rule: Compare the high of the current bar with the highs of its neighboring bars (usually one bar before and after).
                                • If High[0] > High[1] and High[0] > High[1] then High[0] is a peak.
                              • Filter: Ensure the peak is part of a valid trend by checking if the price was generally moving upwards before this peak.
                            • Set Previous High:
                              • Once a peak is identified, set this peak price as the previousHigh.
                              • Example: If the peak is $2000 and the price declines after reaching this point, $2000 becomes the previousHigh.
                            Example of Applying These Rules


                            Detecting Trend Reversal:
                            1. Trend Reversal Detection:
                              • For a peak (uptrend reversal), look for a bar where the high is greater than the highs of the bars immediately before and after it.
                              • For a trough (downtrend reversal), look for a bar where the low is lower than the lows of the bars immediately before and after it.
                            2. Determining Previous Peak Price:
                              • Identify the highest price within a range of bars before a clear trend reversal.
                              • Once detected, this highest price becomes the reference previousHigh.
                            Pseudocode Example


                            For each bar in historical data:
                            If high of current bar is higher than the high of previous bar and next bar:
                            This bar is a local peak
                            Set previousHigh = high of this bar

                            If low of current bar is lower than the low of previous bar and next bar:
                            This bar is a local trough
                            Record the lowest point for possible trend reversal
                            • Trend Reversal: Detect points where the price changes direction, using local maxima and minima.
                            • Previous Peak Price: Identify the highest price before the trend changes and set it as previousHigh.

                            Using these rules, you can systematically identify trend reversals and determine significant price levels for your trading strategy.
                            Please let me know if you need any further clarity.

                            Thanks!

                            Comment


                              #44
                              Hello maaxk,

                              The print should be in a condition set with no conditions, as shown in the test script I have provided you. This way the print appears for every bar.

                              What are the specific rules you want in the condition?

                              Are you looking for the high of the current bar to be less than 1 bar ago and the high of 1 bar ago to be greater than 2 bars ago?
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #45
                                Hello Chelsea,

                                How will i do it in the strategy builder:
                                The print should be in a condition set with no conditions, as shown in the test script I have provided you. This way the print appears for every bar.
                                Please guide step by step.

                                What are the specific rules you want in the condition?

                                Are you looking for the high of the current bar to be less than 1 bar ago and the high of 1 bar ago to be greater than 2 bars ago?
                                Chelsea B.​
                                Please read all the steps in the screenshot attached, i think it should clear your confusion.

                                Click image for larger version

Name:	Trading Strategy.png
Views:	105
Size:	232.5 KB
ID:	1315494

                                Thanks!

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                663 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                376 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                110 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                575 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                580 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X