The Flow Method and Market Profile

Compensation

hello, everybody presumably does not know or about me, but I retain you ...
I'm with you and I longing that things being what they are feel a true family. So paralysed a progress it all later to lure and command what next ...
regards
 
Any afl which plots lines on chart... POC , VAL, VAH etc
Hello sach007

you can try this AFL .... this AFL i got from a blog .....hope this may help you

Regards
AnAtheist


_SECTION_BEGIN("Price");
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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("vol histr");

PlotVOL = ParamToggle( "plot Volume?","No| Yes",0);

VolColor = (C>O OR (C==O AND (H-C)<=(C-L)))*ParamColor ("VUpColor" ,colorGreen) +

(C<O OR (C==O AND (H-C)>(C-L)))*ParamColor( "VDnColor" ,colorRed) ;

VolScale = Param("1/Vol. Height (TimeBar chart)(fraction of window) 5=1/5=20%",5, 2, 100, 1.0) ; // Timebars

if (PlotVOL >0)

{

Vheight = VolScale;

Plot(Prec(Volume ,0),"V",VolColor, styleNoTitle| styleOwnScale| styleThick| ParamStyle( "VStyle", styleHistogram,

maskHistogram) ,Vheight );

}
_SECTION_END();

_SECTION_BEGIN("hhll");
Q = Param( "% Change", 2, 0.1, 10, 0.1 );
Z = Zig( C , q ) ;
HH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( z, q, 1 ) > Peak( Z, q, 2 ) ) );
LH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( Z, q, 1 ) < Peak( Z, q, 2 ) ) );
HL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) > Trough( Z, q, 2 ) ) );
LL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) < Trough( Z, q, 2 ) ) );
GraphXSpace = 5;
dist = 0.5 * ATR( 20 );

for ( i = 0; i < BarCount; i++ )
{
if ( HH )
PlotText( "HH", i, H[ i ] + dist, colorYellow );

if ( LH )
PlotText( "LH", i, H[ i ] + dist, colorYellow );

if ( HL )
PlotText( "HL", i, L[ i ] - dist, colorPink );

if ( LL )
PlotText( "LL", i, L[ i ] - dist, colorPink );

}
_SECTION_END();

_SECTION_BEGIN("BACK COLR");
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
_SECTION_END();

_SECTION_BEGIN("Price");
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", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
ToolTip = "Open = " + O + "\nHigh = " + H + "\nLow = " + L + "\nClose = " + C;

_SECTION_END();

