I need this AFL. Please help me !

#11
//------------------------------------------------------------------------------
//
// Formula Name: Linear Regression Line w/ Std Deviation Channels
// Author/Uploader: Patrick Hargus
// E-mail:
// Date/Time Added: 2005-03-07 00:58:06
// Origin: Based on the Linear Regression Indicator found in TC2000 and the AB Lin Regression Drawing Tool.
// Keywords: linnear regression, standard deviation
// Level: medium
// Flags: indicator
// Formula URL: http://www.amibroker.com/library/formula.php?id=438
// Details URL: http://www.amibroker.com/library/detail.php?id=438
//
//------------------------------------------------------------------------------
//
// Plot a linear regression line of any price field available on a chart for a
// period determined by the user. 2 Channels are plotted above and below based
// on standard deviations of the linear regression line as determined by the
// user. A look back feature is also provided for examining how the indicator
// would have appeared on a chart X periods in the past. Designed for AB
// versions 4.63 and above using drag and drop feature with user variable
// Params.
//
// Various explorations based on crossovers, excursions and returns within the
// SD channels are easily added.
//
//------------------------------------------------------------------------------

// Linear Regression Line with 2 Standard Deviation Channels Plotted Above and Below
// Written by Patrick Hargus, with critical hints from Marcin Gorzynski, Amibroker.com Technical Support
// Designed for use with AB 4.63 beta and above, using drag and drop feature.
// Permits plotting a linear regression line of any price field available on the chart for a period determined by the user.
// 2 Channels, based on a standard deviation each determined by the user, are plotted above and below the linear regression line.
// A look back feature is also provided for examining how the indicator would have appeared on a chart X periods in the past.


P = ParamField("Price field",-1);
Daysback = Param("Period for Liner Regression Line",21,1,240,1);
shift = Param("Look back period",0,0,240,1);


// =============================== Math Formula =============================================================

x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );


// ==================Plot the Linear Regression Line ==========================================================


LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");

LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
Plot( LRLine , "LinReg", LRCOLOR, LRSTYLE ); // styleDots );

// ========================== Plot 1st SD Channel ===============================================================

SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);
SD = SDP/2;

width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;

SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");

Plot( SDU , "Upper Lin Reg", SDColor,SDStyle );
Plot( SDL , "Lower Lin Reg", SDColor,SDStyle );

// ========================== Plot 2d SD Channel ===============================================================

SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);
SD2 = SDP2/2;

width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;

SDColor2 = ParamColor("2 SD Color", colorCycle );
SDStyle2 = ParamStyle("2 SD Style");

Plot( SDU2 , "Upper Lin Reg", SDColor2,SDStyle2 );
Plot( SDL2 , "Lower Lin Reg", SDColor2,SDStyle2 );

// ============================ End Indicator Code ==============================================================
 

casoni

Well-Known Member
#12
I need color Linear Regression Channel

_SECTION_BEGIN("Linear Regression Channel");
//CyberMan's Linear Regression Channel.

//Linear Regression Line with 2 Standard Deviation Channels Plotted Above and Below
//The original was written by Patrick Hargus, with critical hints from Marcin Gorzynski, Amibroker.com Technical Support
//Wysiwyg coded the angle in degrees part
//I modified the original Linear Regression code so that the line will change color based on the degree of the Linear Regression slope.
//I combine this with my trading system.
//When my system gives an entry signal I look at the Linear Regression Line and I will only take long positions if the Linear Regression line is green and the entry price is below the LR line.
//When my system gives an entry signal I look at the Linear Regression Line and I will only take short positions if the Linear Regression line is red and the entry price is above the LR line.
//It is usefull for filtering out lower probability trades.

//====================================Start of Linear Regression Code==================================================================================

P = ParamField("Price field",-1);

Length = 150;

Daysback = Param("Period for Liner Regression Line",Length,1,240,1);
shift = Param("Look back period",0,0,240,1);

//=============================== Math Formula ========================================================================================================

x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );

//==================Plot the Linear Regression Line ====================================================================================================

LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");

LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );

