AmiBroker formula Language

HULK

Active Member
Thanks Hulk.


For good afl.


pls tell me if you can give the password to afl. and protect it.
Convert AFL into DLL so that core functionality of the AFL is hidden from the viewer and at the same time, is available across entire AmiBroker platform.

You need programming language like C++ which lets you generate a DLL. Also, the AmiBroker Development Kit (ADK) is required for the conversion.


Enjoy ;)


HULK
 
Check this out.Hope it serves your purpose.

http://www.dotnetforab.com/



Sell your trading system safely
.NET for AmiBroker is a easy solution for black box trading system developers to protect, license and sell their systems. AFL scripts can be easily and quickly converted to .NET plugins leaving no public trading logic in AFL files. .NET plugins can be protected and licensed by commercial protection tools like IntelliLock, CliSecure Licensing, .NET Licensing Pro, etc. The protected plugins can be made public. Only customers who were given license for their machines can use the protected .NET Plug-Ins.
 
Hi friedns,

I want to change these support and Resistance color.
I want support color is green and resistance color is red.
If you can pls try these.

_SECTION_BEGIN("Support_and_Resistance");
/* SUPPORT AND RESISTANCE */
/* AFL Code - Prakash Shenoi */
LB= Param("Look Back Periods",10,1,30,1);
R=ValueWhen(Cross(MA(C,LB),C),HHV(H,LB),1);
S=ValueWhen(Cross(C,MA(C,LB)),LLV(L,LB),1);
Color=IIf(O>C,colorWhite,colorWhite);
Plot (R,"Resz",22,8+16);
Plot (s,"Supp",19,8+16);
GraphXSpace=4;
_SECTION_END();
 
Hi friedns,

I want to change these support and Resistance color.
I want support color is green and resistance color is red.
If you can pls try these.

_SECTION_BEGIN("Support_and_Resistance");
/* SUPPORT AND RESISTANCE */
/* AFL Code - Prakash Shenoi */
LB= Param("Look Back Periods",10,1,30,1);
R=ValueWhen(Cross(MA(C,LB),C),HHV(H,LB),1);
S=ValueWhen(Cross(C,MA(C,LB)),LLV(L,LB),1);
Color=IIf(O>C,colorWhite,colorWhite);
Plot (R,"Resz",22,8+16);
Plot (s,"Supp",19,8+16);
GraphXSpace=4;
_SECTION_END();
 

johnnypareek

Well-Known Member
hi,

below is code hope u want this.

_SECTION_BEGIN("Support_and_Resistance");
/* SUPPORT AND RESISTANCE */
/* AFL Code - Prakash Shenoi */
LB= Param("Look Back Periods",10,1,30,1);
R=ValueWhen(Cross(MA(C,LB),C),HHV(H,LB),1);
S=ValueWhen(Cross(C,MA(C,LB)),LLV(L,LB),1);
Color=IIf(O>C,colorWhite,colorBlack);
Plot (R,"Resz",4,8+16);
Plot (s,"Supp",5,8+16);
GraphXSpace=4;
_SECTION_END();
 
Hi Friends,

I want one help.
I have one template for metastock. These chart show Buy sell signal. I want to create these template for amibroker. I create one afl for amibroker But these is not 100% accurate. It near 95% accurate Buy sell call is mismatch Our afl give buy call before or after one candle.


Here i show nifty chart from 28 March 2011 to 30 sept 2011 in metastock format.

Here i show nifty chart from 28 March 2011 to 30 Sept 2011 im amibroker format.

Diffrance Between to Buy sell call date in meta and ami is

Signal Meta date amibroker date

sell 19-04-2011 26-04-2011.
Buy 31-05-2011 31-05-2011.
Sell 16-06-2011 16-06-2011.
Buy 28-06-2011 27-06-2011.
Sell 15-07-2011 12-07-2011.
Buy 06-09-2011 02-09-2011.
Sell 23-09-2011 23-09-2011.

These is the Buy and sell signal date for metastock and amibroker i want to mach amibroker signal to meta stock.
Here i give amibroker afl so if you can pls try these with change different time period. and change amibroker afl.

_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*9;
VS_raw = 2.5 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Buy=upline;
Sell=dnline;

Col = IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack));

Plot(C, "", col, styleBar | styleThick );

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

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBlack, colorBlack ),0, IIf( Buy, Low, High ) );


