keksParticipant
Average
Hi, I would like to draw a horizontal line on the intraday chart that represents last observed daily vwap level of previous session of trading. So in essense:
line1 = dclose(1)
return line1 coloured(255,255,255)
Except I do not want dclose, instead want to see where daily vwap was at close previous session. Would anyone PLEASE let me know how I can create this?
THANKS!!
There you go:
Timeframe(Daily,UpdateOnClose)
if volume > 0 then
VWAP = (volume * typicalprice)
endif
Timeframe(default)
return VWAP AS "Daily VWAP"
keksParticipant
Average
THANKS!!!!
I modified code slightly:
Timeframe(Daily,UpdateOnClose)
if volume > 0 then
d = max(1, intradaybarindex)
VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
endif
Timeframe(default)
return VWAP AS “Daily VWAP”
keksParticipant
Average
Hmm.. it seem to work for a bit then get calculation error and the indicator drops off the chart. Not sure what is wrong with code
keksParticipant
Average
in the attached pic the green is daily vwap, red is the code above… ideally i would like the red line to extend from where green on ends on previous day. strategy under development will build signals based on whether price remains above previous day vwap….
I am not getting any error with both of them.
Anyhow, you are NOT calculating VWAP, your code simply returns TypicalPrice.
I also got the error message now. I think it’s due to the high number involved summing up they daily volume*typicalprice for the intradaybarindex.
keksParticipant
Average
would it be easier/less calc to use last observed vwap level of previous session instead of calculating? In other words previous session daily vwap close… seem to be an lighter way to accomplish this however I am not sure how to code this
keksParticipant
Average
thanks again.
would you be chance be willing to help me specify time interval of previous day session for the vwap calculation line to be based off?
For example, let us assume I want to use index futures previous day vwap level during ordinary trading session only as an indicator on the following day trading session…
To make it work in a time interval the daily timeframe can’t be used.
The code you wrote is almost correct, provided the TIMEFRAME keyword is removed. Then a time interval must be added:
ONCE d = 0
if volume > 0 then
IF intradaybarindex = 0 THEN
d = 0
ENDIF
IF Time >= 080000 AND Time <= 180000 THEN
d = d + 1
VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
ENDIF
endif
return VWAP AS “Daily VWAP”
keksParticipant
Average
thanks so much for taking the time to update this code. Still this does not seem to give me a horizontal line marking previous end of session vwap level….
the reason I like having this drawn is many of the securities I follow seem to trade differently based on whether they are above or below previous session vwap…
I will try to figure out how to get an accurate line drawn using clues from your code, but so far still not where I would like to be!