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

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.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by mattdowns1234, Yesterday, 06:57 PM
      0 responses
      14 views
      0 likes
      Last Post mattdowns1234  
      Started by dgee949, Yesterday, 06:26 PM
      0 responses
      24 views
      0 likes
      Last Post dgee949
      by dgee949
       
      Started by dgee949, Yesterday, 05:58 PM
      0 responses
      30 views
      0 likes
      Last Post dgee949
      by dgee949
       
      Started by thepcmd, Yesterday, 05:14 PM
      0 responses
      34 views
      0 likes
      Last Post thepcmd
      by thepcmd
       
      Started by xmess777, Yesterday, 04:58 PM
      0 responses
      23 views
      0 likes
      Last Post xmess777  
      Working...
      X