16

AFL of the week: USD-INR Currency Trading Strategy

We have received many requests from our readers to publish AFL for USD-INR Currency Trading strategy. This post would cater to all those requests. This is an extremely profitable trend following strategy for USD-INR currency pair. See the backtest report for its performance. It is an intraday strategy based on triple crossover of Exponential moving averages.

Please visit Trading Tuitions Academy to learn AFL coding and create your own Trading systems.

USD-INR Currency Trading Strategy: AFL Overview

Paramter Value
Preferred Timeframe 10 minutes
Indicators Used EMA 3, EMA 21, EMA 46
Buy Condition EMA Period 3 is greater than EMA period 21, and EMA period 21 is greater than EMA period 46.
Sell Condition EMA Period 3 is less than EMA period 21, and EMA period 21 is less than EMA period 46
Stop Loss 0.5%
Targets No fixed target, Stop and reverse when AFL gives opposite signal
Position Size 80% of Trading Capital
Initial Equity 100000
Brokerage 50 per order
Margin 2.5% (for USD-INR Currency futures)

USD-INR Currency Trading Strategy: AFL Code

//------------------------------------------------------
//
//  Formula Name:    USD-INR Trading Startegy
//  Author/Uploader: Trading Tuitions
//  E-mail:          support@tradingtuitions.com
//  Website:         www.tradingtuitions.com
//------------------------------------------------------

_SECTION_BEGIN("USD-INR Trading Startegy");

SetTradeDelays( 1, 1, 1, 1 );
SetOption( "InitialEquity", 100000);
SetOption("FuturesMode" ,True);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",50);
SetOption("AccountMargin",10);
SetOption("RefreshWhenCompleted",True);
SetPositionSize( 80, spsPercentOfEquity ); 
SetOption( "AllowPositionShrinking", True );
BuyPrice=Open;
SellPrice=Open;
ShortPrice=Open;
CoverPrice=Open;

SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

EMAPeriod1=3;
EMAPeriod2=21;
EMAPeriod3=46;

Buy = EMA(C, EMAPeriod1) > EMA(C, EMAPeriod2) AND EMA(C, EMAPeriod2) < EMA(C, EMAPeriod3);
Sell = EMA(C, EMAPeriod1) < EMA(C, EMAPeriod2) AND EMA(C, EMAPeriod2) > EMA(C, EMAPeriod3);
 
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = Sell;
Cover = Buy;

StopLoss=0.5;
ApplyStop(Type=0,Mode=1,Amount=StopLoss);

Plot( Close, "Price", colorWhite, styleCandle );
Plot(ema( C, EMAPeriod1 ),"3EMA",colorWhite);
Plot(ema( C, EMAPeriod2 ),"21EMA",colorBlue);
Plot(ema( C, EMAPeriod3 ),"46EMA",colorRed);
 

/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
 
_SECTION_END();

AFL Screenshot

Currency Trading Strategy

Backtest Report

 Paramter Value
  USD-INR Currency Futures
Initial Capital  100000
Final Capital 896807.50
Backtest Period 07-07-2015 to 03-03-2016
Timeframe 10 minutes
Net Profit %  796.81%
Annual Return % 2672.58%
Number of Trades 111
Winning Trade % 39.64%
Average holding Period 64 periods
Max consecutive losses 8
Max system % drawdown -44.49%
Max Trade % drawdown -28.39%

Download the detailed backtest report here.

Please note that you can expect even better results if you allow compounding of your returns.

Equity Curve

USD-INR Trading Startegy Equity Curve

Additional Amibroker settings for backtesting

Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 1000 and margin requirement of 2.5% for USD-INR:

Symbol Info_USDINR

Disclaimer:

All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

Related Posts

16 Comments

  1. Sir i like the backtesting & system but if you could please back test the USD INR pair from the period 2010 it will be of great help

    • Hi Tejas,
      We are struggling to find reliable historical data for Currency futures. We will update the backtest result as soon as we find it.

      • Im also trying to get expired currency futures historical data, Can you tell me where i can get it?

  2. SIR, CAN WE USE THIS AFL FOR NIFTY OR BANK NIFTY, IF YES WHICH TIME FRAME, LASTLY DO WE HAVE TO MAKE ANY CHANGES IN THE AFL.
    THANKS & REGARDS

    • Hi Karan,

      This strategy is optimized for Currency pairs. You can backtest and see the results for Nifty and Banknifty. Use timeframe of more than 5 mins.

  3. SIR, CAN YOU PROVIDE SUCH GOOD AFL FOR NIFTY & BANK NIFTY.
    THANKS & REGARDS

  4. IS the stop loss .5% of the value of the currency pair or the value of the invested money ?

  5. Hi sir,
    I am new to trading. Is this strategy still relevant for 2018? How can I reach you for more details?

  6. If you go long when the buy condition is met (3EMA>21EMA>46EMA), the do you exit when the condition is completely opposite(3EMA<21EMA<46EMA) or would you exit even if one the entry condition is reversed (for example 3EMA 46EMA)

  7. The above discussed strategy is working only for USD – INR and not for other pairs .. Do you have separate strategy for pairs like JPYINR and EURINR

Leave a Reply

Your email address will not be published.