_SECTION_BEGIN("TD Systems");
// Parameters
ShowNumbers= ParamToggle("Show 1-8 Numbers","No|Yes", 1);
ShowTDPoints = ParamToggle("Show TD Points", "No|Yes", 1);
ShowTDST = ParamToggle("Show TD Setup Trend", "No|Yes", 1);
tdstsa = 0;
tdstba = 0;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//********************************************** TD Points********************************************************************/
function TD_Supply()
{
return ( H > Ref(H, 1) AND H > Ref(H, -1) AND H > Ref(C, -2));
}
function TD_Demand()
{
return ( L < Ref(L, 1) AND L < Ref(L, -1) AND L < Ref(C, -2));
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *********************************************** TD Sequential************************************************************/
// *** Setup Buy Signal ***
//nine consecutive days closes less than the close four days earlier
Con = C < Ref( C, -4);
Buy9Bars = BarsSince(BarsSince(Con));
Buy9Signal = Buy9Bars == 9;

// *** Requirements ***
//The first day of the nine-day must be preceded by a close day immediately before it that is greater than OR equal to the Close four days earlier
Con = Ref(C, -9) >= Ref(C, -13);
Buy9Req = Buy9Signal AND Con;

// *** Intersection ***
// the high of either day 8 or day 9 is greater than or equal to the low three,four, five, six, OR seven days earlier
Con1 = (H >= Ref(L, -3)) OR ( Ref(H, -1) >= Ref(L, -3));
Con2 = (H >= Ref(L, -4)) OR ( Ref(H, -1) >= Ref(L, -4));
Con3 = (H >= Ref(L, -5)) OR ( Ref(H, -1) >= Ref(L, -5));
Con4 = (H >= Ref(L, -6)) OR ( Ref(H, -1) >= Ref(L, -6));
Con5 = (H >= Ref(L, -7)) OR ( Ref(H, -1) >= Ref(L, -7));

Buy9Intr = Buy9Req AND (Con1 OR Con2 OR Con3 OR Con4 OR Con5);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *** Setup Sell Signal ***
//nine consecutive days closes greater than the Close four days earlier.
Con = C > Ref( C, -4);
Sell9Bars = BarsSince(BarsSince(Con));
Sell9Signal = Sell9Bars == 9;

// *** Requirements ***
//The first day of the nine-day must be preceded by a Close day immediately before it that is less than the Close four days earlier
Con = Ref(C, -9) < Ref(C, -13);
Sell9Req = Sell9Signal AND Con;

// *** Intersection ***
//the low of either day 8 or day 9 is less than or equal to the high three,four, five, six, OR seven days earlier
Con1 = (L <= Ref(H, -3)) OR ( Ref(L, -1) <= Ref(H, -3));
Con2 = (L <= Ref(H, -4)) OR ( Ref(L, -1) <= Ref(H, -4));
Con3 = (L <= Ref(H, -5)) OR ( Ref(L, -1) <= Ref(H, -5));
Con4 = (L <= Ref(H, -6)) OR ( Ref(L, -1) <= Ref(H, -6));
Con5 = (L <= Ref(H, -7)) OR ( Ref(L, -1) <= Ref(H, -7));

Sell9Intr = Sell9Req AND (Con1 OR Con2 OR Con3 OR Con4 OR Con5);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(StrToNum(NumToStr(Buy9Intr))) Sell9Intr = False;
if(StrToNum(NumToStr(Sell9Intr))) Buy9Intr = False;
BuySignal = Flip(Buy9Intr, Sell9Intr);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *** Buy Countdown ***
//With respect to a pending Buy Signal, the close must be less than the low two days earlier
Con = C < Ref(L, -2);
Buy13Count = Sum(Con AND BuySignal, BarsSince(Buy9Intr));
Buy13Signal = Buy13Count == 13;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// *** Sell Countdown ***
//with respect to a pending Sell Signal, the Close must be greater than the High two trading days earlier.
Con = C > Ref(H, -2);
Sell13Count = Sum(Con AND NOT BuySignal, BarsSince(Sell9Intr));
Sell13Signal = Sell13Count == 13;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************** TD Sequential Plotting area *************************************************/
Plot(C, "", IIf(O>=C, colorRed, colorGreen), styleBar);
PlotShapes(IIf(Buy9Intr OR Sell9Intr, shapeDigit9, shapeNone),colorBlue, 0, H,
20);
if(ShowNumbers)
PlotShapes(IIf(Buy9Bars==1, shapeDigit1,
IIf(Buy9Bars==2, shapeDigit2,
IIf(Buy9Bars==3, shapeDigit3,
IIf(Buy9Bars==4, shapeDigit4,
IIf(Buy9Bars==5, shapeDigit5,
IIf(Buy9Bars==6, shapeDigit6,
IIf(Buy9Bars==7, shapeDigit7,
IIf(Buy9Bars==8, shapeDigit8,
IIf(Buy9Bars >9, shapeStar,shapeNone))))))))),colorGreen, 0, H, H*.0015);
if(ShowNumbers)
PlotShapes(
IIf(Sell9Bars==1, shapeDigit1,
IIf(Sell9Bars==2, shapeDigit2,
IIf(Sell9Bars==3, shapeDigit3,
IIf(Sell9Bars==4, shapeDigit4,
IIf(Sell9Bars==5, shapeDigit5,
IIf(Sell9Bars==6, shapeDigit6,
IIf(Sell9Bars==7, shapeDigit7,
IIf(Sell9Bars==8, shapeDigit8,
IIf(sell9bars>9, shapeStar,shapeNone))))))))),colorRed, 0, H, H*.0015);

Sell = Sell13Signal AND NOT BuySignal;
Buy = Buy13Signal AND BuySignal;
Sell = ExRem(Sell, Buy);
Buy = ExRem(Buy, Sell);
PlotShapes(Sell*shapeDownArrow, colorYellow, 0, H, -H*.001);
PlotShapes(Buy*shapeUpArrow, colorBrightGreen, 0, L, -L*.001);

if(StrToNum(NumToStr(BuySignal)))
bgColor = ColorRGB(0,66, 2);
else
bgColor = ColorRGB(66,2, 0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************** TD Points Plotting area *************************************************/
if(ShowTDPoints)
{
PlotShapes(TD_Supply()*shapeSmallCircle, colorRed, 0, H, H*.001);
PlotShapes(TD_Demand()*shapeSmallCircle, colorGreen, 0, L, -L*.001);
///////////////////////////////////////////////////////////////////////////
y0 = StrToNum(NumToStr(ValueWhen(TD_Demand(), L)));
x = LineArray(0, y0, (BarCount-1), y0);
Plot(x, "", colorGold, styleDashed);
y0 = StrToNum(NumToStr(ValueWhen(TD_Supply(), H)));
x = LineArray(0, y0, (BarCount-1), y0);
Plot(x, "", colorGold, styleDashed);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************** TDST Plotting area *************************************************/
// ---------------->>>> Code from Dave <<<---------------------- //
if(ShowTDST)
{
tdstba =Cum(0);
tdstb = Null;
HHV9 = HHV(H,9);
for (i = 0; i < 10; i++) tdstba = Null;

for( i = 10; i < BarCount; i++ )
{
if (Buy9Bars == 9)
{
HHV_b = HHV9;
if (HHV_b > C[i-9])
tdstb = HHV_b;
else tdstb = C[i-9];

for (j = 0; j < 9; j++ )
tdstba[i-j] = tdstb;
}
else tdstba = tdstb;
}

tdstsa =Cum(0);
tdsts = Null;
LLV9 = LLV(L,9);
for (i = 0; i < 10; i++) tdstsa = Null;

for( i = 10; i < BarCount; i++ )
{
if (Sell9Bars == 9)
{
LLV_b = LLV9;
if (LLV_b < C[i-9])
tdsts = LLV_b;
else tdsts = C[i-9];

for (j = 0; j < 9; j++ )
tdstsa[i-j] = tdsts;
}
else tdstsa = tdsts;
}
Plot(tdstba, "TDSTb", colorBlue,styleStaircase | styleThick|styleDots);
Plot(tdstsa, "TDSTs", colorRed,styleStaircase | styleThick|styleDots);

}
_SECTION_END();

_SECTION_BEGIN("EMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 21, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );

_SECTION_END();


_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();_SECTION_BEGIN("MPLite");
PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);
function Lastthursday()
{
Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,IIf(Daysinmonthfinal-Day()<8 AND DayOfWeek()==3 AND Ref(DayOfWeek(),1)!=4 AND Day()!=Daysinmonthfinal ,1,0));
return returnvalue;
}

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

totalVisible=Lastvisiblebar-FirstVisibleBar;
//if(totalVisible<1500){

//Den = Param("Density", 1, 0.1, 10, 0.1);
percent=Param("Value Area", 70, 1, 100, 1);
Type=ParamList("Type","Price Profile|Volume Profile");
Period= ParamList("Base","Hourly|Daily|Weekly|Monthly|Lastthursday|Yearly",1);
x_scale=Param("Horizontal_scale", 2, 0, 10, 0.1);
EnMP2= ParamStyle("Style",styleLine|styleNoLabel,maskAll);
styleLines=styleDots;
EnIB = ParamToggle("Show Initial Balance", "No|Yes",0);
IBBars = Param("Initial Balance Bars", 2, 1, 10, 1);
ViewYvalues= ParamToggle("Show Yesterdays Values", "No|Yes",1);
ViewVlines= ParamToggle("Show Vertical Base Lines", "No|Yes",1);
Viewvalues= ParamToggle("Show Values", "No|Yes",0);
ViewVpoc= ParamToggle("Show Virgin POC", "No|Yes",1);
ViewTPO=ParamToggle("Show TPO Count", "No|Yes",0);

if(Period=="Hourly"){
BarsInDay = BarsSince(Hour() != Ref(Hour(), -1));Bot = TimeFrameGetPrice("L", inHourly, 0);Top = TimeFrameGetPrice("H", inHourly, 0);Vol = TimeFrameGetPrice("V", inHourly, 0);
}
if(Period=="Daily" ){//OR Interval()==3600
BarsInDay = BarsSince(Day() != Ref(Day(), -1) ) ;Bot = TimeFrameGetPrice("L", inDaily, 0);Top = TimeFrameGetPrice("H", inDaily, 0);Vol = TimeFrameGetPrice("V", inDaily, 0);
}
if(Period=="Weekly" OR Interval()==24 * 3600 ){
BarsInDay = BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ));bot1=ValueWhen(BarsInDay==0,L,1);Bot2 = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);bot=Min(bot1,bot2);top1=ValueWhen(BarsInDay==0,H,1);Top2 =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);top=Max(top1,top2);Vol = TimeFrameGetPrice("V", inWeekly, 0);
}
if(Period=="Monthly" ){
BarsInDay = BarsSince(Month() != Ref(Month(), -1));Bot = TimeFrameGetPrice("L", inMonthly, 0);Top = TimeFrameGetPrice("H", inMonthly, 0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}
if(Period=="Lastthursday" ){
BarsInDay = BarsSince(Lastthursday()==0 AND Ref(Lastthursday(), -1)==1);bot1=ValueWhen(BarsInDay==0,L,1);Bot2 = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);bot=Min(bot1,bot2);top1=ValueWhen(BarsInDay==0,H,1);Top2 =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);top=Max(top1,top2);Vol = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,Sum(V,BarsInDay),0);

}
if(Period=="Yearly" ){
BarsInDay = BarsSince(Year() != Ref(Year(), -1));Bot = TimeFrameGetPrice("L", inYearly, 0);Top = TimeFrameGetPrice("H", inYearly, 0);Vol = TimeFrameGetPrice("V", inYearly, 0);
}

