candlestick rsi: not working

Forums ProRealTime English forum ProBuilder support candlestick rsi: not working

Viewing 15 posts - 1 through 15 (of 16 total)
  • #44741

    Hi guys,

    someone could tell me why the following code doesn’t work?

    It was supposed to graph rsi as candlestick, instead it only graphs a single dash of current value. I didn’t expect it to work in already completed bars (because I imagine for that bars only ohlc are available), but I don’t understand why it doesn’t work in real-time bars.

    Thanks,

    Alberto

    #44747

    Before debugging your code, please have a look at this version I made months ago for another member of the forum: RSI with candlesticks

    #44749

    Hi Nicolas,

    your code has a different logic: your ohlc values are calculated applying rsi() on different price series; instead, I always use the close price.

    It seems that even if the variables are declared as ONCE their prev value is lost.

    #44751

    That’s right, I get the same behaviour, even with my own version:

     

    #44757

    I really don’t understand how the code is evaluated; does the code is executed every tick?

    The following code should plot a line with constant value of 1 (only on the first tick of each bar it should switch to 0), instead it’s always 0

    Am I missing something or could it be a bug?

    #44758

    IT IS POSSIBLE BARINDEX=-1?

    #44767

    No, it wouldn’t.

    According to documentation, BarIndex is a monothonically increasing value starting from 0

    #44784
    AVT

    As far as I see it, you have a condition which is checked and a result is found and plotted. There is nowhere something telling the program to repeat the condition check.

    #44785

    Hi AVT,

    I totally agree with you during the first execution of the code; that body is from a dummy indicator I wrote to reproduce the issue. Being an indicator, I expect that body will be executed for every tick; from the second execution onward cbidx won’t never be -1, it will be most of the time equal to BarIndex (except during the first tick of a new bar). So, most of the time the result should be 1.

    Being delcared as “once” (that from what I understood from doc is somewhat similar to “static” keyword in classical programming languages) the previous values of cbidx and rval should be kept.

    #44844

    Hi guys,

    I’m sorry to bother you (again) with this issue, but really I don’t understand the code execution logic behind an indicator. Another example:
    <pre class=”lang:probuilder decode:true “>once cbidx=0
    once a=0

    a = BarIndex-cbidx
    cbidx = BarIndex

    return a

     

    The returned value, a, is always 1.

    I really don’t understand how is that possible!!!! The only way for “a” to be always 1 is that my code is executed only when a new bar is formed (more specifically, on the first tick of every new bar). But looking at other indicators I can see their values changing every tick, so the indicator has to be executed every tick. I checked the official doc again but it’s quite useless.

    #44849

    Live calculation of an indicator for an on-going candle is at every tick, so yes a=1. The only way I would understand the question and why you think a=1 is impossible would be in case you had a different understanding for “once” of what it really does, and would be expecting a to remain =0?

    If that’s the case, what “once a=0” does is to perform a=0 just once at first candle, it’s a line not read at following candles, and it doesn’t prevent either other calculations to be made for “a” in the code. It means “read this line just once at the beginning of the history”, it doesn’t mean “this is the value of a once and for all”.

    If this wasn’t the problem, sorry I completely misunderstood the question…

    #44852

    Noobywan,

    I’m sorry but english not being my language maybe I can’t explain my thoughts clearly.

    I’ll try one more attempt; lets see these two lines of code:

    From my understanding, BarIndex is an increasing counter counting the bars processed in the graph. If you agree with that, so the value of BarIndex will change every first tick of a new bar; said in another way, all the ticks of the same bar will have the same value of BarIndex.

    If what I just said is true, so the variable “a” should always be 0, except for every first tick of a new bar.

    Suppose that the code is evaluating the last tick of bar 1000; the variables are

    a = 1000-1000 = 0

    cbidx = 1000

    The next tick will be the first tick of bar 1001; so the variables will be

    a = 1001 – 1000 = 1

    cbidx = 1001

    Again, the second tick of bar 1001; the variables will be

    a = 1001 – 1001 = 0

    cbidx = 1001

    Third tick of bar 1001; the variables will be

    a = 1001 – 1001 = 0

    cbidx = 1001

    …and so on…

    First tick of bar 1002; the variables will be

    a = 1002 – 1001 = 1

    cbidx = 1002

     

     

     

    #44855

    ok I think I see what you mean, it implies you consider cbidx would change value at first tick and keep it in memory for second tick of same bar, but what the code does is reevaluate at each tick what the latest close price mean for all variable values compared with previous bar’s values, not with previous tick values of current bar… so in other words, if cbidx is calculated on a tick which is not the last of the candle, then its calculation is “forgotten” for this tick and “remade” at next tick starting again from values at close of previous candle, and only calculation of last tick of a candle is then kept for calculations of next candle

    #44856

    Really? So there is no way to keep a value from tick to tick? Only from bar to bar?

    #44858

    Values that can change from tick to tick within the same bar are stored in platform reserved keywords, like high or low. But for a user-created variable inside a probuilder personal code, within a given timeframe, I am not aware of any way to store in memory all the diffrenent values such a variable went through at ticks before the last one inside a same candle. Even using a drawcandle command to display the range an indicator value would have to happen by calculation at last tick from price open,high,low,close of cnadle rather than intermediate-tick memory storing… Nicolas might correct me when he’s back if I’m wrong…

Viewing 15 posts - 1 through 15 (of 16 total)

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