_SECTION_BEGIN("strefa volumenowa");
SetChartOptions(0,0,chartGrid30|chartGrid50|chartGrid70);
mnoznik=Param("krotnosc", 1,0.1,10,0.1);
srednia=Param("MA",30,20,300,10);
sredniaV=MA(V,srednia);
vol = V > sredniaV * mnoznik;
function GetTop(bars)
{
Top = vol;
return Top;
}
P1 = GetTop(0);
RF1=ValueWhen(P1,H);
Plot(RF1,"",colorGreen,16+40 |styleNoLabel);
RF2=ValueWhen(P1,L);
Plot(RF2,"",colorRed,16+40|styleNoLabel);
function GetVisibleBarCount()
{
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
return Min( Lvb - fvb, BarCount - fvb );
}
function GfxConvertBarToPixelX( bar )
{
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxchartleft = Status("pxchartleft");
pxchartwidth = Status("pxchartwidth");
return pxchartleft + bar * pxchartwidth / ( Lvb - fvb + 1 );
}
// Szerokosc Bar w pixelach
function GfxConvertBarWdthPixelX()
{
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxchartwidth = Status("pxchartwidth");
return pxchartwidth / ( Lvb - fvb + 1 );
}
function GfxConvertValueToPixelY( Value )
{
local Miny, Maxy, pxchartbottom, pxchartheight;
Miny = Status("axisminy");
Maxy = Status("axismaxy");
pxchartbottom = Status("pxchartbottom");
pxchartheight = Status("pxchartheight");
return pxchartbottom - floor( 0.5 + ( Value - Miny ) * pxchartheight/ ( Maxy - Miny ) );
}
GfxSetOverlayMode(1);
GfxSelectSolidBrush( colorOrange );
GfxSelectPen( colorOrange,1, 0 );
AllVisibleBars = GetVisibleBarCount();
fvb = Status("firstvisiblebar");
RequestTimedRefresh(1); // ensure 1 sec refresh
endPiwota= BarCount;
startPiwota=gettop(0);
dlugoscPiwota = BarsSince(startpiwota);
dp=LastValue(dlugoscPiwota);
BarWdth = GfxConvertBarWdthPixelX() ;
kolor1 = colorPlum;
for( i = 0; i < AllVisibleBars ; i++ )
{
if (endpiwota[i+fvb])
{
dp=dlugoscPiwota[i+fvb];
if ( i +fvb -dp > 0)
{
x2 = GfxConvertBarToPixelX( i );
x1 = GfxConvertBarToPixelX( i-dp );
y1 = GfxConvertValueToPixelY( H[ i +fvb -dp]);
y2 = GfxConvertValueToPixelY( L[ i +fvb -dp]);
GfxSelectSolidBrush( kolor1 ); GfxSelectPen( kolor1 ,1, 0 );
GfxRectangle(x1-BarWdth/2 , y1, x2 +BarWdth/2 , y2);
}
}
}
// exploracja
BUYINGSPIKE= Volume >= mnoznik * sredniaV;
SELLINGSPIKE= Volume >= mnoznik * sredniaV;
buysignal = C > Ref(RF1,-1) AND vol;
sellsignal = C < Ref(RF2,-1) AND vol;
Filter = buysignal OR sellsignal;
AddColumn(V,"Volume", 1);
AddColumn(sredniaV,"30bar Avg Volume", 1);
//VStatus= WriteIf(BUYINGSPIKE,"UPMOVE SPIKE", WriteIf(SELLINGSPIKE,"DOWNMOVE SPIKE", " "));
//VColor= IIf(BUYINGSPIKE, colorBRIGHTGreen, IIf(SELLINGSPIKE, colorLightOrange, colorPaleTurquoise));
//AddTextColumn(VStatus,"VOLUME SPIKE",1,colorDarkBlue,VColor);
AddColumn (L, "Low", 1.2);
AddColumn (H, "High", 1.2);
signalStatus= WriteIf(buysignal,"UPMOVE SPIKE", WriteIf(sellsignal,"DOWNMOVE SPIKE", " "));
signalColor= IIf(buysignal, colorBRIGHTGreen, IIf(sellsignal, colorLightOrange, colorPaleTurquoise));
AddTextColumn(signalStatus,"VOLUME SPIKE",1,colorDarkBlue,signalColor);
_SECTION_END();