CurTop = HHV(H,BarsInDay+1);
Curbot = LLV(L,BarsInDay+1);

Range = Top-Bot;
coverage=LastValue(Ref(ATR(10),-1));

den=(coverage/10);
//den=1;

multiplier=IIf(round(totalVisible)/300<1,1,round(totalVisible)/300);

if(ViewVlines==1)
{
Plot(BarsInDay==0, "", ParamColor("Base Line Color",colorDarkGrey), styleHistogram | styleOwnScale | styleLine | styleNoLabel);
}

relTodayRange = 0;
x=0;
basey=0;
basex=0;
newday=0;
total=0;
shiftup=0;
shiftdn=0;
Line=Null;
Voloumeunit=0;


for ( i = IIf(FirstVisibleBar-100>1,FirstVisibleBar-100,FirstVisibleBar); i <Lastvisiblebar AND i<BarCount-1 ; i++ )
{
if(BarsInDay==0)
{t=BarsInDay[i-1];

Col=ParamColor("IB Color",colorWhite);
IBstyle=ParamStyle("IB style",styleLine,maskAll);
if(EnIB==1)
{
IBH=HHV(H,IBBars);
IBL=LLV(L,IBBars);
Line1 = LineArray(basex, IBH[basex+IBBars-1],i, IBH[basex+IBBars-1]);
Plot(Line1,"",Col,IBstyle);
Line2 = LineArray(basex, IBL[basex+IBBars-1],i, IBL[basex+IBBars-1]);
Plot(Line2,"",Col,IBstyle);
}
//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;


for (j=1; j<= relTodayRange+1 ; j++)
{
if(poc < x[j])
{
poc=x[j]; pocj=j;}
else if(poc == x[j])
{
if (abs(midrange-j)< abs(midrange-pocj)){
poc = x[j]; pocj = j;
}
}

}

for ( n = 1; n <= relTodayRange; n++ )
{
total[n]=x[n]+total[n-1];
}

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
if(pocj-a>0 AND pocj+a<relTodayRange)
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
}
else if(pocj-a<1 )
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}
}
else if(pocj+a>relTodayRange )
{
if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}
}
}


