@KelivinHand
i tried chaning it to
i don;t know that deep programming............
so didn;t gave desirable result
i tried chaning it to
i don;t know that deep programming............
so didn;t gave desirable result
At first I wanted to give the answer as trash: (TodayVolume + 1e-30), but
my value consideration is not that small as 1e-30, might give infinite value to TodayVolume &
cause VWAP to be too small.
The warning message is giving the warning above the array of TodayVolume
Divide by 0 at array[0]....[n] of the initial part.
This can also be done by after
TodayVolume = Sum(V,Bars_so_far_today);
add in the following statement:
TodayVolume = IIf(TodayVolume==0, Null, TodayVolume);
to replace the 0 to null value. The idea is come from the ADK that using SkipEmptyValues().
Likely the old version may not encounter the "Divide by Zero" warning because of using SkipEmptyValues() internally.
The warning message is just a warning not so critical and no such thing as security issue.
The issue of you is that you know nuts about Amibroker, and you want to condemn Amibroker to attract attention.
You cannot visualize how powerful in the eye of true programmer, they can do wonder without restriction.
Here the fixed.
PHP:
_SECTION_BEGIN("VWAP");
//#### Modified by Kelvinhnad ####
Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
/* This statement don't make the VWap start at 09:00:00
Fixed startBar = ValueWhen(TimeNum() == 090000, BarIndex()); */
StartBar = TimeNum()>=090000;
TodayVolume = Sum(V,Bars_so_far_today);
//-- Fixed the Divide-by-0 at array[0]
TodayVolume = IIf(TodayVolume==0, Null, TodayVolume);
//-- From Trash: Correction to better programming style
VWAP = Sum (C * V, Bars_so_far_today)/TodayVolume;
//-- Draw VWAP based on Start Time
Plot (IIf(startbar, VWAP, Null),"VWAP",colorLime, styleThick);
//-- Created a dashed line from 00:00 to 09:00
Plot (IIf(NOT startbar, VWAP, Null),"",colorGreen, styleDashed);
_SECTION_END();
so the Buy/Sell Arrow may not be correct if the user required to start from 09:00
Here the VWAP Intraday Version
PHP:
_SECTION_BEGIN("Price Chart");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("VWAP");
//## Modified by KelvinHand ##
tmStart = 090000;
tmEnd = 165959;
tmRange = TimeNum() >= tmStart AND TimeNum() <= tmEnd;
barStart = TimeNum() >= tmStart ;
barStart = barStart - Ref(barStart,-1);
BarsInRange = (1 + BarsSince(barStart)) * tmRange;
volTotal = Sum(V,BarsInRange);
//-- Fixed the Divide-by-0 at array[0]
volTotal = IIf(volTotal==0, Null, volTotal);
VWAP = Sum(C* V * tmRange, BarsInRange ) / volTotal;
Plot(iif(VWAP, VWAP, Null), "VWAP",colorLime, styleNoLabel|styleThick, Null, Null, 0, 1);
_SECTION_END();
Last edited: