Amibroker AFL- Profit & Stoploss Trigger for Strategy
This page shows you step-wise how to turn any good Amibroker AFL into an intraday trading strategy with profit and stoploss trigger.
How to Use Profit & Stoploss Trigger (AFL)
Step 1: Click here to download the AFL file. Save it on standard location like desktop for convenient use in future.
Step 2: Apply your AFL strategy on chart which you want to use for AFL trading. You can also download an AFL strategy from the following articles:
Step 3: Drag-Drop the intraday.afl on your strategy chart. Right-click on chart to open parameter window.
Parameters for Setting Profit & Stoploss Trigger
StopLoss: It applies a stoploss trigger for current trade. The trigger is calculated from the closing price of signal generation candle. Example: If supertrend generates buy signal at 7800, and you apply stoploss of 40, it will trigger the stoploss @ 7760. The SL is plotted as a thick line on chart. Leave it to 0 if you do not want to apply SL.
Profit Target: It applies the profit target similar to the stoploss trigger.
Intraday Mode (YES/NO): If you turn intraday mode on, it will apply trade entry and exit time conditions on exiting strategy.
Trade Entry From: Specify in HHMM format the time after which you want to start trading. Some traders do not trade in first 15 minutes after market open because market is very volatile at this time.
Trade Entry Upto: Specify in HHMM format the time after which you do not want to take a fresh trade. Example: Many traders do not want to create a new position in last one hour of market.
Trade Exit Time: Time at which Amibroker will generate exit signal for open positions.
Color of Signals: color of the trade signals which are plotted on chart. The AFL uses arrow for entry signals and star for exit signals.
Strengths and Limitations AFL
This intraday.afl can be applied to any strategy. It does changes the original signal generation logic of strategy, but simply over-rides it with additional conditions.
Some AFL strategies freely available on internet do not even have properly defined buy, sell, short and cover conditions. This intraday.afl does not works with such AFLs.
This AFL cannot continue a signal from previous day. In the example of SuperTrend, if ST continues in sell signal from yesterday, this AFL cannot plot fresh Sell signal at market open. For this purpose, the complete modification of original afl is required. Please share your coding requirement in comments section or avail personal consultancy.
getting error 29 for variable ‘cover’ used without been initialized in Profit & Stoploss Trigger for Strategy
I’m using amibroker 5.70
Getting Error 29 – Variable ‘cover’ used without having been initialized in amibroker 5.70
GETTING THIS ERROR . PLEASE CORRECT IT
Hi Vishal, an outline of the code replacing % with Rs can be something like this:-
_SECTION_BEGIN( “Algoji.com intraday.afl” );
per10 = 0920;
per11 = 1130;
per12 = Param( “Trade Exit(HHMM)”, 1510, 1200, 1510, 100 );
sl_buy = 1 – Param(“StopLoss_buy(%)”, 0.3, 0.3, 1, 0.1)/100;
sl_short = 1 + Param(“StopLoss_short(%)”, 0.3, 0.3, 1, 0.1)/100;
tgt_buy = 1 + Param(“Target_buy(%)”, 1, 0.5, 2, 0.25)/100;
tgt_short = 1 – Param(“Target_short(%)”, 1, 0.5, 2, 0.25)/100;
intra = ParamToggle( “Activate Intraday Mode”, “NO|YES” );
intraex = intra AND TimeNum() > per12 * 100;
intraen = !intra OR ( TimeNum() per10 * 100 );
Col_sl_buy = ParamColor( “Color of sl_buy”, colorRed);
Col_sl_short = ParamColor( “Color of sl_short”, colorBlue);
Col_tgt_buy = ParamColor( “Color of tgt_buy”, colorRed );
Col_tgt_short = ParamColor( “Color of tgt_short”, colorBlue );
Buy2 = Buy;
Sell2 = Sell;
Short2 = Short;
Cover2 = Cover;
bflag = sflag = 0;
slarr_buy = tgtarr_buy=slarr_short = tgtarr_short = Null;
for ( i = 10; i < BarCount; i++ )
if ( Buy2[i] AND intraen[i] AND bflag == 0 )
Buy[i] = 1;
bflag = 1;
if ( sl_buy )
slarr_buy[i] = C[i] * sl_buy;
if ( tgt_buy )
tgtarr_buy[i] = C[i] * tgt_buy;
Buy[i] = 0;
if ( bflag AND Buy[i] == 0 )
slarr_buy[i] = slarr_buy[i-1];
tgtarr_buy[i] = tgtarr_buy[i-1];
if ( ( Sell2[i] OR intraex[i] OR( L[i] 0 ) OR ( H[i] > tgtarr_buy[i] AND tgt_buy > 0 ) ) AND bflag )
Sell[i] = 1;
bflag = 0;
Sell[i] = 0;
if ( Short2[i] AND intraen[i] AND sflag == 0 )
Short[i] = 1;
sflag = 1;
if ( sl_short )
slarr_short[i] = C[i] * sl_short;
if ( tgt_short )
tgtarr_short[i] = C[i] * tgt_short;
Short[i] = 0;
if ( sflag AND Short[i] == 0 )
slarr_short[i] = slarr_short[i-1];
tgtarr_short[i] = tgtarr_short[i-1];
if ( ( Cover2[i] OR intraex[i]OR( H[i] > slarr_short[i-1] AND sl_short > 0 ) OR ( L[i] 0 ) ) AND sflag )
Cover[i] = 1;
sflag = 0;
Cover[i] = 0;
Sir this is awsome. I want to comapre high low of 2nd candle with first candle. Then trade on 2nd candle breakout pls sir add this if u have time i can recharge your jio no.. I m a scholar just learning.
While you may have the best product in the market, but if your support isnt as good as it should be, then you probably will not see the light of the day in business.
I am writing with much frustration, as I see a complete lack of support from your end (currently dealing with Abhishek) who takes eons just to clarify a simple point.
Another thing is I am shocked to see there is no way one can contact you regarding the product by Phone, only email. What is the point in having such products when you dont even have a human to talk to ? And the only one who communicates by email, is way too busy to communicate…..
To sum up, you have a product that could compete with international brands, but with an INDIAN mindset.
I some help related to MT4 with Alice Blue
I am not sure how to push orders to Alice terminal