Skip to main content

Simple Buy Sell for Amibroker (AFL)

Divyesh almost 14 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 5)
  • Tags:
    trading system, amibroker

As i had said i am not AFL Progremmer….!
I have mixed codes and create some easy formula which is based on color of chart back color and candle color….!
two stretegy is here…..

1, buy/sell on back ground color – buy when turns green and sell when turns red.
2, buy/sell on candle color – buy when candal turns green and sell when candle turns red….
3, more powere when both turns same…..

to the Admin….i m unable to upload PNG or JPG format screen shop….!!!

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Price ADX");
function PercentR( periods )
{ return -100 * ( HHV( H, periods ) - C )/( HHV( H, periods ) - LLV( L, periods
) ); }
range = Param("Periods", 14, 2, 200, 1 );
 ADX(range);
 PDI(range) ;
 MDI(range);
Plot( C, "Close", IIf( PDI(range) > MDI(range), ParamColor("Up Color",colorLime), ParamColor("Down Color", colorRed ) ), styleCandle|styleThick,styleNoTitle |
ParamStyle("Style") | GetPriceStyle() ); 
Bull_Trend=(PercentR( Param("Periods", 14, 2, 100 ) )> -30);
Bear_Trend=(PercentR( Param("Periods", 14, 2, 100 ) )< -70);
_SECTION_END();


_SECTION_BEGIN("colorMeBad"); // added new lines of code

flowerClose =EMA((O+H+L+C)/4,3); // Woodie 
m = 17;
a=MA(flowerClose,m)+abs(MA(flowerClose,m)-Ref(MA(flowerClose,m),-1));
b=MA(flowerClose,m)+MA(flowerClose,m)-Ref(MA(flowerClose,m),-1);
balance=IIf(MA(flowerClose,m)<b,b,MA(flowerClose,m ));
pma=balance;
sig = MA(2*balance-EMA(flowerClose,3),1);
//Plot(sig,"Signal", 40, 1); //40 instead of 7
s=(pma>sig);
pm=MA(flowerClose,5);
pmcolor=IIf(pm>Ref(pm,-1),27,32); //42 ins colorLightYellow,13 insrd colorRed
//Plot(pm,"CMB", pmcolor,4);

_SECTION_END();



_SECTION_BEGIN("Title");

DODay = TimeFrameGetPrice("O", inDaily);
DHiDay = TimeFrameGetPrice("H", inDaily); 
DLoDay = TimeFrameGetPrice("L", inDaily); 

Title = EncodeColor(colorWhite)+"* SAI STOCK BROKING 09825340778 *  "+EncodeColor(colorWhite)+ Name() + ", " + Interval(2) + ", " + Date() + 
EncodeColor(colorWhite)   +  "\nO " + EncodeColor(colorWhite) + O + 

 ",   H :  "   + H + 
 ",   L  :  " + L + 
 ",   C  :  "  + C +
EncodeColor(colorWhite)+ "\n Day-Open : " +DODay + "  Day-High : " +DHiDay + "  Day-Low : " + DLoDay+



_SECTION_BEGIN("Background text");
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
SetChartBkColor( LastValue(pmcolor) );
GfxSetBkMode(transparent=-1);
GfxSetOverlayMode(1);
GfxSelectFont("Candara", 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( ColorRGB (217,217,213));
GfxTextOut( "By", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont("Candara", Status("pxheight")/C13*0.5 );
GfxSetTextColor( ColorRGB (217,217,213));
GfxTextOut( "Sai Stock Broking 09825340778", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
_SECTION_END();
_SECTION_BEGIN("Price Line");

PriceLineColor=ParamColor("PriceLineColor",ColorRGB(82,82,82));
PriceLevel = ParamField("PriceField", field = 3 ); 

Daysback = Param("Bars Back",500,10,900,1); 
FirstBar = BarCount - DaysBack; 
YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null); 

Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel|styleThick,maskAll)); 

side = Param("side",1,0,1000,1);

dist = 0; 

for( i = 0; i < BarCount; i++ ) 
{ 
if(i+side== BarCount) PlotText( "\n " + PriceLevel[ i ], i, YY[ i ]-dist[i], colorAqua ); 
} 

_SECTION_END();

4 comments

3. Divyesh
almost 14 years ago

to everyone….!
15 min chart will give good result….!
in 5 min chart, more speculation and chance of more tread and loss….!

4. shekar
almost 14 years ago

shekar.Mangalore.

really fine one.kindlly give me tgts,stoploss and buysell arrows at your best accuracy

Leave Comment

Please login here to leave a comment.