.

Perfect Crossover With Composite Volume - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.

Perfect Crossover With Composite Volume

_SECTION_BEGIN("Ed");
//Market Profile

GraphXSpace= 5; 
SetChartOptions(0, chartShowDates); 
Den = Param("Density", 40, 10, 100, 10); 
StyleVP = ParamStyle("style VP", styleLine, maskAll); 

BarsInDay = BarsSince(Day() != Ref(Day(), -1)) + 1; 
lastBarInDay = Day() != Ref(Day(), 1) OR Cum(1) == BarCount; 

Bot = TimeFrameGetPrice("L", inDaily, 0); 
Top = TimeFrameGetPrice("H", inDaily, 0); 
Vol = abs(TimeFrameGetPrice("V", inDaily, 0)); 
Range = (Top-Bot);

Box = Range/Den;

VolumeUnit = abs(Vol)/BarsInDay; 

// stored detected volume within certain price range at last bar of day

for(k = 0; k < Den; k++) 
{

Line = Bot + k * Box;

detect = Line >= L & Line <= H;

IntraV = IIf(lastBarInDay, Sum(detect * abs(V), BarsInDay), 0); 

VarSet("Vol" + k, IntraV); 
}

// Look for the biggest value and index
MaxVal = -1e20; 
MaxIndex = -1e20; 
POC = Top;
for(i = 0; i < Den; i++) 
{
Line = Bot + i * Box;
Vi = VarGet("Vol" + i); 
MaxIndex = IIf(MaxVal < Vi, i, MaxIndex); 
POC = IIf(MaxVal < Vi, Line, POC);
MaxVal = IIf(MaxVal < Vi, Vi, MaxVal); 
}

// plot the point of control
Plot(Ref(ValueWhen(lastBarInDay,POC),-1) , "POC", colorGold,1); 

// MP charting
for(j=0; j<Den; j++) 
{

Line = Bot + j * Box;

// MP charting 
IntraV2 = VarGet("Vol" + j) / VolumeUnit; 
ppp = Ref(ValueWhen(lastBarInDay, IntraV2, 0), -1); 
VpLine = IIf(ppp >= BarsInDay, Line + Box/4, Null); 

Plot(VpLine, "", IIf(ValueWhen(lastBarInDay, MaxIndex , 0)== j, colorRed, colorBlue), styleDots); 
}

SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) ); 
GraphXSpace= 5; 
SetChartOptions(0, chartShowDates); 
Plot(C,"\nLast",colorWhite,64); 
_SECTION_END();
Previous Post Next Post