LRStyle = ParamStyle("LR Style");
Angle = Param("Angle", 0.05, 0, 1.5, 0.01);// A slope higher than 0.05 radians will turn green, less than -0.05 will turn red and anything in between will be white.

LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );

Pi = 3.14159265 * atan(1); // Pi
SlopeAngle = atan(bb)*(180/Pi);

LineUp = SlopeAngle > Angle;
LineDn = SlopeAngle < - Angle;

if(LineUp)
{
Plot(LRLine, "Lin. Reg. Line Up", IIf(LineUp, colorBrightGreen, colorWhite), LRStyle);
}
else
{
Plot(LRLine, "Lin. Reg. Line Down", IIf(LineDn, colorDarkRed, colorWhite), LRStyle);
}

//========================== Plot 1st SD Channel ======================================================================================================

SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);
SD = SDP/2;

width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); //Set width of inside chanels here.
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;

SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");

Plot( SDU , "Upper Lin Reg", colorWhite,SDStyle ); //Inside Regression Lines
Plot( SDL , "Lower Lin Reg", colorWhite,SDStyle ); //Inside Regression Lines

//========================== Plot 2d SD Channel ========================================================================================================

SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1);
SD2 = SDP2/2;

width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); //Set width of outside chanels here.
SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ;
SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ;

SDColor2 = ParamColor("2 SD Color", colorCycle );
SDStyle2 = ParamStyle("2 SD Style");

Plot( SDU2 , "Upper Lin Reg", colorWhite,SDStyle2 ); //OutSide Regression Lines
Plot( SDL2 , "Lower Lin Reg", colorWhite,SDStyle2 ); //OutSide Regression Lines

Trend = IIf(LRLine > Ref(LRLine,-1),colorGreen,colorRed);//Changes LR line to green if sloping up and red if sloping down.

Plot( LRLine , "LinReg", Trend, LRSTYLE );

//===================== End Indicator Code
add this ,
PlotOHLC(sdu2,sdu2,sdu,sdu,"",colorPaleGreen,styleCloud);
PlotOHLC(sdl2,sdl2,sdl,sdl,"",colorPink,styleCloud);
 
#13
Casoni@ Brother please take my heart-core thanks. I always remember you for your help. Please feel free to knocked me if you need any help. I am always on your side. I wish all of your success and all the best.

colorafl
 
#16
Re: super trend rocket formula afl

_SECTION_BEGIN("Trend Lines");
p1 = Param("TL 1 Periods", 20, 5, 50, 1);
p2 = Param("TL 2 Periods", 5, 3, 25, 1);
TL1 = LinearReg(C, p1);
TL2 = EMA(TL1, p2);
Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorGreen), ParamColor("TL Dn Colour", colorRed));
Plot(TL1, "TriggerLine 1", Col1, styleLine|styleThick|styleNoLabel);
Plot(TL2, "TriggerLine 2", Col1, styleLine|styleThick|styleNoLabel);
_SECTION_END();

_SECTION_BEGIN("Linear Regression Channel");
//CyberMan's Linear Regression Channel.

//Linear Regression Line with 2 Standard Deviation Channels Plotted Above and Below
//The original was written by Patrick Hargus, with critical hints from Marcin Gorzynski, Amibroker.com Technical Support
//Wysiwyg coded the angle in degrees part
//I modified the original Linear Regression code so that the line will change color based on the degree of the Linear Regression slope.
//I combine this with my trading system.
//When my system gives an entry signal I look at the Linear Regression Line and I will only take long positions if the Linear Regression line is green and the entry price is below the LR line.
//When my system gives an entry signal I look at the Linear Regression Line and I will only take short positions if the Linear Regression line is red and the entry price is above the LR line.
//It is usefull for filtering out lower probability trades.


//================================================St art Chart Configuration===================================== =======================================

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
SetChartBkGradientFill(ParamColor("Top", colorTeal), ParamColor("Bottom", colorLightGrey), ParamColor("Title", colorTeal));
SetChartBkColor(colorTeal);


