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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X