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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    30 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    17 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    9 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    16 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    19 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X