if(ViewVpoc==1)
{
Virginpoc=basey+pocj*den;
newi=Null;
for( j = i; j <= (BarCount - 1) ; j++ )
if( L[j] < Virginpoc AND H[j]>Virginpoc )
{newi=j;break;}
else {newi=BarCount;}
Plot(LineArray(basex,basey+pocj*den,newi,basey+pocj*den),"",ParamColor("Virgin Poc Color",colorYellow),styleLine|styleNoRescale);
}

Vah = LineArray(baseX, baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX, baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex+poc,basey+pocj*den);


Vahn = LineArray(i, baseY+(pocj+shiftup)*den, i+t, baseY+(pocj+shiftup)*den);
pocn = LineArray(i, baseY+(pocj)*den, i+t, baseY+(pocj)*den);
Valn = LineArray(i, baseY+(pocj-shiftdn)*den, i+t, baseY+(pocj-shiftdn)*den);

Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);

if(ViewYvalues==1)
{
Plot(Vahn,"",ParamColor("YVAH",colorWhite),styleDashed|styleNoRescale);
Plot(Valn,"",ParamColor("YVAL",colorWhite),styleDashed|styleNoRescale);
Plot(pocn,"",ParamColor("YPOC",colorYellow),styleDashed|styleNoRescale);

}


