Coding formula for VWAP – share price

Forums ProRealTime English forum ProBuilder support Coding formula for VWAP – share price

Tagged: 

Viewing 13 posts - 1 through 13 (of 13 total)
  • #94455

    I am trying to create an indicator that will give me the difference between the current share price and VWAP as a percentage. I’m using the code shown below, but it has a syntax error in line 2 and I don’t know how to fix it. I can’t get ProBuilder to give me the correct code for VWAP as it doesn’t appear in the indicator list. Any suggestions gratefully received. Thanks

     

    Someone elsewhere has suggested the following code for VWAP but it comes up with a syntax error also.

     

    Sorry, the instructions say to use the <> “insert PRT code” button but I can’t see where that is.

    #94467

    Screenshot_1-2

    I tidied up your post for you. 🙂

    #94470

    Type VWAP in the search box (found top right by hovering over your profile picture) and several VWAP indicators are already in the library. You can use the VWAP calculations found in these to easily create your indicator.

    Sum and VWAP are not code words used in PRT which is why you get the error.

     

    #94474

    You can try this. Not tested:

     

    #94475

    Dear Vonasi,

    Thank you so much for your quick reply. I realise in looking at it that I really only need an indicator which gives share price minus VWAP. However, when I tried this it didn’t work. I used the code:

     

     

    #94477

    Sorry, sorry, it is % difference between share price and VWAP that I need.  But the code still seems to be wrong. See my image.

     

     

    #94480

    I cut and pasted the VWAP code from an indicator and I notice now that it is showing VWAP for the close of the previous bar.

    The VWAP calculation is on the previous bar but your on price VWAP indicator is the daily VWAP on a 5 minute chart hence the difference.

    I tidied up your post again. Please see my previous post with the image of where the ‘Insert PRT Code’ button is and try to remember to use it. 🙂

    #94482

    Try this:

    It starts measuring VWAP from the first candle of the day. If you just want a fixed number of bars for the calculation then try this:

     

    #94483

    I just found a minor bug due to the lack of volume history which means that when switching time frames the indicator does not work.

    Here is a fix:

     

    #94531

    Hi Vonasi,

    I’ve got your code working, so thanks very much. This is what I’ve ended up using:

    One other question, is there any way that I can reduce the number of decimal places on the index readouts from 5 to 2 on the charts? (e.g. 0.25, rahter than 0.25467) See image.

    With thanks, Pippa

     

     

     

     

    #94570

    Try this – not tested – it might only round it to two decimal places and not change the displayed number of digits:

     

    #94598

    Seems similar to measure the normalized distance from the VWAP like this indicator of the library: Z-Score distance from VWAP

    #94758

    Thanks, no this is quite different from a Z-score concept. It is the difference between the trading price at any given time, and the VWAP number, expressed as a percent. Z-score is related to standard deviations. A completely different concept to VWAP. But thanks.

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

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