query about afl

ocil

Well-Known Member
#2
Find down side AFL:-
_SECTION_BEGIN("Bull Bear Volume indicator");
/*
A approximation of the average Bull Volume component versus the average Bear Volume component of total Volume. Dieplays an interesting and helpful view of the ebb and flow of Bull and Bear Volume pressure in the market. Shows what the bears are up to while the bulls are in control and vice versa. You can see bull pressure building (or bear pressure diminishing) in advance of a bullish price move (especially in sideways markets and horizonal rectangular consolidations). The graph moves in curves from which you can often extrapolate reasonably accurate and useful projections of future Bull or Bear Volume Action.

Features:
Total Volume MA Histogram and Line
Bull Volume MA Histogram and Line
Bear Volume MA Histogram and Line
Currently Selected Bull Volume Level
Currently Selected Bear Volume Level
Bull/Bear Volume Convergence/Divergence Oscillator
Rising and Falling Convergence/Divergence Background Shadows

***All components of the indicator can be toggled on and off via the parameter window if the display is too busy or too sparse for your tastes. Set your own defaults in the code.***

I tried to use all AB color constants for compatibility but the available greys are too dark - In this case I have supplied the RGB values for the custom greys I used in the Rise/Fall Background Shadows. If your color scheme is radically different than the default gray background you may have to redo all the colors to your satisfaction.


Known Issues:
Sometimes the volume will dip slightly below the zero line, especially at the beginning of the chart. I think this is related to the lookback periods for the TEMA's and the uneven distribution of up and down days in the market- I don't think it voids the reliability or usefulness of the indicator. When I figure out how to fix it I will post the updated code. Or if anyone knows the cause and fix please let me know via email or post the fix in the comments section.

If you find this indicator helpful, or if you find any error in logic or coding, or if you see a better way to display this information, please drop me an email at:

"nkm at dr dot com"

...and let me know - I'd love to get the feedback.

Best Regards,

Nick Molchanoff
*/




/* basic variable defs
ud: up-Day (Close up from Open)
dd: down-Day (Close down from Open)
uc: up-Close (Close up from previous Close)
dc: down-Close: (Close down from previous Close)
*/
C1 = Ref(C, -1);
uc = C > C1; dc = C <= C1;
ud = C > O; dd = C <= O;

/*
Volume Day types:
green: up-day and up-close
yellow: up-day but down-close
red: down-day and down-close
blue: down-day but up-close
white: close equals open, close equals previous close

(currently unused vtypes are for future enhancements)
*/
green = 1; blue = 2; Custom12 = 3; red = 4; Black = 5;
VType = IIf(ud,
IIf(uc, green, Custom12),
IIf(dd,
IIf(dc, red, blue), Black));

/* green volume: up-day and up-close*/
gv = IIf(VType == green, V, 0);
/* yellow volume: up-day but down-close */
yv = IIf(VType == Custom12, V, 0);
/* red volume: down-day and down-close */
rv = IIf(VType == red, V, 0);
/* blue volume: down-day but up-close */
bv = IIf(VType == blue, V, 0);

/* split up volume of up-close days from down-close days - (for the purposes of this volume display indicator, up-days that closed down from the previous close are considered bearish volume days, and conversely, down-days that nevertheless closed up from the previous close are considered bullish volume days - my testing indicates this is more accurate than using ordinary up-days and down-days) */
uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */

/* create moving average period parameters */
VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);

/* create triple exponential moving avearges of separate up and down volume moving averages */
MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume

/* Switch for Horizontal lines indicating current level of positive and negative volume for ease in comparing to past highs/lows - toggle via parmameter window */
OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);
CompareBullVolume = Param("Show Bull Level", 0, 0, 1, 1);
if(CompareBullvolume AND !OscillatorOnly){
Plot(SelectedValue(MAuv), "", colorGreen, styleLine);
}

CompareBearVolume = Param("Show Bear Level", 0, 0, 1, 1);
if(CompareBearVolume AND !OscillatorOnly){
Plot(SelectedValue(MAdv), "", colorRed, styleLine);
}

/* Volume Segment Switches - toggle via parameter window */
bullvolume = Param("Show Bull Volume", 1, 0, 1, 1);
bearvolume = Param("Show Bear Volume", 1, 0, 1, 1);
totalvolume = Param("Show Total Volume", 1, 0, 1, 1);