if(ViewTPO==1)
{
nnn=HHV(H,BarsInDay);
PlotText(""+(total[relTodayRange]-total[pocj]),basex,nnn,colorLightGrey);
PlotText(""+(total[pocj-1]),basex,basey-den,colorLightGrey);


}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX,basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX,baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX,baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}


for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
if(P>0){
line = LineArray(baseX, baseY+(p)*Den, baseX+x[p], baseY+(p)*Den);
}
Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA", colorGrey40),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA", colorGrey40))) , EnMP2);
}


///////////////////

basex=0;
x=0;
Basex=i;
baseY=Bot;
relTodayRange=Range/Den;
Voloumeunit=Vol/LastValue(BarsInDay);

}

for (j=0; j<= relTodayRange ; j++)
{
if (L <= Bot+j*Den AND H >= Bot+j*Den )
{

if(Type=="Price Profile"){x[j]=(x[j])+x_scale;}
else if(Type=="Volume Profile"){x[j]=x[j]+round(V/Voloumeunit)+1;}

}
}
}

Col=ParamColor("IB Color",colorWhite);
IBstyle=ParamStyle("IB style",styleLine,maskAll);
if(EnIB==1)
{
IBH=HHV(H,IBBars);
IBL=LLV(L,IBBars);
Line1 = LineArray(basex, IBH[basex+IBBars-1],i, IBH[basex+IBBars-1]);
Plot(Line1,"",Col,IBstyle);
Line2 = LineArray(basex, IBL[basex+IBBars-1],i, IBL[basex+IBBars-1]);
Plot(Line2,"",Col,IBstyle);
}

//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;

for (j=1; j<= relTodayRange+1 ; j++)
{
if(poc < x[j])
{
poc=x[j]; pocj=j;}
else if(poc == x[j])
{
if (abs(midrange-j)< abs(midrange-pocj)){
poc = x[j]; pocj = j;
}
}

}

for ( n = 1; n <= relTodayRange; n++ )
{
total[n]=x[n]+total[n-1];
}

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
if(pocj-a>0 AND pocj+a<relTodayRange)
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
}
else if(pocj-a<1 )
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}
}
else if(pocj+a>relTodayRange )
{
if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}
}
}

Vah = LineArray(baseX, baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX, baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex+poc,basey+pocj*den);

if(ViewTPO==1)
{
PlotText(""+(total[relTodayRange]-total[pocj]),basex,top,colorLightGrey);
PlotText(""+(total[pocj-1]+x_scale),basex,basey-den,colorLightGrey);
}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX,basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX,baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX,baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}


for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
line = LineArray(baseX, baseY+p*Den, baseX+x[p], baseY+p*Den);

Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Color_Above_VA", colorGrey40),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA",colorGrey40))),EnMP2);
Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);

}

_SECTION_END();
 
Anantheist.. thanks for the AFL... but can you post any link which explains this AFL...
Hi sach007

My id is not Anantheist :lol: ...it's AnAtheist :cool:
i got this Afl and market profile method anther thread like TJ which is moderated by saint sir ...you can Google it.. you can get many post regarding this Method .....

And previous AFL is very clumsy so you can try this one ..... If you need more Afl on MP with various method i can post it ... but at the end Price only speaks what is right and what is wrong .. no indicator , system or AFL is 100 % perfect ....it's only a tool not holy girl.....

Regards
AnAtheist:)

_SECTION_BEGIN("MPLite");
PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorGreen,colorRed),styleCandle);
function Lastthursday()
{
Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,IIf(Daysinmonthfinal-Day()<8 AND DayOfWeek()==3 AND Ref(DayOfWeek(),1)!=4 AND Day()!=Daysinmonthfinal ,1,0));
return returnvalue;
}

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status( "LastVisibleBar" );

