Great afl but needs correction pls

jsb2012

Active Member
#1
_SECTION_BEGIN("MarketProfile+OR+FPSR bold_POC+IB");
//------------------------------------------------------------------------------
//
// Formula Name: Market Profile
//
// Use with 5/15min chart
// Originial - From AFL library
// Edited by - Milind

//Market Profile


Den = Param("Density", 1, 0.25, 100, 0.25); // Resolution in terms of $
IBBars = Param("Initial Balance Bars", 2, 0, 5, 1);
EnIB = Param("Show Initial Balance", 1, 0, 1, 1);
EnMP = Param("Show Market Profile", 1, 0, 2, 1);

PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorAqua,colorRe d),styleCandle|styleThick|styleNoLabel);

BarsInDay = BarsSince(Day() != Ref(Day(), -1));
Bot = TimeFrameGetPrice("L", inDaily, 0);
Top = TimeFrameGetPrice("H", inDaily, 0);
Vol = TimeFrameGetPrice("V", inDaily, 0);
POC = H - H;
VAL = H - H;
VAH = H - H;
CurTop = HHV(H,BarsInDay+1);
Curbot = LLV(L,BarsInDay+1);
Range = Highest(Top-Bot);
TodayRange = Top - Bot;

AveRange = Sum(Top-Bot,30)/30;
LAveRange = AveRange[BarCount-1];
if (LAveRange < 1) {Den = 0.05;}
else if (LAveRange < 10) {Den = 0.25;}
else if (LAveRange < 20) {Den = 0.5;}
else if (LAveRange < 100) {Den = 1;}
else if (LAveRange < 500) {Den = 5;}
else {Den = 1;}

// Initialization
baseX = 0;
baseY = floor(Bot[0]/Den)*Den;
relTodayRange = 0;
firstVisBar = Status("firstvisiblebar");
lastVisBar = Status("lastvisiblebar");

D=.000125;

for (j=0; j <= 100; j++) {
x[j] = 0;
}

i0 = 0;
i1 = 0;
for (i=0; i<BarCount; i++) {
if (BarsInDay == 0 AND i < firstVisBar) {
i0 = i;
}
if (BarsInDay == 0 AND i >= lastVisBar) {
i1 = i;
}
}

i1 = BarCount-1;
for (i=i0; i<=i1; i++) {
if (BarsInDay == 0) {
baseX = i;
baseY = floor(Bot/Den)*Den;
maxY = floor(Top/Den)*Den;
relTodayRange = (maxY-baseY)/Den;

for (j=0; j <= relTodayRange; j++) {
x[j] = 0;
}
}

if (EnMP == 2) {
for (j=0; j<= relTodayRange; j++) {
if (L <= baseY+j*Den AND H >= baseY+j*Den) {
PlotText(StrExtract("A,B,C,D,E,F,G,H,I,J,K,L,M,N",
BarsInDay), baseX+x[j], baseY+j*Den, colorBlack);
x[j]++;
}
}
}
else if (EnMP == 1) {
for (j=0; j<= relTodayRange; j++) {
if (L <= baseY+j*Den AND H >= baseY+j*Den) {
line = LineArray(baseX, baseY+j*Den, baseX+x[j]+1, baseY+j*Den);
Plot(line,"",ParamColor("Color", colorCustom12), styleLine+styleDots|styleNoLabel);
x[j]++;
}
}
}

// Draw Initial Balance after 11am bar is complete
if (BarsInDay == IBBars+1 AND EnIB == 1) {
Linex = LineArray(i-2, curtop[i-1],i+10, curtop[i-1],0,True);
//Line1a=Line1+d*Line1;
//Line1b=Line1-d*Line1;
//Plot(Line1,"",colorBlue,styleDots+styleThick|style NoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styl eNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styl eNoLabel);


Liney = LineArray(i-2, curbot[i-1],i+10, curbot[i-1],0,True);
//Line1a=Line1+d*Line1;
//Line1b=Line1-d*Line1;
//Plot(Line1,"",colorBlue,styleDots+styleThick|style NoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styl eNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styl eNoLabel);
PlotOHLC(Linex,Linex,Liney,Liney,"",colorBlue,styl eCloud);

}

// Examine x[j]
if ((i < BarCount - 1 AND BarsInDay[i+1] == 0) OR i == BarCount-1) {
maxXj = 0;
for (j=0; j<= relTodayRange; j++) {
if (maxXj < x[j]) {maxXj = x[j]; maxj = j;}
}
for (k=i-BarsInDay;k<=i;k++) {
POC[k] = baseY+Maxj*Den;
}
Line1 = LineArray(baseX, baseY+maxj*Den, i, baseY+maxj*Den,0,True);
Line1a=Line1+d*Line1;
Line1b=Line1-d*Line1;
Plot(Line1,"",colorWhite,styleDots+styleThick);
Plot(Line1a,"",colorWhite,styleDots+styleThick|sty leNoLabel);
Plot(Line1b,"",colorWhite,styleDots+styleThick|sty leNoLabel);

}
}

//Plot(POC,"POC",colorWhite,styleDots);
_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | styleHidden |styleNoLabel| styleBar| GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("ORBO 10mt");
priceTitle=EncodeColor(colorYellow)+ StrFormat(" {{NAME}} -- {{INTERVAL}}" ) + "\n"+ EncodeColor(colorCustom11)+
"Date = " + Date() ;
ToolTip=StrFormat(" Close = %g (%.1f%%)",C,SelectedValue( ROC( C, 1 ) ));
Title ="DHIRAJ" + priceTitle + "\n" + EncodeColor(colorWhite) + ToolTip;


breakoutime = 100500;
afterbreakout0 = Cross(TimeNum(),100500);
afterbreakout1 = TimeNum()>=100500;
NewDay = Day()!= Ref(Day(), -1);
highestoftheday = HighestSince(newday,H,1);
Lowestoftheday =LowestSince(newday,L,1);
ORBHigh = ValueWhen(afterbreakout0,highestoftheday,1);
ORBLow = ValueWhen(afterbreakout0,lowestoftheday,1);
buycandidate =Cross(C,orblow) AND afterbreakout1;
sellcandidate = Cross(orbhigh,C) AND afterbreakout1 ;

BuyCond2 = Cross(C, WMA((L+C+H)/3,9)+0.01);/*((MidMA, LongMA);*/
SellCond4=Cross( WMA((L+C+H)/3,9)+0.01,C);
Buy1 = BuyCond2;
Sell1 = SellCond4 ;
entryprice=WMA((L+C+H)/3,9)+0.01;
ENTRYSELL=WMA((L+C+H)/3,9)-0.01;

