aeseme, Have you considered implementing the Commodity Selection Index by Wilder as a PIN? If implemented correctly, CSI helps select the most profitable currency pair that is on the move. It also takes into consideration the cost of commissions. I think it should also take into consideration the cost of wider spreads compared to all other competing currency pairs, but we can have that discussion later.
Using CSI, I should be able to say that I will put 2% of my account balance on the barrel head for the least expensive but most volatile trade within the 28 currency pairs. THIS is the kind of trading I want to do!
Here is some code I found on this website for this CSI. The coder called it Currency Selection Index, but I think we'll all be OK with it seeing that we are in the currency world.
//+------------------------------------------------------------------+
//| Currency Selection Index |
//+------------------------------------------------------------------+
double CSI(int x,int TimeFrame,int ADX_Period,int ATR_Period,double Pips2dbl,double Pips2points)
{
double CSIval;
double adx=iADX(CurPairs[x],TimeFrame,ADX_Period,PRICE_CLOSE,MODE_MAIN,0);
double adx2=iADX(CurPairs[x],TimeFrame,ADX_Period,PRICE_CLOSE,MODE_MAIN,0+ADX_Period);
double adxr=0.5*(adx+adx2);
double atr=iATR(CurPairs[x],TimeFrame,ATR_Period,0);
//ATR in pips
double atrval=atr/Pips2dbl;
//Lot value and pip value in the deposit currency
double LotValue=iClose(CurPairs[x],TimeFrame,0)*DeltaValuePerLot(CurPairs[x]);
double pipvalue=LotValue*Pips2dbl;
//V is the value of 1 pip move, i.e., the value of the basic increment of the ATR
double V=pipvalue;
double marginrequired=MarketInfo(CurPairs[x],MODE_MARGINREQUIRED);
double M=MathSqrt(marginrequired);
//Commission Cost in the Deposit Currency, eg: 7USD per 100K USD Round Trip";
double CommissionCost=7;
//Deposit Currency Commission Costs as pips
//double CommissionPips=CommissionCost*0.1;
//Spread in pips
double spread=MarketInfo(CurPairs[x],MODE_SPREAD)/Pips2points;
//Total Cost (C) of Trade = Spread + CommissionCost in the deposit currency
//In this case we are converting the spread to commission costs. Nevertheless, here is a related discussion
//on converting commissions to spread: http://www.forexfactory.com/showthread.php?p=8458967
double C = (spread*pipvalue) + CommissionCost;
double Ka= V/M;
double Kb=1/(150+C);
CSIval=adxr*atrval*Ka*Kb*100;
return(CSIval);
}
//+------------------------------------------------------------------+
//| DeltaValuePerLot |
//+------------------------------------------------------------------+
double DeltaValuePerLot(string pair="")
{
if(pair=="") pair=Symbol();
return(MarketInfo(pair,MODE_TICKVALUE)/MarketInfo(pair,MODE_TICKSIZE)); // Not Point.
}
//+------------------------------------------------------------------+
//| pips2dblFactor |
//+------------------------------------------------------------------+
void pips2dblFactor(string symbol)
{
int MDigits=StrToInteger(DoubleToStr(MarketInfo(symbol,MODE_DIGITS),0));
if(MDigits%2==1)
{
// DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
// Adjust for five (5) digit brokers
pips2dbl=MarketInfo(symbol,MODE_POINT)*10;
pips2points=10;
Digitspips=1;
}
else
{
pips2dbl=MarketInfo(symbol,MODE_POINT);
pips2points=1;
Digitspips=0;
}
}
//+------------------------------------------------------------------+
Using CSI, I should be able to say that I will put 2% of my account balance on the barrel head for the least expensive but most volatile trade within the 28 currency pairs. THIS is the kind of trading I want to do!
Here is some code I found on this website for this CSI. The coder called it Currency Selection Index, but I think we'll all be OK with it seeing that we are in the currency world.
//+------------------------------------------------------------------+
//| Currency Selection Index |
//+------------------------------------------------------------------+
double CSI(int x,int TimeFrame,int ADX_Period,int ATR_Period,double Pips2dbl,double Pips2points)
{
double CSIval;
double adx=iADX(CurPairs[x],TimeFrame,ADX_Period,PRICE_CLOSE,MODE_MAIN,0);
double adx2=iADX(CurPairs[x],TimeFrame,ADX_Period,PRICE_CLOSE,MODE_MAIN,0+ADX_Period);
double adxr=0.5*(adx+adx2);
double atr=iATR(CurPairs[x],TimeFrame,ATR_Period,0);
//ATR in pips
double atrval=atr/Pips2dbl;
//Lot value and pip value in the deposit currency
double LotValue=iClose(CurPairs[x],TimeFrame,0)*DeltaValuePerLot(CurPairs[x]);
double pipvalue=LotValue*Pips2dbl;
//V is the value of 1 pip move, i.e., the value of the basic increment of the ATR
double V=pipvalue;
double marginrequired=MarketInfo(CurPairs[x],MODE_MARGINREQUIRED);
double M=MathSqrt(marginrequired);
//Commission Cost in the Deposit Currency, eg: 7USD per 100K USD Round Trip";
double CommissionCost=7;
//Deposit Currency Commission Costs as pips
//double CommissionPips=CommissionCost*0.1;
//Spread in pips
double spread=MarketInfo(CurPairs[x],MODE_SPREAD)/Pips2points;
//Total Cost (C) of Trade = Spread + CommissionCost in the deposit currency
//In this case we are converting the spread to commission costs. Nevertheless, here is a related discussion
//on converting commissions to spread: http://www.forexfactory.com/showthread.php?p=8458967
double C = (spread*pipvalue) + CommissionCost;
double Ka= V/M;
double Kb=1/(150+C);
CSIval=adxr*atrval*Ka*Kb*100;
return(CSIval);
}
//+------------------------------------------------------------------+
//| DeltaValuePerLot |
//+------------------------------------------------------------------+
double DeltaValuePerLot(string pair="")
{
if(pair=="") pair=Symbol();
return(MarketInfo(pair,MODE_TICKVALUE)/MarketInfo(pair,MODE_TICKSIZE)); // Not Point.
}
//+------------------------------------------------------------------+
//| pips2dblFactor |
//+------------------------------------------------------------------+
void pips2dblFactor(string symbol)
{
int MDigits=StrToInteger(DoubleToStr(MarketInfo(symbol,MODE_DIGITS),0));
if(MDigits%2==1)
{
// DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
// Adjust for five (5) digit brokers
pips2dbl=MarketInfo(symbol,MODE_POINT)*10;
pips2points=10;
Digitspips=1;
}
else
{
pips2dbl=MarketInfo(symbol,MODE_POINT);
pips2points=1;
Digitspips=0;
}
}
//+------------------------------------------------------------------+