/* plot volume lines and histograms if toggled on: */
bearToFront = Param("Show Bear Vol in Front", 0, 0, 1, 1);
if(bearToFront AND !OscillatorOnly){
Plot(MAdv, "", colorRed, styleHistogram|styleNoLabel);
}
if(bullvolume AND !OscillatorOnly){
Plot(MAuv, "Average Bull Volume", colorGreen, styleHistogram|styleNoLabel);
}
if(bearvolume AND !OscillatorOnly){
Plot(MAdv, "Average Bear Volume", colorRed, styleHistogram|styleNoLabel);
}
if(totalVolume AND !OscillatorOnly){
Plot(MAtv, "Total Volume", colorBlack, styleHistogram|styleNoLabel);
Plot(MAtv, "", colorBlack, styleLine);
}
if(bullvolume AND !OscillatorOnly){
Plot(MAuv, "", colorGreen, styleLine);
}
if(bearvolume AND !OscillatorOnly){
Plot(MAdv, "", colorRed, styleLine);
}

/* better visibility of zero line: */
Plot(0, "", colorBlue, 1);

/* Rise/Fall Convergence variables: */
Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;

/* Rise/Fall Convergence Oscillator Switch - toggle via parameter window - (provides a better view of resulting combination of battling bull/bear volume forces) */
convergenceOscillator = Param("Show Oscillator", 1, 0, 1, 1);
if(convergenceOscillator OR OscillatorOnly){
Plot(Converge, "Bull/Bear Volume Convergence/Divergence", colorViolet, 1|styleLeftAxisScale|styleNoLabel|styleThick);
Plot(0,"", colorCustom12, 1|styleLeftAxisScale|styleNoLabel);
}

/************************************************** ******
Convergence Rise/Fall Shadows:

(provides a more easily visible display of rising and falling bull/bear volume convergence) - toggle via parameter window

-posiitive Volume exceeding negative Volume: Light shadow
-negative volume exceeding positive volume: dark shadow
-if you use standard gray background - best shadows are:
-my greys: 14 = (216, 216, 216); 15 = (168, 168, 168));
-best substitute? using AB color constants?
-light: colorpalegreen; dark: colorRose;?
-(depends on your color scheme - customize to your tastes)
************************************************** ********/

/* uncomment if you use my custom color greys: */
riseFallColor = IIf(rising, 14,15); //my custom shadow greys

/* comment out if you use my custom color gray shadows: */
/* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */

/* Rise/Fall Convergence Plot Switch - toggle via parameter window */
riseFallShadows = Param("Show RiseFallShadows", 0, 0, 1, 1);
if(riseFallShadows){
Plot(IIf(rising OR falling, 1, 0), "", riseFallColor, styleHistogram|styleArea|styleOwnScale|styleNoLabel);
}
GraphXSpace = 0.5;
SetChartBkColor( ParamColor( "Outer panel",colorWhite) );
_SECTION_END();
 
#5
Code:
Plot(100,"",7,styleLine);
Plot(-100,"",7,styleLine);
n=9;
ys1=(High+Low+Close*2)/4;
rk3=EMA(ys1,n);
rk4=StDev(ys1,n);
rk5=(ys1-rk3)*100/rk4;
rk6=EMA(rk5,n);
UP=EMA(rk6,n);
DOWN=EMA(up,n);
Oo=IIf(up<down,up,down);
Hh=Oo;
Ll=IIf(up<down,down,up);
Cc=Ll;
barcolor2=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),colorBlue,IIf(up>down,colorGreen,colorRed));
PlotOHLC( Oo,hh,ll,Cc, "Modified " + Name(), barcolor2, styleCandle );



johny bhai plz check it
 
#6
finally found it

Code:
Plot(95,"",7,styleLine);
Plot(-95,"",7,styleLine);
Plot(15,"",7,styleDashed);
Plot(-20,"",7,styleDashed);


n=4;
n = Param("n", 7, 2, 200, 1, 4 );
p=30;
p = Param("p",30,2,100,1);
ys1=(Open+High+Low+Close*9)/4;
rk3=EMA(ys1,n);
rk4=StDev(ys1,n);
rk5=(ys1-rk3)*100/rk4;
rk6=EMA(rk5,n);
UP=EMA(rk6,n);
DOWN=EMA(up,n);
Oo=IIf(up<down,up,down);
Hh=Oo;
Ll=IIf(up<down,down,up);
Cc=Ll;
Buy=Cross(up,down);
Sell=Cross(down,up);


Short=Sell;
Cover=Buy;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

barcolor2=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,1),colorBlue,IIf(up>down,colorGreen,colorRed));
PlotOHLC( Oo,hh,ll,Cc, "Modified " + Name(), barcolor2, styleCandle );
SetChartOptions( 1, chartShowDates );
BKswitch = ParamToggle("Background Color","On,Off");