Buy= Cross(C,orbhigh) AND afterbreakout1;
Sell = Cross(orblow,C) AND afterbreakout1;
color = IIf(Buy,colorGreen,IIf(Sell,colorRed,IIf(buycandid ate,colorBlue,IIf(sellcandidate,colorPink,0))));


Plot(C,"",colorYellow,styleBar);
PlotShapes( shapeUpArrow * Buy, colorGreen,0,L,-12);
PlotShapes( shapeDownArrow * Sell, colorRed,0,H,-12);
//Plot(afterbreakout0,"",colorBlue,styleHistogram|st yleOwnScale);

StyleOR=styleNoLine|styleDots+styleThick|styleNoLa bel;

//Plot(ORBHigh,"RESISTENCE",colorGreen,StyleOR);
//Plot(ORBLow,"SUPPORT",colorRed,StyleOR);
PlotOHLC(ORBHigh,ORBHigh,ORBLow,ORBLow,"",colorDar kBlue,styleCloud);

Filter = Buy OR Sell OR sellcandidate OR buycandidate OR Buy1 OR Sell1;


//Filter = Buy OR Sell OR sellcandidate OR buycandidate;
AddColumn(C,"CMP",0,colorBlue);
AddColumn(IIf(Buy OR sellcandidate,ORBHigh,ORBLow),"INTRA ",0,colorDefault,color);
AddColumn(IIf(Buy1,entryprice,ENTRYSELL),"DELIVERY ",0,colorDefault,IIf(Buy1,colorGreen, colorRed));

_SECTION_END();

_SECTION_BEGIN("Weekly MP");
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",colorTurquoise), styleNoTitle | styleBar | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("Market Profile");
//Market Profile
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);

//===========================

Den = Param("Density", 200, 10, 300, 10);
ShowMP = ParamToggle("Show MP", "No|Yes");
ShowVP = ParamToggle("Show VP", "No|Yes");
StyleMP = ParamStyle("style MP", styleLine|styleDots, maskAll);
StyleVP = ParamStyle("style VP", styleLine|styleDots, maskAll);

//===========================

//===========================
BarsInDay =BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ))+1;

//===========================
NewDay = DayOfWeek() > Ref( DayOfWeek(),1) OR Cum(1) == BarCount;

//===========================
Bot = TimeFrameGetPrice("L", inWeekly, 0);
Top = TimeFrameGetPrice("H", inWeekly, 0);
Vol = TimeFrameGetPrice("V", inWeekly, 0);

//===========================

Range = Highest(Top-Bot);
Box = Range/Den;
VolumeUnit = Vol/BarsInDay;

for (k = 0; k < Den; k++) // loop through each line (price) starting at the Lowest price
{
Line = Bot + k*Box;
detect = Line >= L & Line <= H;

if(ShowMP == True)
{
CountMPString = IIf(NewDay, Sum(detect, BarsInDay), 0);
CountMPString = Ref(ValueWhen(NewDay, CountMPString, 0), -1);
MpLine = IIf(CountMPString >= BarsInDay, Line, Null);

Plot(MPLine, "", colorGreen , styleMP);
}

if(ShowVP == True)
{
CountVPString = IIf(NewDay, Sum(detect*V, BarsInDay)/VolumeUnit, 0);
CountVPString = Ref(ValueWhen(NewDay, CountVPString, 0), -1);
VpLine = IIf(CountVPString >= BarsInDay, Line + Box/4, Null);
// Plot()
Plot(VPLine, "", colorBlue, styleVP);
}
}

Title = "{{NAME}} - {{INTERVAL}} {{DATE}} {{VALUES}} - \\c04 Market Profile \\c06 Volume Profile";
_SECTION_END();

_SECTION_BEGIN("Price+FPSR+ZG+WW+StoDiv+CCI+");
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", colorPink ), styleNoTitle | styleBar );




////////////////////////////////////////////////// DP TOGGLE ///////////////////////////////////////////////////////




Show_Prev = ParamToggle( "Display Pivots", "No|Yes", 1);

// Get Previous Day's close, Low and High
DayC=Prev_Close = TimeFrameGetPrice( "C", inDaily, -1, expandFirst) ;
DayL=Prev_Low = TimeFrameGetPrice( "L", inDaily, -1, expandFirst) ;
DayH=Prev_High = TimeFrameGetPrice( "H", inDaily, -1, expandFirst) ;
Today = LastValue(Day( ) );
P = (Prev_High + Prev_Low + Prev_Close)/ 3;


R6 = (DayH / DayL) * DayC * 1.002;
R5 = (DayH / DayL) * DayC;
R4 = (((DayH / DayL) + 0.83) / 1.83) * DayC;
R3 = ( ( (DayH / DayL) + 2.66) / 3.66) * DayC;
R2 = ( ( (DayH / DayL) + 4.5) / 5.5) * DayC;
R1 = ( ( (DayH / DayL) + 10) / 11) * DayC;

S1 = (2- ( ( (DayH / DayL) + 10) / 11)) * DayC;
S2 = (2-( (DayH / DayL) + 4.5) / 5.5) * DayC;
S3 = (2-(( DayH / DayL) + 2.66) / 3.66) * DayC;
S4 = (2-( (DayH / DayL) + 0.83) / 1.83) * DayC;
S5 = (2-( DayH / DayL)) * DayC;
S6 = (2-( DayH / DayL)) * DayC * 0.998;
////////////////////////////// FPSR 30 MT STRATEGY /////////////////////////////////////////////////////////////

//TimeFrameSet( inDaily );

BS=(Prev_High-Prev_Low)/3;
Y=Prev_Close+BS;
X=Prev_Close-BS;


MULT=0.0003;


YT=Y+MULT*Y;
YB=Y-MULT*Y;

XT=X+MULT*X;
XB=X-MULT*X;


//PlotOHLC( 0, Prev_High ,Prev_Low ,Prev_Low, "", HLColor, styleCloud|styleNoLabel);
HLColor = colorPaleBlue;

