Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to enter a trade after price exceeds the highest high after 10 ticks.

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

    Trying to enter a trade after price exceeds the highest high after 10 ticks.

    Like my headline says, I am trying to enter a trade after the price exceeds the highest high from the past 10 ticks but I don't know if my code is actually doing it. Looking at this code, am I accomplishing what I need to?

    Code:
    if (CurrentBar < BarsRequiredToTrade) {
    
                    return;
    
                }
    
                double Highest = MAX (High, 10) [1];
                double Lowest = MIN (Low, 10) [1];
                if (High[0] > Highest) {
    
                EnterLong ("long");
    
                }
    
                if (Low[0] < Lowest) {
    
                EnterShort ("short");
    
                }

    #2
    In my code I used the past 5 ticks but I meant to use 10.

    Comment


      #3
      Hello jertrade,

      Thanks for your post.

      It will be necessary to use prints to verify that the logic you have written is doing what you expect. For example, you would print out values used to evaluate your conditions, like "Highest" to see that it is giving the value you are looking for, and that the logic is updating as you expect it to.
      double Highest = MAX (High, 10) [1]; This code is checking the highest high of the last 10 bars, from 1 bar ago. If you are running against a single tick data series, this would mean the highest high of the last 10 ticks, from the previous tick.

      If you are trying to check if the highest high of the last 10 bars is exceeded, you could use MAX (High, 10) [0]; and if you want to see if this happens after X number of ticks, you could add a single tick data series, and use that single tick data series to increment an integer to count how many ticks have passed. Then you could trigger logic "after 10 ticks."

      Please see our Multi Time Frame and Instruments documentation for a complete walkthrough for creating multi series NinjaScripts.

      Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

      Please let us know if we can be of further assistance.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      65 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X