totalVisible=Lastvisiblebar-FirstVisibleBar;
//if(totalVisible<1500){

//Den = Param("Density", 1, 0.1, 10, 0.1);
percent=Param("Value Area", 70, 1, 100, 1);
Type=ParamList("Type","Price Profile|Volume Profile");
Period= ParamList("Base","Hourly|Daily|Weekly|Monthly|Last thursday|Yearly",1);
x_scale=Param("Horizontal_scale", 2, 0, 10, 0.1);
EnMP2= ParamStyle("Style",styleLine|styleNoLabel,maskAll) ;
styleLines=styleDots;
EnIB = ParamToggle("Show Initial Balance", "No|Yes",0);
IBBars = Param("Initial Balance Bars", 2, 1, 10, 1);
ViewYvalues= ParamToggle("Show Yesterdays Values", "No|Yes",1);
ViewVlines= ParamToggle("Show Vertical Base Lines", "No|Yes",1);
Viewvalues= ParamToggle("Show Values", "No|Yes",0);
ViewVpoc= ParamToggle("Show Virgin POC", "No|Yes",1);
ViewTPO=ParamToggle("Show TPO Count", "No|Yes",0);

if(Period=="Hourly"){
BarsInDay = BarsSince(Hour() != Ref(Hour(), -1));Bot = TimeFrameGetPrice("L", inHourly, 0);Top = TimeFrameGetPrice("H", inHourly, 0);Vol = TimeFrameGetPrice("V", inHourly, 0);
}
if(Period=="Daily" ){//OR Interval()==3600
BarsInDay = BarsSince(Day() != Ref(Day(), -1) ) ;Bot = TimeFrameGetPrice("L", inDaily, 0);Top = TimeFrameGetPrice("H", inDaily, 0);Vol = TimeFrameGetPrice("V", inDaily, 0);
}
if(Period=="Weekly" OR Interval()==24 * 3600 ){
BarsInDay = BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ));bot1=ValueWhen(BarsInDay==0,L,1);Bot2 = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);bot=Min(bot1,bot2);top1=ValueWhen(BarsInDay==0,H,1);Top2 =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);top=Max(top1,top2);Vol = TimeFrameGetPrice("V", inWeekly, 0);
}
if(Period=="Monthly" ){
BarsInDay = BarsSince(Month() != Ref(Month(), -1));Bot = TimeFrameGetPrice("L", inMonthly, 0);Top = TimeFrameGetPrice("H", inMonthly, 0);Vol = TimeFrameGetPrice("V", inMonthly, 0);
}
if(Period=="Lastthursday" ){
BarsInDay = BarsSince(Lastthursday()==0 AND Ref(Lastthursday(), -1)==1);bot1=ValueWhen(BarsInDay==0,L,1);Bot2 = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,LLV(L,BarsInDay),0);bot=Min(bot1,bot2);top1=ValueWhen(BarsInDay==0,H,1);Top2 =ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2,HHV(H,BarsInDay),0);top=Max(top1,top2);Vol = ValueWhen(Ref(BarsInDay,1)==1 OR BarIndex()>BarCount-2 ,Sum(V,BarsInDay),0);

}
if(Period=="Yearly" ){
BarsInDay = BarsSince(Year() != Ref(Year(), -1));Bot = TimeFrameGetPrice("L", inYearly, 0);Top = TimeFrameGetPrice("H", inYearly, 0);Vol = TimeFrameGetPrice("V", inYearly, 0);
}

CurTop = HHV(H,BarsInDay+1);
Curbot = LLV(L,BarsInDay+1);

Range = Top-Bot;
coverage=LastValue(Ref(ATR(10),-1));

den=(coverage/10);
//den=1;

multiplier=IIf(round(totalVisible)/300<1,1,round(totalVisible)/300);

if(ViewVlines==1)
{
Plot(BarsInDay==0, "", ParamColor("Base Line Color",colorDarkGrey), styleHistogram | styleOwnScale | styleLine | styleNoLabel);
}

relTodayRange = 0;
x=0;
basey=0;
basex=0;
newday=0;
total=0;
shiftup=0;
shiftdn=0;
Line=Null;
Voloumeunit=0;