Thanks
 
Last edited:
I want combine two afl.

One afl is candalstick chart with Buy Sell Signal.

Afl is belowe.

_SECTION_BEGIN("Ensign Volatility Stop");

// Ensign Volatility Stop
// get the multiple of 9 period EMA of ATR_Ensign

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
k=Param("multiplication factor", 1,0.5,5,0.1);

period=k*5;
VS_raw = 2.2 * EMA(ATR(1), period);

// for longs, VS line is below price
loline = VS_below_price = HHV(Close, period) - VS_raw;

// for shorts, VS line is above price
hiline = VS_above_price = LLV(Close, period) + VS_raw;
between = IIf (C < hiline AND C > loline, 1, 0);
up = IIf(C > hiline OR (H > Ref(H, -1) AND H > hiline), 1, 0);
dn = IIf(C < loline OR (L < Ref(L, -1) AND L < loline), 1, 0);
upcond = IIf(between AND BarsSince(up) < BarsSince(dn) , 1, 0);
dncond = IIf(between AND BarsSince(dn) < BarsSince(up) , 1, 0);
upline = IIf(up OR upcond, loline, Null);
dnline = IIf(dn OR dncond, hiline, Null);

Buy=upline;
Sell=dnline;

Col = IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack));

Plot(C, "", col, styleBar | styleThick );

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

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBrightGreen, colorRed ),0, IIf( Buy, Low, High ) );


Second afl is SUPPORT AND RESISTANCE These afl is show All support and Resistance.

The afl is below

//|-----------------------------------------------------------------------------------------
//|PatternExplorer.com - Support & Resistance
//|Copyright 2007, PatternExplorer.com
//|http://www.PatternExplorer.com
//|e-mail: [email protected]
//|-----------------------------------------------------------------------------------------
FormulaName = "PE - S & R";

SetChartOptions( 0, chartShowDates | chartLogarithmic | chartWrapTitle );
#pragma nocache
#include_once <\PEInc\PatternExplorer_f0.afl>
#include_once "Formulas\PatternExplorer\#Defaults & Mods\PE - Defaults.afl"
#include_once "Formulas\PatternExplorer\#Defaults & Mods\PE - Mods.afl"
/*******************************************************************************************/
AddCustomCodeBeforePE();
/*******************************************************************************************/

_SECTION_BEGIN( "Main Parameters" );
AddparamUsefromChart( def_UseFromChart );
Sensitivity = Param( "Sensitivity", 10, 0, 100, 1 );

if ( InChart )
StaticVarSet( "FYIOKU", Sensitivity );

if ( inAA AND Usefromchart )
Sensitivity = StaticVarGet( "FYIOKU" );

DisRange = Param( "Plot 'far away' Lines Trigger", 3, 0, 10, 0.5 );

Color_SL = ParamColor( "Support", def_Color1 );

Color_RL = ParamColor( "Resistance", colorRed );

_SECTION_END();

/*******************************************************************************************/
#include_once <\PEInc\PatternExplorer_1.afl>
#include_once <\PEInc\Lib\PatternExplorer_f15.afl>
/*******************************************************************************************/
BS = break_G1_val == 1 OR break_G2_val == 1;

SS = break_G1_val == -1 OR break_G2_val == -1;

Buy = def_Buy AND BS;

Sell = SS;

/*******************************************************************************************/
Filter = def_Filter AND BarIndex() == LastValue( BarIndex() ) AND NOT GroupID() == 253;

Filter = Filter AND ( Buy OR Sell );

/*******************************************************************************************/
Addefaultcolumns();

Adddefaultcolumns( 2, 1 );

AddTextColumn(
WriteIf( break_G1_val == -1, "Break",
WriteIf( break_G1_val == 1, "Break", "" ) ), "Minor Levels", 1.2,
IIf( break_G1_val == 1, colorGreen, IIf( break_G1_val == -1, colorRed, colorBlue ) ) );

AddTextColumn(
WriteIf( break_G2_val == -1, "Break",
WriteIf( break_G2_val == 1, "Break", "" ) ), "Major Levels", 1.2,
IIf( break_G2_val == 1, colorGreen, IIf( break_G2_val == -1, colorRed, colorBlue ) ) );

AddTextColumn( FullName(), "Full name" );

