Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Making OnEachTick and OnbarClose coexist

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

    Making OnEachTick and OnbarClose coexist

    I want to develop an indicator that is based on tick by tick. I understood how tick by tick works and IsFirstTickOfBar which allows to detect the new candle of the timeframe.
    The close[1] then represents the last tick of the previous bar, Close[2] the one that precedes it etc.
    My problem is that I also want to calculate the Williams R% of the previous bar calculated on the close.
    How to do it? Should I create variables that I initialize for each new bar to keep the highest and lowest of the bar and then manually calculate the R% or can I add a series but then how to feed and use it ?
    Thank you for your advice and possibly examples.​

    #2
    Hello bicou,

    When IsFirstTickOfBar is true, call the indicator and use an index of [1] on the plot.

    WilliamsR(ISeries<double> input, int period)[int barsAgo]
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


    if (IsFirstTickOfBar)
    {
    Print(string.Format("{0} | Time[1]: {1}, WilliamsR(20)[1]: {2}", Time[0], Time[1], WilliamsR(20)[1]));
    }
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X