if(Show_Prev)
{Plot(IIf(Today == Day(),R5, Null), "R5", ParamColor("R5", colorLightBlue),styleDashed|styleThick|styleNoResc ale);
Plot(IIf(Today == Day(),R4, Null), "R4", ParamColor("R4",colorLightBlue),styleDots|styleThi ck|styleNoRescale);
Plot(IIf(Today == Day(),R3, Null), "R3", ParamColor("R3",colorLightBlue),styleDots|styleThi ck|styleNoRescale);
//Plot(IIf(Today == Day(),R2, Null), "R2", ParamColor("R2", colorBlack),styleDots|styleThick|styleNoRescale|st yleNoLabel);
//Plot(IIf(Today == Day(),R1, Null), "R1", ParamColor("R1",colorBlack),styleDots|styleThick|s tyleNoRescale|styleNoLabel);
//Plot(IIf(Today == Day(),P, Null), "P", ParamColor("P",colorYellow),styleDots|styleThick|s tyleNoRescale);
//Plot(IIf(Today == Day(),S1, Null), "S1", ParamColor("S1", colorBlack),styleDots|styleThick|styleNoRescale|st yleNoLabel);
//Plot(IIf(Today == Day(),S2, Null), "S2", ParamColor("S2",colorBlack),styleDots|styleThick|s tyleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),S3, Null), "S3", ParamColor("S3",colorBrightGreen),styleDots|styleT hick|styleNoRescale);
Plot(IIf(Today == Day(),S4, Null), "S4", ParamColor("S4", colorBrightGreen),styleDots|styleThick|styleNoResc ale );
Plot(IIf(Today == Day(),S5, Null), "S5", ParamColor("S5", colorBrightGreen),styleDashed|styleThick|styleNoRe scale);



//Plot(IIf(Today == Day(), Prev_High, Null), "Prev_High", ParamColor(" Prev_High", HLColor),styleDashed|styleThick|styleNoRescale );
//Plot(IIf(Today == Day(), Prev_Low, Null), "Prev_Low", ParamColor(" Prev_Low", HLColor),styleDashed|styleThick|styleNoRescale );
}




////////////////////////////// DAY HILO SHADOW /////////////////////////////////////////////////////////////


BSColor = ColorRGB(80,80,80);
HLColor = ColorRGB(20,20,40);
//PlotOHLC( 0, Prev_High ,Prev_Low ,Prev_Low, "", HLColor, styleCloud|styleNoLabel);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////// DOUBLE TOP //////////////////////////////////////////


/* Detecting double tops */
percdiff = 5; /* peak detection threshold */
fwdcheck = 5; /* forward validity check */
mindistance = 10;
validdiff = percdiff/400;
PK= Peak( H, percdiff, 1 ) == High;

x = Cum( 1 );
XPK1 = ValueWhen( PK, x, 1 );
XPK2 = ValueWhen( PK, x, 2 );

peakdiff = ValueWhen( PK, H, 1 )/ValueWhen( PK, H, 2 );
doubletop = PK AND abs( peakdiff - 1 ) < validdiff AND (XPK1 - XPK2)>mindistance AND High > HHV( Ref( H, fwdcheck ), fwdcheck - 1 );
SellDT = doubletop;
Buy = 0;
//Filter=SellDT;
WriteIf( Highest( doubletop ) == 1, "AmiBroker has detected some possible
double top patterns for " + name() + "\nLook for green arrows on the price
chart.", "There are no double top patterns for " + name() );



PlotShapes(SellDT*shapeHollowDownTriangle,colorPin k, 0, High, Offset =-25);
PlotShapes(SellDT*shapeDigit0,colorPink, 0, High, Offset =40);
PlotShapes(SellDT*shapeDigit0,colorPink, 0, High, Offset =50);


////////////_SECTION_BEGIN("Volume At Price");
PlotVAPOverlay( Param("Lines", 300, 100, 1000, 1 ), Param("Width", 5, 1, 100, 1 ), ParamColor("Color", colorLightBlue ), ParamToggle("Side", "Left|Right" ) | 4*ParamToggle("Z-order", "On top|Behind", 1 ) );

_SECTION_END();

_SECTION_BEGIN("VOLUME_Hight of Volume Bars Control");


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

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

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

VolScale = Param("1/Vol. Height (TimeBar chart)(fraction of
window) 5=1/5=20%",10, 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("DispMA");

_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", Null ), styleNoTitle | styleCandle );

P = ParamField("Field");
Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted");
//Periods = Param("Periods", 30, 2, 300 );
//Displacement = Param("Displacement", 4, -50, 50 );
//m = 0;

//if( Type == "Simple" )
A = MA( H,6 );
B = MA( L,6 );


x= Ref(A,-4);
y= Ref(B,-4);

D=.0003;
xt=x+x*D;
xb=x-x*D;

yt=y+y*D;
yb=y-y*D;

PlotOHLC( 0,xt,xb,xb ,"",ColorRGB(70,10,10), styleCloud);

PlotOHLC( 0,yt,yb,yb ,"",ColorRGB(10,70,10), styleCloud);

_SECTION_END();
 
#3
_SECTION_BEGIN("MarketProfile+OR+FPSR bold_POC+IB");
//------------------------------------------------------------------------------
//
// Formula Name: Market Profile
//
// Use with 5/15min chart
// Originial - From AFL library
// Edited by - Milind

//Market Profile


Den = Param("Density", 1, 0.25, 100, 0.25); // Resolution in terms of $
IBBars = Param("Initial Balance Bars", 2, 0, 5, 1);
EnIB = Param("Show Initial Balance", 1, 0, 1, 1);
EnMP = Param("Show Market Profile", 1, 0, 2, 1);

PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorAqua,colorRe d),styleCandle|styleThick|styleNoLabel);

BarsInDay = BarsSince(Day() != Ref(Day(), -1));
Bot = TimeFrameGetPrice("L", inDaily, 0);
Top = TimeFrameGetPrice("H", inDaily, 0);
Vol = TimeFrameGetPrice("V", inDaily, 0);
POC = H - H;
VAL = H - H;
VAH = H - H;
CurTop = HHV(H,BarsInDay+1);
Curbot = LLV(L,BarsInDay+1);
Range = Highest(Top-Bot);
TodayRange = Top - Bot;

AveRange = Sum(Top-Bot,30)/30;
LAveRange = AveRange[BarCount-1];
if (LAveRange < 1) {Den = 0.05;}
else if (LAveRange < 10) {Den = 0.25;}
else if (LAveRange < 20) {Den = 0.5;}
else if (LAveRange < 100) {Den = 1;}
else if (LAveRange < 500) {Den = 5;}
else {Den = 1;}

// Initialization
baseX = 0;
baseY = floor(Bot[0]/Den)*Den;
relTodayRange = 0;
firstVisBar = Status("firstvisiblebar");
lastVisBar = Status("lastvisiblebar");

D=.000125;

for (j=0; j <= 100; j++) {
x[j] = 0;
}

i0 = 0;
i1 = 0;
for (i=0; i<BarCount; i++) {
if (BarsInDay == 0 AND i < firstVisBar) {
i0 = i;
}
if (BarsInDay == 0 AND i >= lastVisBar) {
i1 = i;
}
}