OUTcolor = ParamColor("Outer Panel Color",colorTeal);
INUPcolor = ParamColor("Inner Panel Upper",colorDarkTeal);
INDNcolor = ParamColor("Inner Panel Lower",colorPlum);
TitleColor = ParamColor("Title Color ",colorBlack);

if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
AlertIf( Buy , "SOUND C:\\Windows\\Media\\chimes.wav", "Audio alert", 2 ); 
AlertIf( Sell , "SOUND C:\\Windows\\Media\\alert.wav", "Audio alert", 2 );

Long=Flip(Buy,Sell); 
Shrt=Flip(Sell,Buy); 

BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);


Edc=(
WriteIf (Buy AND Ref(shrt,-1), " BUY @ "+C+"  ","")+ 
WriteIf (Sell AND Ref(Long,-1), " SEll @ "+C+"  ","")+
WriteIf(Sell , "Last Trade Profit Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy  , "Last Trade Profit Rs."+(SellPrice-C)+"",""));

//============== TITLE ==============
_SECTION_BEGIN("Title");
no=Param( "Swing", 6, 1, 55 );
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);
tsl=IIf(avn==1,sup,res);
dec = (Param("Decimals",2,0,7,1)/10)+1;
if( Status("action") == actionIndicator ) 
(
Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
	EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
	EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
	EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1)



+"\n"+EncodeColor(colorBrightGreen)+

WriteIf (Buy , "Signal: Go Long - Entry Price: "+WriteVal(C)+" - Traget: "+WriteVal((BuyPrice-tsl)+BuyPrice)

+" - StopLoss:"+WriteVal(tsl)+"  "

,"")+

"\n"+EncodeColor(colorRed)+
WriteIf (Sell , "Signal: Go Short - Entry Price: "+WriteVal(C)+" - Target: "+WriteVal((tsl-SellPrice)-SellPrice)+" - StopLoss:"+WriteVal(tsl)+" ","")+
EncodeColor(colorTurquoise)+
WriteIf(Long AND NOT Buy, "Trade: Long - Entry Price: "+WriteVal((BuyPrice))+" - Profit: "+WriteVal((C-BuyPrice))+" "+EncodeColor(colorLime)+"Let your profit runs!","")+
EncodeColor(colorLightOrange)+
WriteIf(shrt AND NOT Sell, "Trade: Short - Entry Price: "+WriteVal((SellPrice))+" - Profit: "+WriteVal((SellPrice-C))+"  - "+EncodeColor(colorLime)+"Let your profit runs!","")


);
_SECTION_END();

//Magfied Market Price
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor( ParamColor("Color",colorBrightGreen) ); 
Hor=Param("Horizontal Position",590,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1); 
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True ); 
GfxSetBkMode( colorBlack );  
GfxSetTextColor(ParamColor("Color",colorYellow) ); 
GfxTextOut(""+DD+"  ("+xx+"%)", Hor , Ver+45 );
 


_SECTION_END();



H1 = SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ) );
L1 = SelectedValue( TimeFrameGetPrice( "L", inDaily, -1 ) );
C1 = SelectedValue( TimeFrameGetPrice( "C", inDaily, -1 ) );
H2 = SelectedValue( TimeFrameGetPrice( "H", inDaily, 0 ) );
L2 = SelectedValue( TimeFrameGetPrice( "L", inDaily, 0 ) );
O1 = SelectedValue( TimeFrameGetPrice( "open", inDaily, 0 ) );
F4 = 0;
D1 = ( H1 - L1 );
D2 = ( H2 - L2 );
F1 = D1 * 0.433;
F2 = D1 * 0.766;
F3 = D1 * 1.35;
if ( D2 <= F1 )
    F4 = F1;
else
    if ( D2 <= F2  )
        F4 = F2;
    else
        F4 = F3;

S_P = ( O1 - F4 );

B_P = ( O1 + F4 );

BP = ( L2 + F4 );

BPTGT = ( BP + ( BP * .0065 ) );//.0015 brokerage

BPSTPLS = ( BP - ( BP * .0085 ) );

SP = ( H2 - F4 );

SPTGT = ( SP - ( SP * .0065 ) );

SPSTPLS = ( SP + ( SP * .0085 ) );


p = ( H1 + L1 + C1 ) / 3;

s1 = ( H1 );

r1 = ( L1 );

r2 = SelectedValue( L2 );

s2 = SelectedValue( H2 );

//CONDITION


Filter =  Buy OR Sell;

AddColumn( IIf( Buy, 66, 1 ), "Buy", formatChar, 1, bkcolor = IIf( Buy, 43, 33 ) );

