Shift Moving Average to the left

Forums ProRealTime English forum ProBuilder support Shift Moving Average to the left

Viewing 10 posts - 1 through 10 (of 10 total)
  • #75489

    Hello,

    I look for instruction to shift moving avg to the left ( not to the right).

    i mean if i have 5 days : day1 day2 day 3 day4 and day 5

    the value for the 5 day moving average shifted by 2 on the LEFT is for the day 3 :

    value(day3 ) = 1/5 *(close(day1) + close( day 2) + close(day3) + close(day4 ) + close(day 5))

    as i have only 5 days, and as i shift by two on the left  the value is undefined for day 4 and day 5 and nothing is  displayed:

    value(day4) : blank

    value(day5) : blank

     

    this can be done with ‘shift horizontal’ property in moving average configuration box, but cannot be done programtically for the moment : how do it ?

    after this i will use other coefficients than 1/5 in my summations ( with some negative coefficients )

     

    Thierry Brémard

    #75490

    Moved to the English forum.

     

    #75492

    While you can easily draw something that happened in the past, like that

    the same is not allowed for the future.

    You could do that by making an indicator that computes the average itself within a FOR…NEXT loop, but it would require so many loops, especially if you should use multiple MAs crossovers and, even if ProBuilder would allow you to do it, well… it would require such a long time at every new candlestick to make you hate it!

     

    #75505

    Hello Roberto,

     

    thank you for your fast answer.

    i am annoyed because i understand that you suggest that it is not possible,

    but I can parameter the moving average to do this. attached you see in blue the 21 moving average shifted to the left by 10 units.

    pro builder should have instruction like this no ? maybe a meta instruction or meta parameter for indicator like “shift all result to -x units on the left” ?

    as you are partner with pro real time can you ask them how they do this with their own moving average ?

    or could you ask them to give the user possiblity to use their moving average mechanism with a custom module to specify exactly the value of the coeficcients ( user specifiy 21 values for a 21 moving average)

    Regards

     

    #75511

    That’s was not as difficult as I thought, if I understood your question (a screenshot is better than lots of words):

    From the attached screenshot you can see the same SMA[20] on the chart displayed normally and left-shifted 26 bars (I wrote 26 thinking about Ichimoku, but it has nothing to do with that). You can change the shifting, period and type as you prefer (for colors take a look at https://www.prorealcode.com/wp-content/uploads/2015/09/P1jHlnG.jpg).

    As for my partnership with PRT, I admit I would be glad to have one, but It is not the case for me and, as far as I know, for all other moderators. Even Nicolas, the Admin, is not a partner of PRT. He, living closer to PRT has for sure more chances to know something a bit earlier than anyone else here, but nothing else. AS being a moderator, well… Nicolas asked me as he saw I was frequently online and was answering many posts and questions, being a moderator simply means I can edit/move/cancel posts NOT getting paid!

    Me, as many other active members have suggested PRT (Nicolas set up this topic for that purpose) through https://www.prorealcode.com/topic/centralization-of-queries-and-suggestions-on-prorealtime/. And some suggestions are about to be integrated, so if you have some, feel free to post there!

    #75527

    Roberto found the best solution to plot curves in the past. There’s maybe other way, like with a loop from current bar but far more contraining..

    #75538

    Hello,

     

    thank you for the help, i validate the code below:

    I was speaking about partnership because i called the pro real time help friday (french office ). i called them first to have answer to my question and suggested me to try on this forum , i replied i wanted to speak to editor only, they replied to this that you were partner and in closed relation between pro real time and pro real code.

     

    Regards

     

    #75539

    Thank you for sharing your final code!

    PRT prefer to make their customers to ask questions about coding on this website, in order to create a complete database of questions / answers  similar as a FAQ.

    #75540

    is there a way to create an array ?

     

    i need to instanciate an array of coefficient at start of code then aplying coefficients to close with a for loop:

    coefficients = (1/N 1/N 1/N 1/N 1/N)

    what is the syntax ? i tried brakets and parenthesis and do not see any array section in their manual

     

    #75546

    Unfortunately arrays are not supported.

    Many of us can’t wait to have them, but we must be patient and do without at present.

Viewing 10 posts - 1 through 10 (of 10 total)

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