/*******************************************************************************************/
Plot( IIf( x >= XT1 & RT1 &NOT T1 == 0, T1, -1e10 ), "T1", IIf( LastValue( C ) < T1, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XT2 & RT2 &NOT T2 == 0, T2, -1e10 ), "T2", IIf( LastValue( C ) < T2, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XT3 & RT3 &NOT T3 == 0, T3, -1e10 ), "T3", IIf( LastValue( C ) < T3, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XT4 & RT4 &NOT T4 == 0, T4, -1e10 ), "T4", IIf( LastValue( C ) < T4, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XT5 & RT5 &NOT T5 == 0, T5, -1e10 ), "T5", IIf( LastValue( C ) < T5, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XP1 & RP1 &NOT P1 == 0, P1, -1e10 ), "P1", IIf( LastValue( C ) < P1, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XP2 & RP2 &NOT P2 == 0, P2, -1e10 ), "P2", IIf( LastValue( C ) < P2, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XP3 & RP3 &NOT P3 == 0, P3, -1e10 ), "P3", IIf( LastValue( C ) < P3, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XP4 & RP4 &NOT P4 == 0, P4, -1e10 ), "P4", IIf( LastValue( C ) < P4, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XP5 & RP5 &NOT P5 == 0, P5, -1e10 ), "P5", IIf( LastValue( C ) < P5, Color_RL, Color_SL ), 1 + 2048 + styleNoTitle );

Plot( IIf( x >= XT6 & RT6 &NOT T6 == 0, T6, -1e10 ), "T6", IIf( LastValue( C ) < T6, Color_RL, Color_SL ), 8 + 2048 + styleNoTitle );

Plot( IIf( x >= XT7 & RT7 &NOT T7 == 0, T7, -1e10 ), "T7", IIf( LastValue( C ) < T7, Color_RL, Color_SL ), 8 + 2048 + styleNoTitle );

Plot( IIf( x >= XP6 & RP6 &NOT P6 == 0, P6, -1e10 ), "P6", IIf( LastValue( C ) < P6, Color_RL, Color_SL ), 8 + 2048 + styleNoTitle );

Plot( IIf( x >= XP7 & RP7 &NOT P7 == 0, P7, -1e10 ), "P7", IIf( LastValue( C ) < P7, Color_RL, Color_SL ), 8 + 2048 + styleNoTitle );

/*******************************************************************************************/
ToolTip = def_ToolTip;

/*******************************************************************************************/
AddCustomCodeAfterPE();

/*******************************************************************************************/
Title = "PatternExplorer.com - Support & Resistance" + default_priceTitle + EncodeColor( IIf( NOT AnZ, def_Text2, colorRed ) ) + ",Sensitivity = " + WriteVal( Sensitivity, 1 ) + " " + EncodeColor( colorRed ) + WriteIf( NOT AnZ, "", " NO POINTS AVAILABLE -> REDUCE SENSITIVITY " );


Any one can combine these two afl.
If price is 5200 on bar chart.
Support is 5100 and resitance is 5400.
i want support resistance price on bar chart.
Support means stop loss and resitance means target.
Means current nifty trade 5200 stop loss is 5100 and target is 5400.
these information is show on bar chart without support and resitance chart.

If any one can do these pls try.

Thanks
 
Dear All I need Help Of u To create Code (AFL) For Close All (Buy/Sell) Open Position At End Of The Day

*1) Close All Open Position At End Of Trading Day
For Example:- If my Position Ya Last Signal in Sell Then Next Signal At End Of Trading session's Last Minuit is give Buy Signal And Same in opposite Side if my Position ya Last Signal In Buy Then Next Signal At End Of Trading session's Last Minuit Is Sell
*2) We can Set Closing Time As Our Choice by parameters
 
_SECTION_BEGIN("Price ");

Plot(C, "", IIf(C > O, colorBrightGreen, colorRed), ParamStyle("Price Style", styleCandle, maskPrice));

Title = FullName()+" - "+Name()+"\nO:"+O+", H:"+H+", L:"+L+", C:"+C;
_SECTION_END();

_SECTION_BEGIN("EMA");

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

Buy=Cross(C, EMA( P, Periods));
Sell=Cross(EMA( P, Periods),C);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorCu stom11);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colo rCustom12);

_SECTION_END();

PLease Help I need Code Here For Exit All position At End OF The Day (3.29pm) For Becktesting Please Please please Help
 

Similar threads