i1 = BarCount-1;
for (i=i0; i<=i1; i++) {
if (BarsInDay == 0) {
baseX = i;
baseY = floor(Bot/Den)*Den;
maxY = floor(Top/Den)*Den;
relTodayRange = (maxY-baseY)/Den;

for (j=0; j <= relTodayRange; j++) {
x[j] = 0;
}
}

if (EnMP == 2) {
for (j=0; j<= relTodayRange; j++) {
if (L <= baseY+j*Den AND H >= baseY+j*Den) {
PlotText(StrExtract("A,B,C,D,E,F,G,H,I,J,K,L,M,N",
BarsInDay), baseX+x[j], baseY+j*Den, colorBlack);
x[j]++;
}
}
}
else if (EnMP == 1) {
for (j=0; j<= relTodayRange; j++) {
if (L <= baseY+j*Den AND H >= baseY+j*Den) {
line = LineArray(baseX, baseY+j*Den, baseX+x[j]+1, baseY+j*Den);
Plot(line,"",ParamColor("Color", colorCustom12), styleLine+styleDots|styleNoLabel);
x[j]++;
}
}
}

// Draw Initial Balance after 11am bar is complete
if (BarsInDay == IBBars+1 AND EnIB == 1) {
Linex = LineArray(i-2, curtop[i-1],i+10, curtop[i-1],0,True);
//Line1a=Line1+d*Line1;
//Line1b=Line1-d*Line1;
//Plot(Line1,"",colorBlue,styleDots+styleThick|style NoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styl eNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styl eNoLabel);


Liney = LineArray(i-2, curbot[i-1],i+10, curbot[i-1],0,True);
//Line1a=Line1+d*Line1;
//Line1b=Line1-d*Line1;
//Plot(Line1,"",colorBlue,styleDots+styleThick|style NoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styl eNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styl eNoLabel);
PlotOHLC(Linex,Linex,Liney,Liney,"",colorBlue,styl eCloud);

}

// Examine x[j]
if ((i < BarCount - 1 AND BarsInDay[i+1] == 0) OR i == BarCount-1) {
maxXj = 0;
for (j=0; j<= relTodayRange; j++) {
if (maxXj < x[j]) {maxXj = x[j]; maxj = j;}
}
for (k=i-BarsInDay;k<=i;k++) {
POC[k] = baseY+Maxj*Den;
}
Line1 = LineArray(baseX, baseY+maxj*Den, i, baseY+maxj*Den,0,True);
Line1a=Line1+d*Line1;
Line1b=Line1-d*Line1;
Plot(Line1,"",colorWhite,styleDots+styleThick);
Plot(Line1a,"",colorWhite,styleDots+styleThick|sty leNoLabel);
Plot(Line1b,"",colorWhite,styleDots+styleThick|sty leNoLabel);

}
}

//Plot(POC,"POC",colorWhite,styleDots);
_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | styleHidden |styleNoLabel| styleBar| GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("ORBO 10mt");
priceTitle=EncodeColor(colorYellow)+ StrFormat(" {{NAME}} -- {{INTERVAL}}" ) + "\n"+ EncodeColor(colorCustom11)+
"Date = " + Date() ;
ToolTip=StrFormat(" Close = %g (%.1f%%)",C,SelectedValue( ROC( C, 1 ) ));
Title ="DHIRAJ" + priceTitle + "\n" + EncodeColor(colorWhite) + ToolTip;


breakoutime = 100500;
afterbreakout0 = Cross(TimeNum(),100500);
afterbreakout1 = TimeNum()>=100500;
NewDay = Day()!= Ref(Day(), -1);
highestoftheday = HighestSince(newday,H,1);
Lowestoftheday =LowestSince(newday,L,1);
ORBHigh = ValueWhen(afterbreakout0,highestoftheday,1);
ORBLow = ValueWhen(afterbreakout0,lowestoftheday,1);
buycandidate =Cross(C,orblow) AND afterbreakout1;
sellcandidate = Cross(orbhigh,C) AND afterbreakout1 ;

BuyCond2 = Cross(C, WMA((L+C+H)/3,9)+0.01);/*((MidMA, LongMA);*/
SellCond4=Cross( WMA((L+C+H)/3,9)+0.01,C);
Buy1 = BuyCond2;
Sell1 = SellCond4 ;
entryprice=WMA((L+C+H)/3,9)+0.01;
ENTRYSELL=WMA((L+C+H)/3,9)-0.01;

Buy= Cross(C,orbhigh) AND afterbreakout1;
Sell = Cross(orblow,C) AND afterbreakout1;
color = IIf(Buy,colorGreen,IIf(Sell,colorRed,IIf(buycandid ate,colorBlue,IIf(sellcandidate,colorPink,0))));


Plot(C,"",colorYellow,styleBar);
PlotShapes( shapeUpArrow * Buy, colorGreen,0,L,-12);
PlotShapes( shapeDownArrow * Sell, colorRed,0,H,-12);
//Plot(afterbreakout0,"",colorBlue,styleHistogram|st yleOwnScale);

StyleOR=styleNoLine|styleDots+styleThick|styleNoLa bel;

//Plot(ORBHigh,"RESISTENCE",colorGreen,StyleOR);
//Plot(ORBLow,"SUPPORT",colorRed,StyleOR);
PlotOHLC(ORBHigh,ORBHigh,ORBLow,ORBLow,"",colorDar kBlue,styleCloud);

Filter = Buy OR Sell OR sellcandidate OR buycandidate OR Buy1 OR Sell1;


//Filter = Buy OR Sell OR sellcandidate OR buycandidate;
AddColumn(C,"CMP",0,colorBlue);
AddColumn(IIf(Buy OR sellcandidate,ORBHigh,ORBLow),"INTRA ",0,colorDefault,color);
AddColumn(IIf(Buy1,entryprice,ENTRYSELL),"DELIVERY ",0,colorDefault,IIf(Buy1,colorGreen, colorRed));

_SECTION_END();

_SECTION_BEGIN("Weekly MP");
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",colorTurquoise), styleNoTitle | styleBar | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("Market Profile");
//Market Profile
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);

//===========================

Den = Param("Density", 200, 10, 300, 10);
ShowMP = ParamToggle("Show MP", "No|Yes");
ShowVP = ParamToggle("Show VP", "No|Yes");
StyleMP = ParamStyle("style MP", styleLine|styleDots, maskAll);
StyleVP = ParamStyle("style VP", styleLine|styleDots, maskAll);

//===========================

//===========================
BarsInDay =BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ))+1;

//===========================
NewDay = DayOfWeek() > Ref( DayOfWeek(),1) OR Cum(1) == BarCount;

//===========================
Bot = TimeFrameGetPrice("L", inWeekly, 0);
Top = TimeFrameGetPrice("H", inWeekly, 0);
Vol = TimeFrameGetPrice("V", inWeekly, 0);

//===========================

Range = Highest(Top-Bot);
Box = Range/Den;
VolumeUnit = Vol/BarsInDay;

