Can u warning correct in afl

KelvinHand

Well-Known Member
#11
@KelivinHand

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();
Note: I think this is not the correct intraday VWAP.
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:
#12
To Master blaster KelvinHand :- Many thanks works :)



and

proper afl code now is

Code:
_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();  


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_BEGIN("ATP");

DayChange = Day() != Ref(Day(), -1);
AvgTradePrice = Null;
CurDayBars = 0;
CurDayCloseSum = 0;
 
for (i = 0; i < BarCount; i++)
{
if (DayChange[i])
{
CurDayCloseSum = C[i];
CurDayBars = 1;
}
else
{
CurDayCloseSum = CurDayCloseSum + C[i];
CurDayBars++;
}
AvgTradePrice[i] = CurDayCloseSum / CurDayBars;
}
Plot(AvgTradePrice, "AvgTradePrice",colorRed,styleThick);
ATP=AvgTradePrice;
 
_SECTION_END();

Buy  =Cover=Ref(L,-1)>Ref(VWAP,-1) AND Ref(L,-1)>Ref(AvgTradePrice,-1)AND H>Ref(H,-1);
Short=Sell=Ref(AvgTradePrice,-1)>Ref(H,-1) AND Ref(VWAP,-1)>Ref(H,-1)AND L<Ref(L,-1);


Buy=ExRem(Buy,Short) OR ExRem(Buy,Sell) ;
Short=ExRem(Short,Buy) OR ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);


PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-45);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-55); 
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-50); 
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=55);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=65); 
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-60);

_SECTION_BEGIN("ema");
Lk = EMA(Close,22);



GfxSetOverlayMode(0); 
GfxSelectFont("Tahoma", Status("pxheight")/36); 
GfxSetTextAlign( 6 );// center alignment 
GfxSetTextColor( colorLightGrey ); 
GfxSetBkMode(0); // transparent 
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/15 );

cx=Param("cxposn",785,0,500,1);
cy=Param("cyposn",39,0,500,1);
GfxSetBkColor(ColorRGB(200,50,100));
GfxSelectFont( "tohomabold",24,30, False);
GfxSetTextColor( colorYellow);
GfxSetTextColor( ColorHSB( 100, 10, 400) );
GfxTextOut("LTP. "+C+" ", cx, cy );

_SECTION_END();
 
Last edited:

trash

Well-Known Member
#13
@TRASH
ty for corrected code but it turned off all the buy sell arrow so that won:t work>>
[the code ] kills all the buy sell arrows so not desirable solution
Nonsense.
Those two lines don't kill anything.
It's because your entire code is junk.
You are a clueless little ghetto vagabond that's all there is.

As for the rest. Sooner or later (more sooner than later) it will hit you hard.
 
#14
topic is closed for discussion ..
it;s not my code.. it;s afl i found on internet . i am not coder.
i don;t know AbC of programming afl....

No one dies virgin in this Market. Stock Market rapes all 1 day or another and you are no exception.
why are u so hyper mamu .... always ready to fight .. i don;t understand.
Be cool .. u want to fight go fight the undefratable shark of stock market The bald guy[Fund manger]^^^ lol

And

Ty once again Kelvinhand ppls like u a are true Boon to tarding and programming community :)
thx to all ppls that replied ....
 

trash

Well-Known Member
#15
topic is closed for discussion ..
it;s not my code.. it;s afl i found on internet . i am not coder.
i don;t know AbC of programming afl....

No one dies virgin in this Market. Stock Market rapes all 1 day or another and you are no exception.
why are u so hyper mamu .... always ready to fight .. i don;t understand.
Be cool .. u want to fight go fight the undefratable shark of stock market The bald guy[Fund manger]^^^ lol

And

Ty once again Kelvinhand ppls like u a are true Boon to tarding and programming community :)
thx to all ppls that replied ....
And people of your kind are definitely a disease to every community. That's for sure.
 

Similar threads