Plot( C, "Close", colorWhite, styleCandle, Zorder = 1);
SetChartOptions(0,chartShowArrows | chartShowDates);

//================================================En d Chart Configuration===================================== ==========================================

_SECTION_BEGIN("HH");
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, colorRed );

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

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

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

}

Filter=HH OR HL OR LH OR LL;
AddColumn(RSI(2),"RSI",1.2);
AddColumn(Close,"PRICE",1.2);
AddColumn(HH,"SHORT");
AddColumn(LH,"LH");
AddColumn(HL,"HL");
AddColumn(LL,"COVER");
AddColumn(V,"volume",1.0);
_SECTION_END();

_SECTION_BEGIN("Realtimetips ");
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", colorBlack , styleNoTitle | styleCandle | GetPriceStyle() );
//
messageboard = ParamToggle("Message Board","Show|Hide",0);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
no=10;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
s5d=IIf(avn==1,sup,res);

if (showsl == 0)
{Plot(s5d,"Stop Loss",colorCustom14,styleDots);}
exitlong = Cross(s5d, C);
PlotShapes(exitlong * shapeDownArrow, colorRed,0,H,-12);
exitshort = Cross(C, s5d);
PlotShapes(exitshort * shapeUpArrow, colorGreen,0,L,-12);

Buy = exitshort;
Sell = exitlong;
Short = Sell;
Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short, Cover);
Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );

for(i=BarCount-1;i>1;i--)
{
if(Buy == 1)
{
entry = C;
sig = "BUY";
sl = s5d;
tar1 = entry + (entry * .0078);
tar2 = entry + (entry * .0234);
tar3 = entry + (entry * .0356);
bars = i;
i = 0;
}
if(Sell == 1)
{
sig = "SELL";
entry = C;
sl = s5d;
tar1 = entry - (entry * .0078);
tar2 = entry - (entry * .0234);
tar3 = entry - (entry * .0356);
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorOrange);
ssl = IIf(bars == BarCount-1, s5d[BarCount-1], Ref(s5d, -1));
sl = ssl[BarCount-1];

Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorCustom14, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorTurquoise, styleLine|styleDots, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText("" + sig + " @ " + entry, BarCount+3, entry, Null, colorTurquoise);
PlotText("Target 1 : " + tar1, BarCount+3, tar1, Null, Clr);
PlotText("Target 2 : @ " + tar2, BarCount+3, tar2, Null, Clr);
PlotText("Target 3 : @ " + tar3, BarCount+3, tar3, Null, Clr);
PlotText("Trailing SL @ " + sl, BarCount+3, sl, Null, colorCustom14);
}
//Plot(sl, "", colorCustom14, styleLine);
printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));

if (messageboard == 0 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorGreen ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 2;
x2 = 290;

y = pxHeight;

GfxSelectPen( colorLightBlue, 1); // broader color
GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;

GfxTextOut( (" ......................................."),27,y-160);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-140) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-120);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-100);
GfxTextOut( ("Target:1 : " + tar1), 13, y -80);
GfxTextOut( ("Target:2 : " + tar2), 13,y-60);
GfxTextOut( ("Target:3 : " + tar3), 13,y-40);
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);;

x = 290;
x2 = 570;
GfxSelectSolidBrush( colorTurquoise );
GfxSetTextColor( colorBlack);
GfxSelectFont( "Tahoma", 14, 100 );
GfxSetBkMode( 1 );
GfxSelectPen( colorLightBlue, 1); // broader color
GfxRoundRect( x, y - 43, x2, y , 7, 7 ) ;

GfxSelectFont( "Tahoma", 10, 400 );

}
//