for (k = 0; k < Den; k++) // loop through each line (price) starting at the Lowest price
{
Line = Bot + k*Box;
detect = Line >= L & Line <= H;

if(ShowMP == True)
{
CountMPString = IIf(NewDay, Sum(detect, BarsInDay), 0);
CountMPString = Ref(ValueWhen(NewDay, CountMPString, 0), -1);
MpLine = IIf(CountMPString >= BarsInDay, Line, Null);

Plot(MPLine, "", colorGreen , styleMP);
}

if(ShowVP == True)
{
CountVPString = IIf(NewDay, Sum(detect*V, BarsInDay)/VolumeUnit, 0);
CountVPString = Ref(ValueWhen(NewDay, CountVPString, 0), -1);
VpLine = IIf(CountVPString >= BarsInDay, Line + Box/4, Null);
// Plot()
Plot(VPLine, "", colorBlue, styleVP);
}
}

Title = "{{NAME}} - {{INTERVAL}} {{DATE}} {{VALUES}} - \\c04 Market Profile \\c06 Volume Profile";
_SECTION_END();

_SECTION_BEGIN("Price+FPSR+ZG+WW+StoDiv+CCI+");
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", colorPink ), styleNoTitle | styleBar );




////////////////////////////////////////////////// DP TOGGLE ///////////////////////////////////////////////////////




Show_Prev = ParamToggle( "Display Pivots", "No|Yes", 1);

// Get Previous Day's close, Low and High
DayC=Prev_Close = TimeFrameGetPrice( "C", inDaily, -1, expandFirst) ;
DayL=Prev_Low = TimeFrameGetPrice( "L", inDaily, -1, expandFirst) ;
DayH=Prev_High = TimeFrameGetPrice( "H", inDaily, -1, expandFirst) ;
Today = LastValue(Day( ) );
P = (Prev_High + Prev_Low + Prev_Close)/ 3;


R6 = (DayH / DayL) * DayC * 1.002;
R5 = (DayH / DayL) * DayC;
R4 = (((DayH / DayL) + 0.83) / 1.83) * DayC;
R3 = ( ( (DayH / DayL) + 2.66) / 3.66) * DayC;
R2 = ( ( (DayH / DayL) + 4.5) / 5.5) * DayC;
R1 = ( ( (DayH / DayL) + 10) / 11) * DayC;

S1 = (2- ( ( (DayH / DayL) + 10) / 11)) * DayC;
S2 = (2-( (DayH / DayL) + 4.5) / 5.5) * DayC;
S3 = (2-(( DayH / DayL) + 2.66) / 3.66) * DayC;
S4 = (2-( (DayH / DayL) + 0.83) / 1.83) * DayC;
S5 = (2-( DayH / DayL)) * DayC;
S6 = (2-( DayH / DayL)) * DayC * 0.998;
////////////////////////////// FPSR 30 MT STRATEGY /////////////////////////////////////////////////////////////

//TimeFrameSet( inDaily );

BS=(Prev_High-Prev_Low)/3;
Y=Prev_Close+BS;
X=Prev_Close-BS;


MULT=0.0003;


YT=Y+MULT*Y;
YB=Y-MULT*Y;

XT=X+MULT*X;
XB=X-MULT*X;


//PlotOHLC( 0, Prev_High ,Prev_Low ,Prev_Low, "", HLColor, styleCloud|styleNoLabel);
HLColor = colorPaleBlue;

if(Show_Prev)
{Plot(IIf(Today == Day(),R5, Null), "R5", ParamColor("R5", colorLightBlue),styleDashed|styleThick|styleNoResc ale);
Plot(IIf(Today == Day(),R4, Null), "R4", ParamColor("R4",colorLightBlue),styleDots|styleThi ck|styleNoRescale);
Plot(IIf(Today == Day(),R3, Null), "R3", ParamColor("R3",colorLightBlue),styleDots|styleThi ck|styleNoRescale);
//Plot(IIf(Today == Day(),R2, Null), "R2", ParamColor("R2", colorBlack),styleDots|styleThick|styleNoRescale|st yleNoLabel);
//Plot(IIf(Today == Day(),R1, Null), "R1", ParamColor("R1",colorBlack),styleDots|styleThick|s tyleNoRescale|styleNoLabel);
//Plot(IIf(Today == Day(),P, Null), "P", ParamColor("P",colorYellow),styleDots|styleThick|s tyleNoRescale);
//Plot(IIf(Today == Day(),S1, Null), "S1", ParamColor("S1", colorBlack),styleDots|styleThick|styleNoRescale|st yleNoLabel);
//Plot(IIf(Today == Day(),S2, Null), "S2", ParamColor("S2",colorBlack),styleDots|styleThick|s tyleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),S3, Null), "S3", ParamColor("S3",colorBrightGreen),styleDots|styleT hick|styleNoRescale);
Plot(IIf(Today == Day(),S4, Null), "S4", ParamColor("S4", colorBrightGreen),styleDots|styleThick|styleNoResc ale );
Plot(IIf(Today == Day(),S5, Null), "S5", ParamColor("S5", colorBrightGreen),styleDashed|styleThick|styleNoRe scale);



//Plot(IIf(Today == Day(), Prev_High, Null), "Prev_High", ParamColor(" Prev_High", HLColor),styleDashed|styleThick|styleNoRescale );
//Plot(IIf(Today == Day(), Prev_Low, Null), "Prev_Low", ParamColor(" Prev_Low", HLColor),styleDashed|styleThick|styleNoRescale );
}




////////////////////////////// DAY HILO SHADOW /////////////////////////////////////////////////////////////


BSColor = ColorRGB(80,80,80);
HLColor = ColorRGB(20,20,40);
//PlotOHLC( 0, Prev_High ,Prev_Low ,Prev_Low, "", HLColor, styleCloud|styleNoLabel);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////// DOUBLE TOP //////////////////////////////////////////


/* Detecting double tops */
percdiff = 5; /* peak detection threshold */
fwdcheck = 5; /* forward validity check */
mindistance = 10;
validdiff = percdiff/400;
PK= Peak( H, percdiff, 1 ) == High;

x = Cum( 1 );
XPK1 = ValueWhen( PK, x, 1 );
XPK2 = ValueWhen( PK, x, 2 );

