All Custom Indicators return ZERO!

Forums ProRealTime English forum ProBuilder support All Custom Indicators return ZERO!

Viewing 7 posts - 1 through 7 (of 7 total)
  • #230957

    Hi PRC

    All my custom indicators return values of zero. Yesterday all was fine? If I copy and paste the indicator code into a strategy and graph them they return the correct values. Does anybody know what is going on?

    Johann

    #230990

    Hi
    Could you share with us the code?

    #231003

    Sure, originally I think the code was called hyper trend? So I added some code to count the bars in a down or up trend and use that to determine a high or low level within the specific trend…the code returns the correct value within a strategy but not within a indicator. It was working before today so I do not really know why it suddenly returns a zero value?

    mult = 5
    slope = 14
    width = 80
    once avg = close
    once hold = 0

    if barindex > 200 then
    atr = AverageTrueRange[200] * mult
    endif

    If abs(close – avg) > atr then
    avg = (close+avg)/2
    //avg = avgN
    else
    avg = avg + os*(hold/mult/slope)
    //avg = avgN
    endif

    os = sgn(avg – avg[1])

    If os <> os[1] then
    hold = atr
    else
    hold = hold[1]
    endif

    greenbarcount = 0
    if avg[2] > avg[1] and avg[1] < avg Then
    greenbar = barindex
    endif
    if avg[1] < avg Then
    greenbarcount = barindex – greenbar
    endif

    if greenbarcount >=1 then
    Longhigh = highest[greenbarcount](high)
    endif
    if greenbarcount =1 then
    Longlow = low
    endif

    Return Longhigh

     

    #231011

    Hi Ivan, any suggestions?

    #231012

    Hi..

    I’ve got a theory, any preloaded bars in a strategy my give a valid ATR value for the logic.

    In indicator, it needs 200 bars before valid ATR value available, since starting at bar zero.

    This might have found a never ‘true’ condition in the logic so no output.

    If you move the ‘ENDIF’ keyword, for the ‘BARINDEX>200 ‘IF’ block, to the end of the code just before ‘RETURN’, then something happens!

    Not sure if this ‘something’  is the desired outcome.

    Seems strange to use ‘ATR’ later in the code run but it may be ‘UNDEFIND’ till 200 bars up.

    Moving this ‘ENDIF’ means all code inside new code block waits till valid   ‘ATR’ value before executing.

    Regards druby

    1 user thanked author for this post.
    #231029

    Thanks Druby will try and see what happens…

    #231036

    Yes. You need wait 200 bars for the ATR calculation.

    1 user thanked author for this post.
Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login