_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();
SetPositionSize(75,spsShares);