for ( i = IIf(FirstVisibleBar-100>1,FirstVisibleBar-100,FirstVisibleBar); i <Lastvisiblebar AND i<BarCount-1 ; i++ )
{
if(BarsInDay==0)
{t=BarsInDay[i-1];

Col=ParamColor("IB Color",colorWhite);
IBstyle=ParamStyle("IB style",styleLine,maskAll);
if(EnIB==1)
{
IBH=HHV(H,IBBars);
IBL=LLV(L,IBBars);
Line1 = LineArray(basex, IBH[basex+IBBars-1],i, IBH[basex+IBBars-1]);
Plot(Line1,"",Col,IBstyle);
Line2 = LineArray(basex, IBL[basex+IBBars-1],i, IBL[basex+IBBars-1]);
Plot(Line2,"",Col,IBstyle);
}
//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;


for (j=1; j<= relTodayRange+1 ; j++)
{
if(poc < x[j])
{
poc=x[j]; pocj=j;}
else if(poc == x[j])
{
if (abs(midrange-j)< abs(midrange-pocj)){
poc = x[j]; pocj = j;
}
}

}

for ( n = 1; n <= relTodayRange; n++ )
{
total[n]=x[n]+total[n-1];
}

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
if(pocj-a>0 AND pocj+a<relTodayRange)
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
}
else if(pocj-a<1 )
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}
}
else if(pocj+a>relTodayRange )
{
if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}
}
}


if(ViewVpoc==1)
{
Virginpoc=basey+pocj*den;
newi=Null;
for( j = i; j <= (BarCount - 1) ; j++ )
if( L[j] < Virginpoc AND H[j]>Virginpoc )
{newi=j;break;}
else {newi=BarCount;}
Plot(LineArray(basex,basey+pocj*den,newi,basey+pocj*den),"",ParamColor ("Virgin Poc Color",colorYellow),styleLine|styleNoRescale);
}

Vah = LineArray(baseX, baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX, baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex+poc,basey+pocj*den);


Vahn = LineArray(i, baseY+(pocj+shiftup)*den, i+t, baseY+(pocj+shiftup)*den);
pocn = LineArray(i, baseY+(pocj)*den, i+t, baseY+(pocj)*den);
Valn = LineArray(i, baseY+(pocj-shiftdn)*den, i+t, baseY+(pocj-shiftdn)*den);

Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);

if(ViewYvalues==1)
{
Plot(Vahn,"",ParamColor("YVAH",colorWhite),styleDashed|styleNoRescale);
Plot(Valn,"",ParamColor("YVAL",colorWhite),styleDashed|styleNoRescale);
Plot(pocn,"",ParamColor("YPOC",colorYellow),styleDashed|styleNoRescale);

}


if(ViewTPO==1)
{
nnn=HHV(H,BarsInDay);
PlotText(""+(total[relTodayRange]-total[pocj]),basex,nnn,colorLightGrey);
PlotText(""+(total[pocj-1]),basex,basey-den,colorLightGrey);


}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX,basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX,baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey );
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX,baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}


for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
if(P>0){
line = LineArray(baseX, baseY+(p)*Den, baseX+x[p], baseY+(p)*Den);
}
Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Colo r_Above_VA", colorGrey40),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA", colorGrey40))) , EnMP2);
}


///////////////////

basex=0;
x=0;
Basex=i;
baseY=Bot;
relTodayRange=Range/Den;
Voloumeunit=Vol/LastValue(BarsInDay);

}

for (j=0; j<= relTodayRange ; j++)
{
if (L <= Bot+j*Den AND H >= Bot+j*Den )
{

if(Type=="Price Profile"){x[j]=(x[j])+x_scale;}
else if(Type=="Volume Profile"){x[j]=x[j]+round(V/Voloumeunit)+1;}

}
}
}

Col=ParamColor("IB Color",colorWhite);
IBstyle=ParamStyle("IB style",styleLine,maskAll);
if(EnIB==1)
{
IBH=HHV(H,IBBars);
IBL=LLV(L,IBBars);
Line1 = LineArray(basex, IBH[basex+IBBars-1],i, IBH[basex+IBBars-1]);
Plot(Line1,"",Col,IBstyle);
Line2 = LineArray(basex, IBL[basex+IBBars-1],i, IBL[basex+IBBars-1]);
Plot(Line2,"",Col,IBstyle);
}

