Gold Silver Ratio Strategy (Amibroker)
The article can be found here.
The strategy in plain English:
- We use the RSI indicator to make an RSI indicator strategy of the gold silver ratio.
- When the 5-day RSI is above 75 we buy GLD at the close.
- When the 5-day RSI is above 75 we short SLV at the close.
- When the 5-day RSI falls below 50, we close both positions at the close.
This is a pair trade.
Amibroker code
SetOption("initialEquity",100000);
Leverage=1.0 ;
SetOption("accountmargin",100/leverage);
setOption("MaxOpenPositions",3);
setOption("holdminbars",1);
SetTradeDelays( 0, 0, 0, 0 ); // SetTradeDelays( buydelay, selldelay, shortdelay, coverdelay )
Fremmed=Foreign("GLD","close",fixup=1);
Fremmedto=Foreign("SLV","close",fixup=1);
Pair= fremmed/fremmedto ;
RSIpair=RSIa(pair,oddis);
if( Name() == "GLD" )
{
IIf( Name() == "GLD",setPositionSize(49*leverage,spsPercentOfEquity),0);
Buy= RSIpair>75 ;;
BuyPrice=Close;
Sell= rsipair<50;
SellPrice=Close;
}
if( Name() == "SLV" )
{
IIf( Name() == "SLV",setPositionSize(49*leverage,spsPercentOfEquity),0);
Short = RSIpair>75;
ShortPrice=Close ;
Cover= rsipair<50 ;
CoverPrice= Close;
}