peakdiff = ValueWhen( PK, H, 1 )/ValueWhen( PK, H, 2 );
doubletop = PK AND abs( peakdiff - 1 ) < validdiff AND (XPK1 - XPK2)>mindistance AND High > HHV( Ref( H, fwdcheck ), fwdcheck - 1 );
SellDT = doubletop;
Buy = 0;
//Filter=SellDT;
WriteIf( Highest( doubletop ) == 1, "AmiBroker has detected some possible
double top patterns for " + name() + "\nLook for green arrows on the price
chart.", "There are no double top patterns for " + name() );



PlotShapes(SellDT*shapeHollowDownTriangle,colorPin k, 0, High, Offset =-25);
PlotShapes(SellDT*shapeDigit0,colorPink, 0, High, Offset =40);
PlotShapes(SellDT*shapeDigit0,colorPink, 0, High, Offset =50);


////////////_SECTION_BEGIN("Volume At Price");
PlotVAPOverlay( Param("Lines", 300, 100, 1000, 1 ), Param("Width", 5, 1, 100, 1 ), ParamColor("Color", colorLightBlue ), ParamToggle("Side", "Left|Right" ) | 4*ParamToggle("Z-order", "On top|Behind", 1 ) );

_SECTION_END();

_SECTION_BEGIN("VOLUME_Hight of Volume Bars Control");


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

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

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

VolScale = Param("1/Vol. Height (TimeBar chart)(fraction of
window) 5=1/5=20%",10, 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("DispMA");

_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", Null ), styleNoTitle | styleCandle );

P = ParamField("Field");
Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted");
//Periods = Param("Periods", 30, 2, 300 );
//Displacement = Param("Displacement", 4, -50, 50 );
//m = 0;

//if( Type == "Simple" )
A = MA( H,6 );
B = MA( L,6 );


x= Ref(A,-4);
y= Ref(B,-4);

D=.0003;
xt=x+x*D;
xb=x-x*D;

yt=y+y*D;
yb=y-y*D;

PlotOHLC( 0,xt,xb,xb ,"",ColorRGB(70,10,10), styleCloud);

PlotOHLC( 0,yt,yb,yb ,"",ColorRGB(10,70,10), styleCloud);

_SECTION_END();

Dear jsb2012

Get following Error :

Variable maxj used without having been initialized.....

I am using Ami 5.60.2
 
#7
I found no problem with the afl, only remove space while editing the afl. But i can't make out anything from the screen like how to trade with this afl.
 
#8

Code:
_SECTION_BEGIN("MarketProfile+OR+FPSR bold_POC+IB");
//------------------------------------------------------------------------------
//
// Formula Name: Market Profile 
//
// Use with 5/15min chart
// Originial - From AFL library
// Edited by - Milind

//Market Profile


Den = Param("Density", 1, 0.25, 100, 0.25); // Resolution in terms of $
IBBars = Param("Initial Balance Bars", 2, 0, 5, 1);
EnIB = Param("Show Initial Balance", 1, 0, 1, 1);
EnMP = Param("Show Market Profile", 1, 0, 2, 1);

PlotOHLC(O,H,L,C,"Price",IIf(C>O,colorAqua,colorRed),styleCandle|styleThick|styleNoLabel);

BarsInDay = BarsSince(Day() != Ref(Day(), -1));
Bot = TimeFrameGetPrice("L", inDaily, 0);
Top = TimeFrameGetPrice("H", inDaily, 0);
Vol = TimeFrameGetPrice("V", inDaily, 0);
POC = H - H;
VAL = H - H;
VAH = H - H;
CurTop = HHV(H,BarsInDay+1);
Curbot = LLV(L,BarsInDay+1);
Range = Highest(Top-Bot);
TodayRange = Top - Bot;

AveRange = Sum(Top-Bot,30)/30;
LAveRange = AveRange[BarCount-1];
if (LAveRange < 1) {Den = 0.05;}
else if (LAveRange < 10) {Den = 0.25;}
else if (LAveRange < 20) {Den = 0.5;}
else if (LAveRange < 100) {Den = 1;}
else if (LAveRange < 500) {Den = 5;}
else {Den = 1;}

// Initialization
baseX = 0;
baseY = floor(Bot[0]/Den)*Den;
relTodayRange = 0;
firstVisBar = Status("firstvisiblebar");
lastVisBar = Status("lastvisiblebar");

D=.000125;

for (j=0; j <= 100; j++) {
x[j] = 0;
}

i0 = 0;
i1 = 0;
for (i=0; i<BarCount; i++) {
if (BarsInDay[i] == 0 AND i < firstVisBar) {
i0 = i;
}
if (BarsInDay[i] == 0 AND i >= lastVisBar) {
i1 = i;
}
}

i1 = BarCount-1;
for (i=i0; i<=i1; i++) {
if (BarsInDay[i] == 0) {
baseX = i;
baseY = floor(Bot[i]/Den)*Den;
maxY = floor(Top[i]/Den)*Den;
relTodayRange = (maxY-baseY)/Den;

for (j=0; j <= relTodayRange; j++) {
x[j] = 0;
}
}

if (EnMP == 2) {
for (j=0; j<= relTodayRange; j++) {
if (L[i] <= baseY+j*Den AND H[i] >= baseY+j*Den) {
PlotText(StrExtract("A,B,C,D,E,F,G,H,I,J,K,L,M,N",
BarsInDay[i]), baseX+x[j], baseY+j*Den, colorBlack);
x[j]++;
}
}
}
else if (EnMP == 1) {
for (j=0; j<= relTodayRange; j++) {
if (L[i] <= baseY+j*Den AND H[i] >= baseY+j*Den) {
line = LineArray(baseX, baseY+j*Den, baseX+x[j]+1, baseY+j*Den);
//Plot(line,"",ParamColor("Color", colorCustom12), styleLine+styleDots|styleNoLabel);
x[j]++;
}
}
} 

// Draw Initial Balance after 11am bar is complete
if (BarsInDay[i] == IBBars+1 AND EnIB == 1) {
Linex = LineArray(i-2, curtop[i-1],i+10, curtop[i-1],0,True);
//Line1a=Line1+d*Line1;
//Line1b=Line1-d*Line1;
//Plot(Line1,"",colorBlue,styleDots+styleThick|style NoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styl eNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styl eNoLabel);


Liney = LineArray(i-2, curbot[i-1],i+10, curbot[i-1],0,True);
//Line1a=Line1+d*Line1;
//Line1b=Line1-d*Line1;
//Plot(Line1,"",colorBlue,styleDots+styleThick|style NoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styl eNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styl eNoLabel);
PlotOHLC(Linex,Linex,Liney,Liney,"",colorBlue,styleCloud);

}

// Examine x[j]
if ((i < BarCount - 1 AND BarsInDay[i+1] == 0) OR i == BarCount-1) {
maxXj = 0;
for (j=0; j<= relTodayRange; j++) {
if (maxXj < x[j]) {maxXj = x[j]; maxj = j;}
}
for (k=i-BarsInDay[i];k<=i;k++) {
POC[k] = baseY+Maxj*Den;
}
Line1 = LineArray(baseX, baseY + maxXj * Den , i, baseY+maxXj*Den,0,True);
Line1a=Line1 +d*Line1;
Line1b=Line1-d*Line1;
Plot(Line1,"",colorWhite,styleDots+styleThick);
Plot(Line1a,"",colorWhite,styleDots+styleThick|styleNoLabel);
Plot(Line1b,"",colorWhite,styleDots+styleThick|styleNoLabel);

}
}

//Plot(POC,"POC",colorWhite,styleDots);
_SECTION_END();

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | styleHidden |styleNoLabel| styleBar| GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("ORBO 10mt");
priceTitle=EncodeColor(colorYellow)+ StrFormat(" {{NAME}} -- {{INTERVAL}}" ) + "\n"+ EncodeColor(colorCustom11)+
"Date = " + Date() ;
ToolTip=StrFormat(" Close = %g (%.1f%%)",C,SelectedValue( ROC( C, 1 ) ));
Title ="DHIRAJ" + priceTitle + "\n" + EncodeColor(colorWhite) + ToolTip; 


breakoutime = 100500;
afterbreakout0 = Cross(TimeNum(),100500);
afterbreakout1 = TimeNum()>=100500;
NewDay = Day()!= Ref(Day(), -1);
highestoftheday = HighestSince(newday,H,1);
Lowestoftheday =LowestSince(newday,L,1);
ORBHigh = ValueWhen(afterbreakout0,highestoftheday,1);
ORBLow = ValueWhen(afterbreakout0,lowestoftheday,1);
buycandidate =Cross(C,orblow) AND afterbreakout1;
sellcandidate = Cross(orbhigh,C) AND afterbreakout1 ;

BuyCond2 = Cross(C, WMA((L+C+H)/3,9)+0.01);/*((MidMA, LongMA);*/
SellCond4=Cross( WMA((L+C+H)/3,9)+0.01,C); 
Buy1 = BuyCond2;
Sell1 = SellCond4 ;
entryprice=WMA((L+C+H)/3,9)+0.01;
ENTRYSELL=WMA((L+C+H)/3,9)-0.01;

Buy= Cross(C,orbhigh) AND afterbreakout1;
Sell = Cross(orblow,C) AND afterbreakout1;
color = IIf(Buy,colorGreen,IIf(Sell,colorRed,IIf(buycandidate,colorBlue,IIf(sellcandidate,colorPink,0))));


Plot(C,"",colorYellow,styleBar);
PlotShapes( shapeUpArrow * Buy, colorGreen,0,L,-12);
PlotShapes( shapeDownArrow * Sell, colorRed,0,H,-12);
//Plot(afterbreakout0,"",colorBlue,styleHistogram|st yleOwnScale);

StyleOR=styleNoLine|styleDots+styleThick|styleNoLabel;

//Plot(ORBHigh,"RESISTENCE",colorGreen,StyleOR);
//Plot(ORBLow,"SUPPORT",colorRed,StyleOR);
PlotOHLC(ORBHigh,ORBHigh,ORBLow,ORBLow,"",colorDarkBlue,styleCloud);

Filter = Buy OR Sell OR sellcandidate OR buycandidate OR Buy1 OR Sell1;


//Filter = Buy OR Sell OR sellcandidate OR buycandidate;
AddColumn(C,"CMP",0,colorBlue);
AddColumn(IIf(Buy OR sellcandidate,ORBHigh,ORBLow),"INTRA ",0,colorDefault,color);
AddColumn(IIf(Buy1,entryprice,ENTRYSELL),"DELIVERY ",0,colorDefault,IIf(Buy1,colorGreen, colorRed));

_SECTION_END();

_SECTION_BEGIN("Weekly MP");
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",colorTurquoise), styleNoTitle | styleBar | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("Market Profile");
//Market Profile
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);

