How to Use Amibroker Autotrade AFL Toolkit?

How to Use Amibroker Autotrade AFL Toolkit?

Amibroker Autotrade AFL Toolkit contains a set of AFLs for automating/modifying your strategy. You can use these set of AFLs to change any strategy signals for intraday trading or multiple targets. The AFLs work for different markets like stocks, futures, options, currency and commodities.

Check out – How to integrate FYERS API Bridge with Amibroker?

Also, watch this video on Troubleshooting for Amibroker using FYERS API Bridge.


90% of AFL codes on the internet are not programmed properly. If you use the Autotrade AFL toolkit with random AFLs on the internet, chances are that you will face many issues.

PlotAll-Signals.afl

90% of AFLs found over the internet have repainting/fake signals. Sometimes you may find an Order placed but no signal in Amibroker Chart. This can happen only if AFL has fake signals. The actual signals triggered by AFL may be different then the signals plot on the chart. To check signals, use the AFL plotALLsignals.afl with bar-replay.

Separate-Entry-Exit.afl

This is basic AFL useful for automation.

Parameters:

  1. Instrument Name: Select the instrument name for the market segment you want to trade
  2. Trade Intrabar: If you want to trade immediately when the signal appears, select Yes. If you want to wait for signal confirmation until completion of the candle, select Candle Completion
  3. Strategy Tag: You can use any strategy tag to manage signals coming from multiple strategies in Amibroker. Eg. STG1, STG2, STG3 etc.
  4. Disable Long: If you want to disable all Long signals (use only Short side for trading), then turn this Yes
  5. Disable Short: If you want to disable all Short signals (use only Long side for trading), then turn this Yes.

Buy-Sell-Double.afl


This is a simple and powerful auto trading template for strategies where you want to trade DOUBLE quantity on the reverse signal. It should be used only for strategies where buy= cover and sell= short.

Parameters:

  1. Instrument Name: Select the instrument name for the market segment you want to trade
  2. Trade Intrabar: If you want to trade immediately when the signal appears, select Yes. If you want to wait for signal confirmation until completion of the candle, select Candle Completion
  3. Strategy Tag: You can use any strategy tag to manage signals coming from multiple strategies in Amibroker. Eg. STG1, STG2, STG3 etc.
  4. Disable Long: If you want to disable all Long signals (use only Short side for trading), then turn this Yes
  5. Disable Short: If you want to disable all Short signals (use only Long side for trading), then turn this Yes
  6. Initial qty- the quantity you want to trade. It will get double after the 1st trade signal
  7. Previous Session Position- If yes it will double the quantity from 1st  trade signal else it will double from second trade signal
  8. Reset – reset the trading quantity to initial quantity

Intraday.afl

This is an advanced template useful for intraday trading.

Parameters:

  1. Activate Intrade Mode? If turned yes, it makes even positional trading or indicator-based strategy for intraday trading only. To apply the intraday timings rule, you should turn this on
  2. Trade Entry From(HHMM): Time when you want to start trading, example 930
  3. Trade Entry Upto(HHMM): Time up to which you want to take fresh trades, example 1430 (for 2:30 pm)
  4. Trade Exit(HHMM): Time at which you want to exit all open positions, example 1515
  5. StopLoss(%): Stoploss in percentage from Buy/Short signals
  6. Trail Stop(%): Trail Stop in percentage from Buy/Short signals
  7. Target(%): Target in percentage from Buy/Short signals
  8. Colour of Modified Signals: This AFL displays on chart both original signals and modified signals, you can set colours. The stop-loss, trail stop and target lines are also drawn on the chart with the same colour.
  9. Exposure and Quantity both parameters are available. If exposure is 0, it will take the defined Quantity. Exposure example: If you want to buy/sell each stock with Rs. 100,000, you can set the exposure =100000 and run the AFL on multiple stocks. It will automatically trade 1000 share for a 100 rs. stock, and 250 shares of a 400 rs. stock.
  10. Qty Using SL: If this is given non-zero value, it calculates quantity based on SL as defined in percentage. It will ignore Quantity given in parameter or Quantity calculated from Exposure.