AddColumn( IIf( Sell, 83, 1 ), "Sell", formatChar, 1, bkcolor = IIf( Sell, 25, 32 ) );



AddColumn( C, "CMP", 1.2, colorDefault, colorLightBlue );

AddColumn( BP, "SELL PRICE", 1.2, colorDefault, colorGreen );

AddColumn( BPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown );

AddColumn( BPSTPLS, "STPLS BUY", 1.2, colorDefault, colorRed );

AddColumn( p, "PIVOT", 1.2, colorDefault, colorYellow );

AddColumn( SPSTPLS, "STPLS SELL", 1.2, colorDefault, colorRed );

AddColumn( SP, "SELL PRICE", 1.2, colorDefault, colorGreen );

AddColumn( SPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown );


AddColumn( H1, "PRE-HIGH" );

AddColumn( L1, "PRE-LOW" );

AddColumn( D1, "PRE-DIFF" );

AddColumn( F1, "0.433" );

AddColumn( F2, "0.766" );

AddColumn( F3, "1.35" );

AddColumn( H2, "D-HIGH" );

AddColumn( L2, "D-LOW" );

AddColumn( D2, "D-DIFF" );

AddColumn( F4, "SELECT FACT" );

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );

Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );


_SECTION_END();

_SECTION_BEGIN("MA1");
P1 = ParamField("Price field",-1);
Periods1 = Param("Periods1", 4, 2, 200, 1, 4 );
Plot( MA( P1, Periods1 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ),
ParamStyle("Style") );
_SECTION_END();
P2 = ParamField("Price field",-1);
Periods2 = Param("Periods2", 1, 2, 200, 1, 1 );
Plot( MA( P2, Periods2 ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ),
ParamStyle("Style") );


PlotShapes( Buy * shapeUpArrow + Sell * shapeDownArrow, IIf( Buy, colorWhite, colorYellow ) );




Cover=Buy;
Short=Sell;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
no=Param( "Swing", 8, 1, 55 );
tsl_col=ParamColor( "Color", colorLightGrey );
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);
tsl=IIf(avn==1,sup,res);

no =  Optimize("TSL",Param("A (Change To Optimise)",10, 1, 55 ,1),1, 55 ,1);

tsl_col=ParamColor( "Color", colorLightGrey );
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);
dtsl=IIf(avn==1,sup,res);
SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Sell AND NOT Sell AND NOT Cover;
SellSL=ValueWhen(Short,DTSL,1);
BuySL=ValueWhen(Buy,DTSL,1);
BuyDifference= BuyPrice - BuySL;
SellDifference = SellSL - SellPrice;

tar1 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + BuyDifference), (SellPrice - SellDifference));
tar2 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (2*BuyDifference)), (SellPrice - (2*SellDifference)));
tar3 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (4*BuyDifference)), (SellPrice - (4*SellDifference)));


CloseAtEnd = ParamToggle("Close Positions EOD", "No|Yes");
stopreverse =ParamToggle("Switch To Stop And Reverse","No|Yes",0);
Trend = ATR(21) < StDev (C,21);
Range = ATR(21) > StDev (C,21);
no=10;
C13=20;
C14=2.1;
C15=12;

tsl_col=ParamColor( "Color", colorLightGrey );
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);
dtsl=IIf(avn==1,sup,res);

SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Sell AND NOT Sell AND NOT Cover;
SellSL=ValueWhen(Short,DTSL,1);
BuySL=ValueWhen(Buy,DTSL,1);
BuyDifference= BuyPrice - BuySL;
SellDifference = SellSL - SellPrice;

tar1 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + BuyDifference), (SellPrice - SellDifference));
tar2 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (2*BuyDifference)), (SellPrice - (2*SellDifference)));
tar3 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (4*BuyDifference)), (SellPrice - (4*SellDifference)));
buyach1 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar1, 0);
buyach2 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar2 , 0);
buyach3 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar3, 0);
 
sellach1 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar1 , 0);
sellach2 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar2, 0);
sellach3 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar3, 0);



//Settings for exploration

