HedgeEA - page 31

 

Ratios

This is somewhat funny, partly because I was trying to figure this out last night, and partly due to the explanations

The way I see it, since this is a hedging strategy, the opening trades must be approximately equal in value.

Since we're really buying/selling the first stated currency in any pair, and we know that a lot is 100,000 of any pair, simply look up the value of the base currency of each pair. For instance, if the first pair is EURUSD, then find the value of 100,000 Euros (in US Dollars), which is $131,000. If the second pair is USDJPY, then you already know that 100,000 units of the USD is $100,000. The ratio would then be 1.3 lots EURUSD to every 1.0 lots of USDJPY.

That's my take on it, and it seems to be working out quite well for me.

Doug

 

Backtesting

One of the things I've noticed when I try to backtest this EA, is that it only makes trades in the currency pari that is chosen for backtesting. Every trade in the results section is only the one currency pair. The results, when run on the other pair, are quite the opposite. Do we need to somehow combine the two sets of backtesting results to get an accurate picture of how the EA is doing?

Just curious.

Doug

 

dcraig,

try setting the autocorrelation to off and make sure you have sufficient funds to open the 2 trades.

 
dcraig:
This is somewhat funny, partly because I was trying to figure this out last night, and partly due to the explanations

The way I see it, since this is a hedging strategy, the opening trades must be approximately equal in value.

Since we're really buying/selling the first stated currency in any pair, and we know that a lot is 100,000 of any pair, simply look up the value of the base currency of each pair. For instance, if the first pair is EURUSD, then find the value of 100,000 Euros (in US Dollars), which is $131,000. If the second pair is USDJPY, then you already know that 100,000 units of the USD is $100,000. The ratio would then be 1.3 lots EURUSD to every 1.0 lots of USDJPY.

That's my take on it, and it seems to be working out quite well for me.

Doug

How about using GBPJPY and CHFJPY as an example. thanks.

i attached the code for the calculating cost in usd of 1 pip which i think it willl return the value of ratio.

//+--------- --------- --------- --------- --------- --------- ----+

//+ Calculate cost in USD of 1pip of given symbol

//+--------- --------- --------- --------- --------- --------- ----+

double PipCost (string TradeSymbol) {

double Base, Cost;

string TS_13, TS_46, TS_4L;

TS_13 = StringSubstr (TradeSymbol, 0, 3);

TS_46 = StringSubstr (TradeSymbol, 3, 3);

TS_4L = StringSubstr (TradeSymbol, 3, StringLen(TradeSymbol)-3);

Base = MarketInfo (TradeSymbol, MODE_LOTSIZE) * MarketInfo (TradeSymbol,

MODE_POINT);

if ( TS_46 == "USD" )

Cost = Base;

else if ( TS_13 == "USD" )

Cost = Base / MarketInfo (TradeSymbol, MODE_BID);

else if ( PairExists ("USD"+TS_4L) )

Cost = Base / MarketInfo ("USD"+TS_4L, MODE_BID);

else

Cost = Base * MarketInfo (TS_46+"USD" , MODE_BID);

return(Cost) ;

}
 

the backtester won't work with 2 simulatneous currencies, only one.

dcraig:
One of the things I've noticed when I try to backtest this EA, is that it only makes trades in the currency pari that is chosen for backtesting. Every trade in the results section is only the one currency pair. The results, when run on the other pair, are quite the opposite. Do we need to somehow combine the two sets of backtesting results to get an accurate picture of how the EA is doing?

Just curious.

Doug
 
BluePearl:
the backtester won't work with 2 simulatneous currencies, only one.

any reason, why the backtest doesn't work?

 

VERY INTERSTING INPUT Stevensign, I'M SURE WE ALL INTERSTING TO CHECK YOUR EA,

DID YOU WRIGHT INDICATOR THAT CALCULATE THE RATIO FOR ANY PAIRS THAT WE WANT TO CHOOSE?

Stevensign:
I'm really heavy into math so here it goes. I'm not big on correlation, IMHO this can be misleading. (I am a big believer in Bollinger Bands on cross pairs but that will be a later post if there is interest).

I believe the ratios should be based on two main factors. First, normalize the lots so 1 PIP is the same value, then second, normalize for range. I use Interbank FX and others that are similar. In my example I will use the GBP/USD and USDCHF. 1 mini lot of GBPUSD is $1 per PIP. This is independant of the price of GBPUSD. The PIP value of 1 lot of USDCHF depends on price. If USDCHF is 1.200 each PIP is 1/1.2 = $0.83. To normalize multiply the lots by the price.

so 1.20 lots at a price of 1.200 equals $1 per PIP.

