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

Gaps indicator

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

    Gaps indicator

    Hi,

    recently I created very simple indicator which prints 1 if the todays open is
    equal or above/below prior high/low. I am using it for e-mini gaps. This is the code:

    {
    if (CurrentDayOHL().CurrentOpen[0] >= PriorDayOHLC().PriorHigh[0] || CurrentDayOHL().
    CurrentOpen[0] <= PriorDayOHLC().PriorLow[0])
    Value.Set(1);

    else Value.Set(0);
    }

    I want to ask is it possible to make any modification in a way that it prints 1 even when
    for example e-mini open is 1 point below previous high.
    My point is that I want a gap print even if todays open is maximum 1 point below
    previous day high.

    Thanks

    #2
    Hello flexi,

    Thanks for the post and welcome to the forums!

    I added the statements to your code segment that will meet your needs.

    Basically the parts I added, in Blue, are asking is the PriorDay High - the CurrentDay Open > 0 && < = 4 ticks. Note that I also added () in Red to enclose the whole statement.

    Code:
    if [COLOR="red"]([/COLOR](CurrentDayOHL().CurrentOpen[0] >= PriorDayOHLC().PriorHigh[0]
    || CurrentDayOHL(). CurrentOpen[0] <= PriorDayOHLC().PriorLow[0])
    [COLOR="Blue"]|| (((PriorDayOHLC().PriorHigh[0] - CurrentDayOHL().CurrentOpen[0]) / TickSize) > 0 
    && ((PriorDayOHLC().PriorHigh[0] - CurrentDayOHL().CurrentOpen[0]) / TickSize) <= 4)[/COLOR][COLOR="Red"])[/COLOR]
    {
    Value.Set(1);
    }
    else 
    {
    Value.Set(0);
    }
    TickSize contains the tick value of the instrument and is used to convert price to ticks. This way you can apply this code to any instrument. Of course the value of 1 point is different depending on the instrument and in this case I assumed ES where 4 ticks = 1 point. In your code you could add a user settable value for the number of ticks to evaluate for.

    Please let me know if I can be of further assistance.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      That worked great.

      Thank you very much

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by andrewtrades, Today, 04:57 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      5 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X