Filter=Buy OR Short;
AddColumn( IIf( Buy, 66 , 83 ), "Signal", formatChar, colorDefault, IIf( Buy , colorGreen, colorRed ) );
AddColumn(Close,"Entry Price",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(dtsl,"Stop Loss",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar1,"Target 1",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar2,"Target 2",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar3,"Target 3",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(Volume,"Volume",1.0, colorDefault, IIf ((Volume > 1.25 * EMA( Volume, 34 )),colorBlue,colorYellow));




//Short = Sell;
//Cover = Buy;

//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);

GraphXSpace = 5;
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 280;
 
y = pxHeight; 
dist = 2*ATR(10);
dist1 = 3*ATR(10);
i=BarCount; 
bars = i;

messageboard = ParamToggle("Message Board","Show|Hide",1);
if(messageboard)
{
for( i = 0; i < BarCount; i++ )
{
    if( Buy[i] )
    {
        // PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L[i]*1.005) + "\nSL= " + (L[i]*0.9975), i, L[ i ]-dist[i], colorGreen, colorWhite );
        
        // Signal Display Panel //

       SellPrice=ValueWhen(Sell,C,1);
       BuyPrice=ValueWhen(Buy,L[ i ]);
       Long=Flip(Buy,Sell);
        Shrt=Flip(Sell,Buy );
        BuyStop2 = L[i]*0.9975;
        BuyTP1 = L[i]*1.070;
        BuyTP2 = L[i]*1.050;
        BuyTP3 = L[i]*1.035;
buyach1 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP3, 0);
buyach2 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP2, 0);
buyach3 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP1, 0);
        GfxSelectFont( "Tahoma", 13, 100 );
        GfxSetOverlayMode( mode = 0 );
        GfxSelectPen( colorBrightGreen, 3 );
        GfxSelectSolidBrush( colorBrightGreen);
        GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
       GfxSetTextColor( colorGold );        
       GfxTextOut( ( " Trading System "),73,y-165);
        GfxTextOut( (" "),27,y-160);
        GfxSetBkMode(1);
        GfxSelectFont( "Arial", 10, 700, False );
        GfxSetTextColor( colorBlue );
        GfxSetTextAlign(0);
        GfxSelectFont( "Tahoma", 13, 100 );

   GfxTextOut( WriteIf(L[ i ], "Buy Above: "+L[ i ],""), 13, y-140);
   GfxSetTextColor( colorGold );    
   GfxTextOut( WriteIf(BuyStop2, "Long SL: "+(BuyStop2),""), 13, y-120);
   GfxSetTextColor( colorWhite );    
   GfxTextOut( WriteIf(BuyTP1, "Buy TGT1: "+(BuyTP3),""), 13,y- 100);
   GfxTextOut( WriteIf(BuyTP2, "Buy TGT2: "+(BuyTP2),""), 13,y- 80); 
   GfxTextOut( WriteIf(BuyTP3, "BuyTGT3: "+(BuyTP1),""), 13,y- 60);   
   GfxSetTextColor( colorViolet );    
   GfxTextOut( ("Current P/L : " + WriteVal(IIf(Buy ,(C-BuyPrice),(C-BuyPrice)),2.2)), 88, y-22);
  GfxTextOut( ("Buy  Signal came " + (BarCount-bars +1) * Interval()/2 + " mins ago"), 13, y-40) ;   
GfxTextOut
( ("" + WriteIf (buyach1, " Done: "+BuyTP3,"")), 160, y-100);
GfxTextOut
( ("" + WriteIf (buyach2, " Done: "+BuyTP2,"")), 160, y-80);
GfxTextOut
( ("" + WriteIf (buyach3, " Done: "+BuyTP1,"")), 160, y-60);        
        // END of Signal Display Panel //
    }
    if( Sell[i] )
    {
        // PlotText( "Sell:" + H[ i ] + "\nT= " + (H[i]*0.995) + "\nSL= " + (H[i]*1.0025), i, H[ i ]+dist1[i], colorRed, colorWhite );
        
        // Signal Display Panel //
        SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,H[ i ]);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
       SellStop2 = H[i]*1.0025;
        SellTP1 = H[i]*0.978;
        SellTP2 = H[i]*0.982;
        SellTP3 = H[i]*0.988;
sellach1 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP3 , 0);
sellach2 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP2, 0);
sellach3 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP1, 0);

        GfxSelectFont( "Tahoma", 13, 100 );
        GfxSetOverlayMode( mode = 0 );
        GfxSelectPen( colorRed, 3 );
        GfxSelectSolidBrush( colorRed );
         GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
        
        GfxTextOut( (" "),27,y-160);
        GfxSetBkMode(1);
        GfxSelectFont( "Arial", 10, 700, False );
        GfxSetTextColor( colorWhite );
        GfxSetTextAlign(0);
        GfxSelectFont( "Tahoma", 13, 100 );
        GfxSetTextColor( colorGold );      
        GfxTextOut( ( " Trading System "),73,y-165);
        GfxSetTextColor( colorWhite ); 
       GfxTextOut( WriteIf(H[ i ], "Sell Below: "+H[ i ],""), 13, y-140);
       GfxSetTextColor( colorGold );     
       GfxTextOut( WriteIf(SellStop2, "Short SL: "+(SellStop2),""), 13, y-120);     
       GfxSetTextColor( colorBlue );   
       GfxTextOut( WriteIf(SellTP1, "Short TGT1: "+(SellTP3),""), 13, y-100);
       GfxTextOut( WriteIf(SellTP2, "Short TGT2: "+(SellTP2),""), 13, y-80);
       GfxTextOut( WriteIf(SellTP3, "Short TGT3: "+(SellTP1),""), 13, y-60);
       GfxSetTextColor( colorGold );
       GfxTextOut( ("Current P/L : " + WriteVal(IIf(Sell ,(SellPrice-C),(SellPrice-C)),2.2)), 88, y-22);
        GfxTextOut( ("sell Signal came " + (BarCount-bars +1) * Interval()/2 + " mins ago"), 13, y-40) ;    
       GfxTextOut
