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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    42 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    25 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    162 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    157 views
    2 likes
    Last Post CaptainJack  
    Working...
    X