function PlotDT()
{
displacement = Param("Displacement Value", 12, 1, 100, 1);
slmode = ParamToggle("Stop Loss", "Auto|Manual", 1);
width = ParamToggle("Width", "HL|OC", 1);
Count = Param("No. of DTL", 4, 4, 20, 1);
NewDay = Day()!= Ref(Day(), -1);

for (i=BarCount-1;i > 1; i--)
{
if(NewDay == 1)
{
printf("High : " + i);
if(width == 1)
{
DL = IIf(O < C, O, C);
DH = IIf(O > C, O, C);
}
else
{
DL = L;
DH = H;
}
Bars = i;
i = -1;
}
}

if(slmode==1)
{
distance = displacement;
}
else
{
distance = ((DH+DL)/2) * .01;
}

Plot(LineArray(BarCount - (BarCount-Bars+20), DH, BarCount+35, DH, 1), "", colorLime, styleLine|styleThick|styleDots, Null, Null, 20);
PlotText("Buy Above " + DH + "; Stop Loss = " + DL, BarCount + 0, DH, colorBlack, colorLime);
Plot(LineArray(BarCount - (BarCount-Bars+20), (DH+ distance), BarCount+35, (DH+ distance), 1), "", colorLime, styleLine|styleThick|styleDots, Null, Null, 20);
PlotText("Target = " + (DH+ distance), BarCount + 0, (DH+ distance), colorBlack, colorLime);
Plot(LineArray(BarCount - (BarCount-Bars+20), DL, BarCount+35, DL, 1), "", colorOrange, styleLine|styleThick|styleDots, Null, Null, 20);
PlotText("Sell Below " + DL + "; Stop Loss = " + DH, BarCount + 0, DL, colorBlack, colorOrange);
Plot(LineArray(BarCount - (BarCount-Bars+20), (DL-distance), BarCount+35, (DL-distance), 1), "", colorOrange, styleLine|styleThick|styleDots, Null, Null, 20);
PlotText("Target = " + (DL-distance), BarCount + 0, (DL-distance), colorBlack, colorOrange);
}
function PlotIndicators()
{

SetChartOptions(0,chartShowArrows|chartShowDates);
/* Standard Error Bands */
Periods = Param("Standard Error", 80, 3, 200, 1);
Smooth = Param("Smooth",14,2,100,1);


LRCurve = LinearReg( C, periods );
MALRCurve = MA(LRCurve, Smooth);
SEValue = StdErr( C, periods );
SErrorAvg = MA(SEValue, Smooth);

LowerBand = MALRCurve - SErrorAvg ;
UpperBand = MALRCurve + SErrorAvg ;

Plot( MALRCurve , "MidBand", ParamColor("ColorMB",colorIndigo) , styleDashed|styleNoTitle);
Plot( LowerBand , "LowerBand", ParamColor("ColorLo",colorOrange) , styleLine|styleThick|styleNoTitle);
Plot( UpperBand , "UpperBand", ParamColor("ColorUp",colorGreen) , styleLine|styleThick|styleNoTitle);

Ch = TimeFrameGetPrice("C", in1Minute/60);
clr = IIf(Ch[BarCount-2] > Ch[BarCount-1],colorRed,colorLime);

Plot(LineArray(0,C[BarCount-1],BarCount-1,C[BarCount-1],15), "", Clr, styleLine|styleNoLabel, Null, Null, 30);
PlotText("CMP:" + C[BarCount-1], BarCount+5, C[BarCount-1],colorBlack,Clr);

LRPeriods = Param("Length", 40, 3, 200, 1);
LRCurve = LinearReg( C, LRPeriods );

PlotLR = IIf(LRCurve < LowerBand, (LRCurve + LowerBand)/2, IIf(LRCurve > UpperBand, (LRCurve + UpperBand)/2, LRCurve));
PlotLR = (PlotLR + SwingLine)/2;
//Plot( PlotLR , "Stop Loss |", ParamColor("SLColor",colorBlue), 4+8+32+2048);
//Plot( SwingLine, "SwingLine", ParamColor( "SWColor", colorBlue ), ParamStyle("StyleSW",style=styleThick|styleNoLabel , mask=maskDefault) );

bc1 = (Cross(C, MALRCurve) OR Cross(C, UpperBand) OR Cross(C, LowerBand)) AND (C > SwingLine);
bc2 = Cross(C, SwingLine) AND (C > MALRCurve OR C > UpperBand OR C > LowerBand);

sc1 = (Cross(MALRCurve, C) OR Cross(UpperBand, C) OR Cross(LowerBand, C)) AND (C < SwingLine);
sc2 = Cross(SwingLine, C) AND (C < MALRCurve OR C < UpperBand OR C < LowerBand);
Buy = bc1 OR bc2;
Sell = sc1 OR sc2;
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
//PlotShapes(shapeCircle*Buy + shapeCircle *Sell, IIf(Buy, colorBlue, colorRed), 0, IIf(Buy, L, H), IIf(Buy, -12, 12));

}
//PlotDT();
_SECTION_END();


