Abnormal behavior of indicator plotting relative to count with time

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #147343 quote
    robocop
    Participant
    Average

    Good evening,

    i have an strange behavior from a sample code.

    defparam drawonlastbaronly = true
    once Count = 0
    
    if Count = 0 then
         Count = Count +1
         MyTime =  Time
         MySecond = MyTime mod 100
         drawtext("A-Seconds=#MySecond#-#Count#",barindex, low-4)
    else
         Count = Count +1
         MyTime =  Time
         MySecond = MyTime mod 100
     
        drawtext("B-Seconds=#MySecond#-Count=#Count#",barindex, 3200)
     
    endif
    
    return

    use in SP500 in market open time, never plot the “A” string, which Count value zero, but plot “B” string from the else clause for Count not zero.

    this is the image, but there are other two abnormal item:
    –  Seconds move (1,2,4,5,6,7,8,9,xxxx up to 59 then restart from zero)
    – Count value always 1.295.

    i dont understand: i expected that indicator plot either the A and B string, and that the B string have count growing from zero to xxxxx.

    if i load less bars (Second image) then number showing from count is still fixed, but its another value.

    may you help me? where i was wrong?

    abcd21.png abcd21.png abcd11.png abcd11.png
    #147355 quote
    robertogozzi
    Moderator
    Master

    It’s because indicators always preload some bars before the one when it starts. So count will start many bars before your indicator starts and count will always be > 0.

    As far as I know there’s no way to avoid this.

    Bear in mind that, unless you will be using a N-second TF, seconds will always be 00 because candlesticks always close on a minute boundary.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Abnormal behavior of indicator plotting relative to count with time


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
robocop @robocop Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
5 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/13/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...