//////////////////////////////////
poc=0;pocj=0;
midrange = int(relTodayRange/2)+1;

for (j=1; j<= relTodayRange+1 ; j++)
{
if(poc < x[j])
{
poc=x[j]; pocj=j;}
else if(poc == x[j])
{
if (abs(midrange-j)< abs(midrange-pocj)){
poc = x[j]; pocj = j;
}
}

}

for ( n = 1; n <= relTodayRange; n++ )
{
total[n]=x[n]+total[n-1];
}

Value_area=(total[relTodayRange]*percent)/100;


for ( a = 1; a <= relTodayRange; a++ )
{
if(pocj-a>0 AND pocj+a<relTodayRange)
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)]>=Value_area) {shiftup=a; shiftdn=a; break;}
}
else if(pocj-a<1 )
{
if(poc+total[pocj+a]-total[pocj]+(total[pocj]-poc)>=Value_area){shiftup=a; shiftdn=pocj; break;}
}
else if(pocj+a>relTodayRange )
{
if(poc+total[relTodayRange]-total[pocj]+(total[pocj]-poc)-total[pocj-(a+1)] >=Value_area){shiftup=floor(relTodayRange)-pocj; shiftdn=a+1; break;}
}
}

Vah = LineArray(baseX, baseY+(pocj+shiftup)*den, i, baseY+(pocj+shiftup)*den);
Val = LineArray(baseX, baseY+(pocj-shiftdn)*den, i, baseY+(pocj-shiftdn)*den);
pocline=LineArray(basex,basey+pocj*den,basex+poc,basey+pocj*den);

if(ViewTPO==1)
{
PlotText(""+(total[relTodayRange]-total[pocj]),basex,top,colorLightGrey);
PlotText(""+(total[pocj-1]+x_scale),basex,basey-den,colorLightGrey);
}

if(Viewvalues==1)
{
PlotText(""+((basey+pocj*den)),baseX,basey+pocj*den,colorWhite,colorDarkGrey);
PlotText(""+((baseY+(pocj+shiftup)*den)),baseX,baseY+(pocj+shiftup)*den,colorWhite,colorDarkGrey );
PlotText(""+((baseY+(pocj-shiftdn)*den)),baseX,baseY+(pocj-shiftdn)*den,colorWhite,colorDarkGrey);
}


for (p = 0; p <= relTodayRange+1; p=p+multiplier)
{
line = LineArray(baseX, baseY+p*Den, baseX+x[p], baseY+p*Den);

Plot(line,"",IIf(p>(pocj+shiftup),ParamColor("Colo r_Above_VA", colorGrey40),IIf(p<=(pocj+shiftup)AND p>=(pocj-shiftdn),ParamColor("Color_VA", colorBlueGrey),ParamColor("Color_Below_VA",colorGrey40))),EnMP2);
Plot(pocline,"",ParamColor("Color_POC_Line",colorYellow),styleLine|styleNoRescale|styleNoLabel);

}

_SECTION_END();
 
Hello,
Can any one please change the lookback from 1 day to last 3 days so that it will show the VAH, VAL, POC for last three days in MPLite.afl.
Thanks in advance.
 
Hi sach007

My id is not Anantheist :lol: ...it's AnAtheist :cool:
i got this Afl and market profile method anther thread like TJ which is moderated by saint sir ...you can Google it.. you can get many post regarding this Method .....

And previous AFL is very clumsy so you can try this one ..... If you need more Afl on MP with various method i can post it ... but at the end Price only speaks what is right and what is wrong .. no indicator , system or AFL is 100 % perfect ....it's only a tool not holy girl.....

Regards
AnAtheist:)

Could you pl. disclose the name of the board moderated by Saint?
 
Hi sach007

My id is not Anantheist :lol: ...it's AnAtheist :cool:
i got this Afl and market profile method anther thread like TJ which is moderated by saint sir ...you can Google it.. you can get many post regarding this Method .....

And previous AFL is very clumsy so you can try this one ..... If you need more Afl on MP with various method i can post it ... but at the end Price only speaks what is right and what is wrong .. no indicator , system or AFL is 100 % perfect ....it's only a tool not holy girl.....

Regards
AnAtheist:)

Could you pl. disclose the name of the board moderated by Saint?

Sorry Bro :(

Saint sir closed the forum for some unknown reason.... :confused:
 

Similar threads