//===========================

Den = Param("Density", 200, 10, 300, 10);
ShowMP = ParamToggle("Show MP", "No|Yes");
ShowVP = ParamToggle("Show VP", "No|Yes");
StyleMP = ParamStyle("style MP", styleLine|styleDots, maskAll);
StyleVP = ParamStyle("style VP", styleLine|styleDots, maskAll);

//===========================

//===========================
BarsInDay =BarsSince(DayOfWeek() < Ref( DayOfWeek(), -1 ))+1;

//===========================
NewDay = DayOfWeek() > Ref( DayOfWeek(),1) OR Cum(1) == BarCount;

//===========================
Bot = TimeFrameGetPrice("L", inWeekly, 0);
Top = TimeFrameGetPrice("H", inWeekly, 0);
Vol = TimeFrameGetPrice("V", inWeekly, 0);

//===========================

Range = Highest(Top-Bot);
Box = Range/Den;
VolumeUnit = Vol/BarsInDay;

for (k = 0; k < Den; k++) // loop through each line (price) starting at the Lowest price
{
Line = Bot + k*Box;
detect = Line >= L & Line <= H;

if(ShowMP == True)
{
CountMPString = IIf(NewDay, Sum(detect, BarsInDay), 0);
CountMPString = Ref(ValueWhen(NewDay, CountMPString, 0), -1);
MpLine = IIf(CountMPString >= BarsInDay, Line, Null);

Plot(MPLine, "", colorGreen , styleMP);
}

if(ShowVP == True)
{
CountVPString = IIf(NewDay, Sum(detect*V, BarsInDay)/VolumeUnit, 0);
CountVPString = Ref(ValueWhen(NewDay, CountVPString, 0), -1);
VpLine = IIf(CountVPString >= BarsInDay, Line + Box/4, Null);
//	 Plot()
Plot(VPLine, "", colorBlue, styleVP);
}
}

Title = "{{NAME}} - {{INTERVAL}} {{DATE}} {{VALUES}} - \\c04 Market Profile \\c06 Volume Profile";
_SECTION_END();

_SECTION_BEGIN("Price+FPSR+ZG+WW+StoDiv+CCI+");
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", colorPink ), styleNoTitle | styleBar ); 




////////////////////////////////////////////////// DP TOGGLE ///////////////////////////////////////////////////////




Show_Prev = ParamToggle( "Display Pivots", "No|Yes", 1);

// Get Previous Day's close, Low and High
DayC=Prev_Close = TimeFrameGetPrice( "C", inDaily, -1, expandFirst) ;
DayL=Prev_Low = TimeFrameGetPrice( "L", inDaily, -1, expandFirst) ;
DayH=Prev_High = TimeFrameGetPrice( "H", inDaily, -1, expandFirst) ;
Today = LastValue(Day( ) );
P = (Prev_High + Prev_Low + Prev_Close)/ 3;


R6 = (DayH / DayL) * DayC * 1.002;
R5 = (DayH / DayL) * DayC;
R4 = (((DayH / DayL) + 0.83) / 1.83) * DayC;
R3 = ( ( (DayH / DayL) + 2.66) / 3.66) * DayC;
R2 = ( ( (DayH / DayL) + 4.5) / 5.5) * DayC;
R1 = ( ( (DayH / DayL) + 10) / 11) * DayC;