So to normalize on price, if the USDCHF is 1.200 use 1.00 lot of GBPUSD and 1.20 lots of USDCHF.

Now let's normalize on range. This can be daily, weekly, monthly, or whatever you want depending on the strategy you're using.

I've written indicators and EAs to show this but basically you want to determine the range of movement for the currency. One way to do this is is to take the difference between a 200 SMA on the high and a 200 SMA on the low of each currency pair, this will show the average daily range. You will get different results if you do this on daily candles or 4 hour candles or 15 minute candles.

I'll simplifiy for daily candles. the GBPUSD has a daily range of about 120 PIPs, the USDCHF has a range of 90 PIPs. So, on average, when the GBPUSD goes up 120 PIPs the USDCHF goes down 90 PIPs.

The ratio of 90/120 = 0.75.

So now multiply the 1.00 lots of the GBPUSD by 0.75 to get 0.75 lots.

The final trade for this example is 0.75 lots GBPUSD and 1.20 lots of USDCHF.

this results is a ration ot 0.75/1.2 = 0.625 for the GBPUSD / USDCHDF pairs.

This will allow you to stay in the trade as long as possible and collect interest or cash grabs.

In a previous post about three pages ago, someone mentioned about adjusting the the trade in as 3:5 ratio. this is a great idea.

I've written advanced EAs based on my comments that automatically account for lot size, accounts size, etc.

I'll post more if there is interest.

I want suggestions to improve entry points.

I'm working on improvements to exit points.

This strategy is amazing!
 
Stevensign:
I'm really heavy into math so here it goes. I'm not big on correlation, IMHO this can be misleading. (I am a big believer in Bollinger Bands on cross pairs but that will be a later post if there is interest).

I believe the ratios should be based on two main factors. First, normalize the lots so 1 PIP is the same value, then second, normalize for range. I use Interbank FX and others that are similar. In my example I will use the GBP/USD and USDCHF. 1 mini lot of GBPUSD is $1 per PIP. This is independant of the price of GBPUSD. The PIP value of 1 lot of USDCHF depends on price. If USDCHF is 1.200 each PIP is 1/1.2 = $0.83. To normalize multiply the lots by the price.

so 1.20 lots at a price of 1.200 equals $1 per PIP.

So to normalize on price, if the USDCHF is 1.200 use 1.00 lot of GBPUSD and 1.20 lots of USDCHF.

Now let's normalize on range. This can be daily, weekly, monthly, or whatever you want depending on the strategy you're using.

I've written indicators and EAs to show this but basically you want to determine the range of movement for the currency. One way to do this is is to take the difference between a 200 SMA on the high and a 200 SMA on the low of each currency pair, this will show the average daily range. You will get different results if you do this on daily candles or 4 hour candles or 15 minute candles.

I'll simplifiy for daily candles. the GBPUSD has a daily range of about 120 PIPs, the USDCHF has a range of 90 PIPs. So, on average, when the GBPUSD goes up 120 PIPs the USDCHF goes down 90 PIPs.

The ratio of 90/120 = 0.75.

So now multiply the 1.00 lots of the GBPUSD by 0.75 to get 0.75 lots.

The final trade for this example is 0.75 lots GBPUSD and 1.20 lots of USDCHF.

this results is a ration ot 0.75/1.2 = 0.625 for the GBPUSD / USDCHDF pairs.

This will allow you to stay in the trade as long as possible and collect interest or cash grabs.

In a previous post about three pages ago, someone mentioned about adjusting the the trade in as 3:5 ratio. this is a great idea.

I've written advanced EAs based on my comments that automatically account for lot size, accounts size, etc.

I'll post more if there is interest.

I want suggestions to improve entry points.

I'm working on improvements to exit points.

This strategy is amazing!

Stevensign,

definately interested to get more info regarding your way of calculating the ratio. Would be great, you can write some function so that we can incorporate into HedgeEA5.9 or you could modify it and upload here for us. :P

Many thanks....

 

Ratio Calculation

kokas:
I do not know how this ratios is calculated. The AutoRatio in fact uses the real cost in USD but as I said before I do not know the algorithm used to obtain the ratio, so if anyone knows, please post and I will update the EA.

Hi Kokas.

I briefly went over you thread. Here is a link to something you might be able to use.

http://kreslik.com/forums/viewtopic.php?t=307

Be prepared for some heavy reading.

I am also attaching the MQ4 that Codersguru made according to this article. I hope it'll help you. Keep me posted.

The Source

Files:
fpi.zip  1 kb
 

Hi Thesource!

Do you know by chance, whichh ring the indicator you posted is calculate for?

Regards Peter