Options.afl

This is a basic template used for trading in options.

  • You can use it on any chart of cash/future to trade in options based on signals generated in the chart.
  • If a Buy signal generated, it will Buy Call and exit the Long position in Put.
  • If a Sell signal generated, it will Buy Put and exit the Long position in Call.

Parameters:

  1. Base symbol- a symbol of derivative you want to trade-in.
  2. Expiry- Expiry of that Put/Call
  3. Put Strike – strike for selecting Put for trading
  4. Call strike- strike for selecting Cut for trading
  5. Instrument Name: should be OPTIDX or OPTSTK
  6. Trade Intrabar: If you want to trade immediately when the signal appears, select Yes. If you want to wait for signal confirmation until completion of the candle, select Candle Completion
  7. Quantity- Total quantity in which you want to trade. For example, in Nifty 1 lot use 75, Nifty 2 lot use 150 and so on.

Martingale Trading Strategy.afl

This is an advanced template with position sizing used for strategies where Buy (LE) and Cover (SX) are the same; Sell (LX) and Short (SE) are the same. It is basically addon version of Intraday Trading AFL.

Parameters:

  1. Colour of Modified Signals: This AFL displays on chart both original signals and modified signals, you can set colours. The stop-loss, trail stop and target lines are also drawn on the chart with the same colour.
  2. Exposure and Quantity both parameters are available. If exposure is 0, it will take the defined Quantity. Exposure example: If you want to buy/sell each stock with Rs. 100,000, you can set the exposure =100000 and run the AFL on multiple stocks. It will automatically trade 1000 share for a 100 rs. stock, and 250 shares of a 400 rs. stock.
  3. Qty Using SL: If this is given non-zero value, it calculates quantity based on SL as defined in percentage. It will ignore Quantity given in parameter or Quantity calculated from Exposure.
  4. Day Profit Limit: Strategy will square-off and stop trading when the profit limit reached (example 5000)
  5. Day Loss Limit: Strategy will square-off and stop trading when loss limit reached (example 2000)
  6. Apply Intraday Martingale: Select NO or Arithmetic or Geometric

Note:

  1. This works only when Intraday mode is activated
  2. If selected Arithmetic, it adds the trading quantity on every losing trade. Example trade quantity is 1, after every losing trading, it adds 1 to new trade. So the progression is like 1, 2, 3, 4, 5….
  3. If selected Geometric, it multiplies the trading quantity on every losing trade with 2. Example trade quantity is 1, after every losing trading, it multiplies 2 to new trade. So the progression is like 1, 2, 4, 8, 16….
    • Related Articles

    • How to integrate FYERS API Bridge with Amibroker?

      Integrating FYERS API Bridge with Amibroker is extremely simple, watch the following video for complete integration. Amibroker Autotrade AFL Toolkit contains a set of AFLs for automating/modifying your strategy. You can use these set of AFLs to ...
    • How can I use the CPR Indicator?

      Central Pivot Range (CPR) is one of the prominently used indicators by day traders that helps you to identify the important price levels to set up trades. CPR can also be used to understand or predict the trends in the market. The major concept ...
    • What are the different types of screeners available in Discover and how can I use them?

      The screeners in Discover are grouped according to different trading styles for ease of use. You can choose from Intraday, Swing, and Long-term screeners with bearish, bullish, or neutral bias. Each screener will show you a list of stocks or ...
    • Can I use my trading account balance to apply for corporate bonds in the primary market?

      For applications in corporate bonds or Debt Initial Public Offerings (IPOs), regulatory guidelines mandate the use of UPI (Unified Payments Interface) for creating mandates. The balance in your trading account with FYERS cannot be utilized for this ...
    • How to use advanced scale options on charts in Fyers App?

      The TradingView chart in FYERS offers several advanced scale options to enhance your charting experience. These options include "Lock Price to Bar Ratio," "Scale Price Chart Only," "Invert Scale," and "Auto (fits data to screen)." Here’s how to use ...