S1 = (2- ( ( (DayH / DayL) + 10) / 11)) * DayC;
S2 = (2-( (DayH / DayL) + 4.5) / 5.5) * DayC;
S3 = (2-(( DayH / DayL) + 2.66) / 3.66) * DayC;
S4 = (2-( (DayH / DayL) + 0.83) / 1.83) * DayC;
S5 = (2-( DayH / DayL)) * DayC;
S6 = (2-( DayH / DayL)) * DayC * 0.998;
////////////////////////////// FPSR 30 MT STRATEGY /////////////////////////////////////////////////////////////

//TimeFrameSet( inDaily );

BS=(Prev_High-Prev_Low)/3;
Y=Prev_Close+BS;
X=Prev_Close-BS;


MULT=0.0003;


YT=Y+MULT*Y;
YB=Y-MULT*Y;

XT=X+MULT*X;
XB=X-MULT*X;


//PlotOHLC( 0, Prev_High ,Prev_Low ,Prev_Low, "", HLColor, styleCloud|styleNoLabel);
HLColor = colorPaleBlue;

if(Show_Prev)
{Plot(IIf(Today == Day(),R5, Null), "R5", ParamColor("R5", colorLightBlue),styleDashed|styleThick|styleNoRescale);
Plot(IIf(Today == Day(),R4, Null), "R4", ParamColor("R4",colorLightBlue),styleDots|styleThick|styleNoRescale);
Plot(IIf(Today == Day(),R3, Null), "R3", ParamColor("R3",colorLightBlue),styleDots|styleThick|styleNoRescale);
//Plot(IIf(Today == Day(),R2, Null), "R2", ParamColor("R2", colorBlack),styleDots|styleThick|styleNoRescale|st yleNoLabel);
//Plot(IIf(Today == Day(),R1, Null), "R1", ParamColor("R1",colorBlack),styleDots|styleThick|s tyleNoRescale|styleNoLabel);
//Plot(IIf(Today == Day(),P, Null), "P", ParamColor("P",colorYellow),styleDots|styleThick|s tyleNoRescale);
//Plot(IIf(Today == Day(),S1, Null), "S1", ParamColor("S1", colorBlack),styleDots|styleThick|styleNoRescale|st yleNoLabel);
//Plot(IIf(Today == Day(),S2, Null), "S2", ParamColor("S2",colorBlack),styleDots|styleThick|s tyleNoRescale|styleNoLabel);
Plot(IIf(Today == Day(),S3, Null), "S3", ParamColor("S3",colorBrightGreen),styleDots|styleThick|styleNoRescale);
Plot(IIf(Today == Day(),S4, Null), "S4", ParamColor("S4", colorBrightGreen),styleDots|styleThick|styleNoRescale );
Plot(IIf(Today == Day(),S5, Null), "S5", ParamColor("S5", colorBrightGreen),styleDashed|styleThick|styleNoRescale);



//Plot(IIf(Today == Day(), Prev_High, Null), "Prev_High", ParamColor(" Prev_High", HLColor),styleDashed|styleThick|styleNoRescale );
//Plot(IIf(Today == Day(), Prev_Low, Null), "Prev_Low", ParamColor(" Prev_Low", HLColor),styleDashed|styleThick|styleNoRescale );
}




////////////////////////////// DAY HILO SHADOW /////////////////////////////////////////////////////////////


BSColor = ColorRGB(80,80,80);
HLColor = ColorRGB(20,20,40);
//PlotOHLC( 0, Prev_High ,Prev_Low ,Prev_Low, "", HLColor, styleCloud|styleNoLabel);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////// DOUBLE TOP //////////////////////////////////////////


/* Detecting double tops */
percdiff = 5; /* peak detection threshold */
fwdcheck = 5; /* forward validity check */
mindistance = 10;
validdiff = percdiff/400;
PK= Peak( H, percdiff, 1 ) == High;

x = Cum( 1 );
XPK1 = ValueWhen( PK, x, 1 ); 
XPK2 = ValueWhen( PK, x, 2 ); 

peakdiff = ValueWhen( PK, H, 1 )/ValueWhen( PK, H, 2 );
doubletop = PK AND abs( peakdiff - 1 ) < validdiff AND (XPK1 - XPK2)>mindistance AND High > HHV( Ref( H, fwdcheck ), fwdcheck - 1 );
SellDT = doubletop;
Buy = 0;
//Filter=SellDT;
WriteIf( Highest( doubletop ) == 1, "AmiBroker has detected some possible
double top patterns for " + name() + "\nLook for green arrows on the price
chart.", "There are no double top patterns for " + name() );



PlotShapes(SellDT*shapeHollowDownTriangle,colorPink, 0, High, Offset =-25);
PlotShapes(SellDT*shapeDigit0,colorPink, 0, High, Offset =40);
PlotShapes(SellDT*shapeDigit0,colorPink, 0, High, Offset =50);


////////////_SECTION_BEGIN("Volume At Price");
PlotVAPOverlay( Param("Lines", 300, 100, 1000, 1 ), Param("Width", 5, 1, 100, 1 ), ParamColor("Color", colorLightBlue ), ParamToggle("Side", "Left|Right" ) | 4*ParamToggle("Z-order", "On top|Behind", 1 ) );

_SECTION_END();

_SECTION_BEGIN("VOLUME_Hight of Volume Bars Control");


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

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

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

VolScale = Param("1/Vol. Height (TimeBar chart)(fraction of
window) 5=1/5=20%",10, 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("DispMA");

_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", Null ), styleNoTitle | styleCandle ); 

P = ParamField("Field");
Type = ParamList("Type", "Simple,Exponential,Double Exponential,Tripple Exponential,Wilders,Weighted");
//Periods = Param("Periods", 30, 2, 300 );
//Displacement = Param("Displacement", 4, -50, 50 );
//m = 0;

//if( Type == "Simple" )
A = MA( H,6 );
B = MA( L,6 );


x= Ref(A,-4);
y= Ref(B,-4);

D=.0003;
xt=x+x*D;
xb=x-x*D;

yt=y+y*D;
yb=y-y*D;

PlotOHLC( 0,xt,xb,xb ,"",ColorRGB(70,10,10), styleCloud);

PlotOHLC( 0,yt,yb,yb ,"",ColorRGB(10,70,10), styleCloud);

_SECTION_END();

_SECTION_BEGIN("Background text");
C13=Param("fonts",30,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",7,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode(transparent=1);
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( colorGreen);
GfxTextOut( " CALL : 07598261722", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont( " Tahoma", Status("pxheight")/C13*0.5 );
GfxSetTextColor( colorBlue);
GfxTextOut( " NSE EQ,NSE F&O,NSE CURRENCY,MCX REAL TIME DATA  ", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
_SECTION_END();
 

muinali

Well-Known Member
#9
working but nothing special
 

Similar threads