( ("" + WriteIf (sellach1, "  Done: "+SellTP3,"")), 160, y-100);
GfxTextOut
( ("" + WriteIf (sellach2, "  Done: "+SellTP2,"")), 160, y-80);
GfxTextOut
( ("" + WriteIf (sellach3, "  Done: "+SellTP1,"")), 160, y-60);
// END of Signal Display Panel //
    }}}



Long=Flip(Buy,Sell); 
Shrt=Flip(Sell,Buy); 

BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);


Edc=(
WriteIf (Buy AND Ref(shrt,-1), " BUY @ "+C+"  ","")+ 
WriteIf (Sell AND Ref(Long,-1), " SEll @ "+C+"  ","")+
WriteIf(Sell , "Last Trade Profit Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy  , "Last Trade Profit Rs."+(SellPrice-C)+"",""));

//============== TITLE ==============
_SECTION_BEGIN("Title");
no=Param( "Swing", 6, 1, 55 );
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);
tsl=IIf(avn==1,sup,res);
dec = (Param("Decimals",2,0,7,1)/10)+1;
if( Status("action") == actionIndicator ) 
(
Title = EncodeColor(55)+  Title = Name() + "     " + EncodeColor(32) + Date() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " +
	EncodeColor(55)+ "     Open = "+ EncodeColor(52)+ WriteVal(O,dec) + 
	EncodeColor(55)+ "     High = "+ EncodeColor(5) + WriteVal(H,dec) +
	EncodeColor(55)+ "      Low = "+ EncodeColor(32)+ WriteVal(L,dec) + 
	EncodeColor(55)+ "    Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
	EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal (V ,1.25)




+"\n"+EncodeColor(colorBrightGreen)+

WriteIf (Buy , "Signal: Go Long - Entry Price: "+WriteVal(C)+" - Traget: "+WriteVal((BuyPrice-tsl)+BuyPrice)

+" - StopLoss:"+WriteVal(tsl)+"  "

,"")+

"\n"+EncodeColor(colorRed)+
WriteIf (Sell , "Signal: Go Short - Entry Price: "+WriteVal(C)+" - Target: "+WriteVal((tsl-SellPrice)-SellPrice)+" - StopLoss:"+WriteVal(tsl)+" ","")+
EncodeColor(colorTurquoise)+
WriteIf(Long AND NOT Buy, "Trade: Long - Entry Price: "+WriteVal((BuyPrice))+" - Profit: "+WriteVal((C-BuyPrice))+" "+EncodeColor(colorLime)+"Let your profit runs!","")+
EncodeColor(colorLightOrange)+
WriteIf(shrt AND NOT Sell, "Trade: Short - Entry Price: "+WriteVal((SellPrice))+" - Profit: "+WriteVal((SellPrice-C))+"  - "+EncodeColor(colorLime)+"Let your profit runs!","")


);
_SECTION_END();


if (messageboard == 0 )
{
if( Status("action") == actionIndicator ) 
(

Title = EncodeColor(55)+  Title = Name() +
"      " + EncodeColor(5) + "{{INTERVAL}}  " + EncodeColor(colorSkyblue) +
 "   " + Date() +"  "+"\n" +EncodeColor(55) +"Open-"+EncodeColor(52)+O+EncodeColor(55)+" High-"+EncodeColor(5)+H+"  "+EncodeColor(55)+"Low-"+EncodeColor(32)+L+"  "+EncodeColor(55)+"Close-"+EncodeColor(52)+C+"  "+EncodeColor(55)+ "Volume= "+EncodeColor(52)+ WriteVal(V)+"\n"+"\n"+ 

EncodeColor(colorLime)+
WriteIf (Buy, "Action: Go Long At "+C+" - SL " +DTSL,"")+
WriteIf (Short, "Action: Go Short At "+C+" - SL " +DTSL,"")+
WriteIf(Long AND NOT Buy, "Action : Long Taken At "+(BuyPrice)+" - Trail SL @ " + DTSL + "","")+
WriteIf(shrt AND NOT Sell, "Action : Short Taken At "+(SellPrice)+" - Trail SL @ " + DTSL + "","")+
WriteIf (Sell AND NOT Short, "Exit Long At "+C,"")+
WriteIf (Cover AND NOT Buy, "Exit Short At "+C,"")+
WriteIf(NOT Long AND NOT Buy AND NOT shrt AND NOT Sell, "Action: Not In A Trade - RELAX!!!","")+"\n"+ 
WriteIf(Long AND NOT Buy, "Profit/Loss: "+(C-BuyPrice)+" Points","")+
WriteIf(shrt AND NOT Sell, "Profit/Loss: "+(SellPrice-C)+" Points","")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 1: "+tar1,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 2: "+tar2,"")+"\n"+
WriteIf(Long OR Buy OR Shrt OR Short, "Target 3: "+tar3,"")+"\n"+
WriteIf(buyach1, "Target 1 Done: "+tar1,"")+
WriteIf(sellach1, "Target 1 Done: "+tar1,"")+"\n"+
WriteIf(buyach2, "Target 2 Done: "+tar2,"")+
WriteIf(sellach2, "Target 2 Done: "+tar2,"")+"\n"+
WriteIf(buyach3, "Target 3 Done: "+tar3,"")+
WriteIf(sellach3, "Target 3 Done: "+tar3,""));
}
for( i = 0; i < BarCount; i++ )
{
 if( Buy[i] )
 {

OUTcolor = ParamColor("Outer Panel Color",colorTeal);
INUPcolor = ParamColor("Inner Panel Upper",colorDarkGrey);
INDNcolor = ParamColor("Inner Panel Lower",colorDarkOliveGreen);
TitleColor = ParamColor("Title Color ",colorBlack);
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
if( Sell[i] )
{
OUTcolor = ParamColor("Outer Panel Color",colorTeal);
INUPcolor = ParamColor("Inner Panel Upper2",colorDarkTeal);
INDNcolor = ParamColor("Inner Panel Lower2",colorPlum);
TitleColor = ParamColor("Title Color ",colorBlack);
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
}
 

amanfree

Active Member
#8
johny bhai please give me the afl as well
 

johnnypareek

Well-Known Member
#9
johny bhai please give me the afl as well
HTML:
_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop",colorBlack),
ParamColor("BgBottom",colorBlack),ParamColor("titl eblock",colorDarkTeal ));
_SECTION_END();


_SECTION_BEGIN("Flower");

Title = StrFormat("\\c02 {{NAME}} | {{DATE}} | Open : %g | High : %g | Low : %g | Close : %g | Change = %.1f%% | Volume = " +WriteVal( V, 1.0 ) +" {{VALUES}}",O, H, L, C, SelectedValue( ROC( C, 1 )) );

_SECTION_END();


_SECTION_BEGIN("Sup/Res Detail");
SupResPeriod = Param("LookBack Period", 50, 0, 200,1);
SupResPercentage = Param("Percentage", 100, 0, 200,1);
PricePeriod = Param("Price Period", 16, 0, 200,1);
SupportLinecolor = ParamColor( "Support Color", colorGreen );
SupportLinestyle = ParamStyle("Support Style", styleThick|8|styleNoLabel);
ResistanceLinecolor = ParamColor( "Resistance Color", colorRed );
Resistancestyle = ParamStyle("Resistance Style", styleThick|8|styleNoLabel);
_SECTION_END();

_SECTION_BEGIN("Line Detail");
OverBought = Param("OverBought Above", 200, 0, 400,1);
OverSold = Param("OverSold Bellow", -200, -400, 0,1);
_SECTION_END();

_SECTION_BEGIN("Trend Bought/Sold Detail");
Smoother = Param("Trend Smoother", 5, 5, 20);
upcolor = ParamColor( "UpTrend Color", colorGreen );
Downcolor = ParamColor( "DownTrend Color", colorRed );
_SECTION_END();

_SECTION_BEGIN("Circle Detail");
Warningcolor = ParamColor( "Warning/Watch Signal", colorYellow );
WatchColor = ParamColor( "Accumulation Zone", colorWhite );
EntryColor = ParamColor( "Entry Signal", colorAqua );
ProfitTakeColor = ParamColor( "Distribution Zone", colorYellow );
ExitColor = ParamColor( "Exit Signal", colorRed );
_SECTION_END();

_SECTION_BEGIN("Swing Sup/Res");
Lookback=SupResPeriod;
PerCent=SupResPercentage;
Pds =PricePeriod;
Var=MACD();
Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
Ut=Wilders(Up,Pds);
Dt=Wilders(Dn,Pds);
RSIt=100*(Ut/(Ut+Dt));
A1=RSIt; B2=RSI(pds); C3=CCI(pds); D4=StochK(pds); E5=StochD(pds);
F6=MFI(pds); G7=Ultimate(pds); H8=ROC(C,pds);
Osc=C3;
Value1 = Osc;
Value2 = HHV(Value1,Lookback);
Value3 = LLV(Value1,Lookback);
Value4 = Value2 - Value3;
Value5 = Value4 * (PerCent / 100);
ResistanceLine = Value3 + Value5;
SupportLine = Value2 - Value5;
baseline=IIf( Osc < 100 AND Osc > 10 ,50 ,IIf( Osc < 0 ,0,0));
Plot(ResistanceLine,"",SupportLinecolor,SupportLinestyle);
Plot(SupportLine,"",ResistanceLinecolor,Resistancestyle);
_SECTION_END();

_SECTION_BEGIN("Entry/Exit Detail");
n=Smoother;
ys1=(High+Low+Close*2)/4;
rk3=EMA(ys1,n);
rk4=StDev(ys1,n);
rk5=(ys1-rk3)*200/rk4;
rk6=EMA(rk5,n);
UP=EMA(rk6,n);
DOWN=EMA(up,n);
Oo=IIf(up<down,up,down);
Hh=Oo;
Ll=IIf(up<down,down,up);
Cc=Ll;
barcolor2=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),upcolor,IIf(up>down,upcolor,downcolor));
SetBarFillColor( barcolor2);
PlotOHLC( Oo,hh,ll,Cc, "Matrix - Accumulation or Bought/Distribution or Sold", barcolor2, styleCandle);
Buy=Cross(up,OverSold);
Sell=Cross(OverBought,up);
PlotShapes (IIf(Buy, shapeSmallCircle, shapeNone) ,EntryColor, layer = 0, yposition = -220, offset = 1 );
PlotShapes (IIf(Sell, shapeSmallCircle, shapeNone) ,ExitColor, layer = 0, yposition = 220, offset = 1 );