enjoy the money rain with this formula:thumb:
 

jsb2012

Active Member
#18
_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 == 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|styleNoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styleNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styleNoLabel);


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|styleNoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styleNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styleNoLabel);
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;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|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|styleOwnScale);

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|styleNoLabel);
//Plot(IIf(Today == Day(),R1, Null), "R1", ParamColor("R1",colorBlack),styleDots|styleThick|styleNoRescale|styleNoLabel);
//Plot(IIf(Today == Day(),P, Null), "P", ParamColor("P",colorYellow),styleDots|styleThick|styleNoRescale);
//Plot(IIf(Today == Day(),S1, Null), "S1", ParamColor("S1", colorBlack),styleDots|styleThick|styleNoRescale|styleNoLabel);
//Plot(IIf(Today == Day(),S2, Null), "S2", ParamColor("S2",colorBlack),styleDots|styleThick|styleNoRescale|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();





I AM GETTING ERROR MY AMI VERSION IS 5.5 in windows 8
 
Last edited:
#19
_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 == 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|styleNoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styleNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styleNoLabel);


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|styleNoLabel);
//Plot(Line1a,"",colorBlue,styleDots+styleThick|styleNoLabel);
//Plot(Line1b,"",colorBlue,styleDots+styleThick|styleNoLabel);
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;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|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|styleOwnScale);

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|styleNoLabel);
//Plot(IIf(Today == Day(),R1, Null), "R1", ParamColor("R1",colorBlack),styleDots|styleThick|styleNoRescale|styleNoLabel);
//Plot(IIf(Today == Day(),P, Null), "P", ParamColor("P",colorYellow),styleDots|styleThick|styleNoRescale);
//Plot(IIf(Today == Day(),S1, Null), "S1", ParamColor("S1", colorBlack),styleDots|styleThick|styleNoRescale|styleNoLabel);
//Plot(IIf(Today == Day(),S2, Null), "S2", ParamColor("S2",colorBlack),styleDots|styleThick|styleNoRescale|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();





I AM GETTING ERROR MY AMI VERSION IS 5.5 in windows 8


try with this one:

_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,colorGreen,colorRed),styleCandle);

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=.00025;

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", colorGold), styleLine+styleDots);
x[j]++;
}
}
}

// Draw Initial Balance after 11am bar is complete
if (BarsInDay == IBBars+1 AND EnIB == 1) {
Line1 = 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);
Plot(Line1a,"",colorBlue,styleDots+styleThick|styleNoLabel);
Plot(Line1b,"",colorBlue,styleDots+styleThick|styleNoLabel);


Line1 = 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);
Plot(Line1a,"",colorBlue,styleDots+styleThick|styleNoLabel);
Plot(Line1b,"",colorBlue,styleDots+styleThick|styleNoLabel);
}

// 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+maxXj*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 | ParamStyle("Style") | 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|styleOwnScale);

StyleOR=styleNoLine|styleDots+styleThick;

Plot(ORBHigh,"RESISTENCE",colorGreen,StyleOR);
Plot(ORBLow,"SUPPORT",colorRed,StyleOR);
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("FPSR");

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


//////////////////////////////30 MT STRATEGY /////////////////////////////////////////////////////////////
BS=(Prev_High-Prev_Low)/3;


Y=R30=Prev_Close+BS;
X=S30=Prev_Close-BS;
BSColor = ColorRGB(20,20,40);

PlotOHLC( 0, R30 , S30 ,S30 , "30MT", BSColor, styleCloud|styleNoLabel);
_SECTION_END();
 

Similar threads