Buy=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),1,IIf(up>down,1,0));
Short = barcolor2=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),0,IIf(up>down,0,1));
Buy = ExRem(Buy ,Short);
Short = ExRem(Short,Buy);

PlotShapes(Buy * shapeUpArrow , colorRed,0,Ll-25);
PlotShapes(Short * shapeDownArrow , colorLime,0,Hh+25);





pd=Param("Pd",2,1,10);
Plot(Ref(MA(Hh,pd),-1),"",colorGreen,styleThick,styleNoLabel);
Plot(MA(Ll,pd),"",colorRed,styleThick,styleNoLabel );

x=(Hh+Ll)/2;



_SECTION_END();
_SECTION_BEGIN("Overbought/Oversold/Warning Detail");
n=Smoother;
ys1=(High+Low+Close*2)/4;
rk3=EMA(ys1,n);
rk4=StDev(ys1,n);
rk5=(ys1-rk3)*210/rk4;
rk6=EMA(rk5,n);
UP=EMA(rk6,n);
DOWN=EMA(up,n);
Oo=IIf(up<down,up,down);
Hh=Oo;
Ll=IIf(up<down,down,up);
Cc=Ll;
barcolor2=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),colorGreen,IIf(up>down,colorGreen,colorRed));

UP=EMA(rk6,n);
UPshape = IIf(UP >= OverBought OR UP<=OverSold, shapeHollowSmallCircle, shapeNone);
UPColor = IIf(UP>=210, ProfitTakeColor, IIf(UP<=-210, WatchColor, Warningcolor));
Plot(UP, "", colorGrey50, styleThick|stylehidden);
PlotShapes(UPShape, UPColor, 0, UP, 0);
_SECTION_END();

_SECTION_BEGIN("Plot Lines");
Plot(OverBought,"",colorWhite,styleLine|styleNoLabel);
Plot(0,"",colorWhite,styleDashed|styleNoLabel);
Plot(OverSold,"",colorWhite,styleLine|styleNoLabel );
_SECTION_END();

GraphXSpace =10;
enjoy
 
Thread starter Similar threads Forum Replies Date
M AmiBroker 1
V AmiBroker 12
shanki99 AmiBroker 3
iTrade AmiBroker 7
P AmiBroker 2

Similar threads