3 paires circular hedge

phil_trade

Re: 3 paires circular hedge

Post by phil_trade »

palatine wrote:To steve, and trader/programmer interested about circular hedge

I have posted a script that I took from mql4 website to automatically execute a circular hedge after placing the first order in place but I am having problem to run to Empty4 (IC markets).

for example :

sell 0.5 EUR EURCHF

it will execute

buy 0.25 EURUSD
Buy 0.33 USDCHF

to do an impeccable hedge rounded because brokers can not do a lot size such as : 32748 USD :mrgreen:

I am not a programmer but this script can be usefull for trader who wish to limit their DD. It would be

Happy trading

JC
oops..script missing ;)
User avatar
aSushiRoll
Trader
Posts: 74
Joined: Fri Apr 05, 2013 10:54 pm

Re: 3 paires circular hedge

Post by aSushiRoll »

Script is still missing, ;) how is it working out for you?
phil_trade

Re: 3 paires circular hedge

Post by phil_trade »

phil_trade wrote:
palatine wrote:To steve, and trader/programmer interested about circular hedge

I have posted a script that I took from mql4 website to automatically execute a circular hedge after placing the first order in place but I am having problem to run to Empty4 (IC markets).

for example :

sell 0.5 EUR EURCHF

it will execute

buy 0.25 EURUSD
Buy 0.33 USDCHF

to do an impeccable hedge rounded because brokers can not do a lot size such as : 32748 USD :mrgreen:

I am not a programmer but this script can be usefull for trader who wish to limit their DD. It would be

Happy trading

JC
oops..script missing ;)
not tested, but :

you just have to change ",2" by ",1" for this 2 lines of codes of "Hedge_This" function :

Code: Select all

              double Size_1 = NormalizeDouble((MarketInfo(HedgeSymbol,MODE_TICKVALUE) * HedgeLots) / MarketInfo(Pairs[b],MODE_TICKVALUE),2);
              double Size_2 = NormalizeDouble((MarketInfo(HedgeSymbol,MODE_TICKVALUE) * HedgeLots) / MarketInfo(Pairs[c],MODE_TICKVALUE),2);
to

Code: Select all

              double Size_1 = NormalizeDouble((MarketInfo(HedgeSymbol,MODE_TICKVALUE) * HedgeLots) / MarketInfo(Pairs[b],MODE_TICKVALUE),1);
              double Size_2 = NormalizeDouble((MarketInfo(HedgeSymbol,MODE_TICKVALUE) * HedgeLots) / MarketInfo(Pairs[c],MODE_TICKVALUE),1);
in

Code: Select all

void  Hedge_This(string HedgeSymbol, int HedgeType, double HedgeLots){

      int a,b,c;
      double TranCost = 99999999;
      string SynSymbol_1,SynSymbol_2;
      int Direction_1,Direction_2;
      double Lots_1,Lots_2;
      

      for (a = 0; a < ArraySize(Indexes); a++){ 
          if(Indexes[a] == StringSubstr(HedgeSymbol,0,3) || Indexes[a] == StringSubstr(HedgeSymbol,3,3)){ continue; }// skip useless indexes    
         for (b = 0; b < ArraySize(Pairs); b++){ 
            if (HedgeSymbol == Pairs[b]){ continue; }// Skip = values
            for (c = 0; c < ArraySize(Pairs); c++){ 
              if( HedgeSymbol == Pairs[c]){ continue; }// Skip = values
              
              double Size_1 = NormalizeDouble((MarketInfo(HedgeSymbol,MODE_TICKVALUE) * HedgeLots) / MarketInfo(Pairs[b],MODE_TICKVALUE),2);
              double Size_2 = NormalizeDouble((MarketInfo(HedgeSymbol,MODE_TICKVALUE) * HedgeLots) / MarketInfo(Pairs[c],MODE_TICKVALUE),2);
User avatar
mobthehop
Trader
Posts: 362
Joined: Wed Nov 16, 2011 12:16 am

Re: 3 paires circular hedge

Post by mobthehop »

not sure what happened here as palatine is gone but Phil would you pls be so kind to post the complete code is I really would like to have a look how this is coded...

Cheers / Mop
phil_trade

Re: 3 paires circular hedge

Post by phil_trade »

mobthehop wrote:not sure what happened here as palatine is gone but Phil would you pls be so kind to post the complete code is I really would like to have a look how this is coded...

Cheers / Mop
Hi Mop

I don't know what's happened :o Sorry, but i have checked but not stored the code.

Please email Palatine

Philippe
User avatar
kwanann
Trader
Posts: 948
Joined: Thu Nov 29, 2012 1:53 am

Re: 3 paires circular hedge

Post by kwanann »

Amazing thing browser history

http://codebase.mql4.com/6185
I've been trading using OM Dual N EA for the past 2 years, live results can be found over at https://www.fxblue.com/users/kwanann
palatine
Posts: 3
Joined: Fri Aug 09, 2013 1:34 pm

Re: 3 paires circular hedge

Post by palatine »

Hi traders,

I am back. Any , I was taking the making the change precognized by phil. but still not working. I wish to see someone could see the code to fix it and remove the silly message from this code.

I would love to use this script to see this kind of hedging would softer the DD when taking risk :mrgreen:

I agree to smaller profit with a smaller risk.

regards to all and thank to steve to help me to be back

Jean charles
You do not have the required permissions to view the files attached to this post.
palatine
Posts: 3
Joined: Fri Aug 09, 2013 1:34 pm

Re: 3 paires circular hedge

Post by palatine »

palatine wrote:Hi traders,

I am back. Any , I was taking the making the change precognized by phil. but still not working. I wish to see someone could see the code to fix it and remove the silly message from this code.

I would love to use this script to see this kind of hedging would softer the DD when taking risk :mrgreen:

I agree to smaller profit with a smaller risk.

regards to all and thank to steve to help me to be back

Jean charles

Dear,

I was trying what told me to do , but I ad no sucess into it.

Is there any body can help me please ?

Regards,

Jc
User avatar
fxdaytrader
Trader
Posts: 190
Joined: Sun Jun 10, 2012 7:03 am
Location: Poon-Town (germany, se-asia, se-europe) ...

Re: 3 paires circular hedge

Post by fxdaytrader »

What is the problem - to compute the correct amount of lots for the hedgepair?

if yes: I made an example, put this in an indicator, this calculation should work:

Code: Select all

string Pair = "EURUSDm"; //example, add suffix also
string Hedge = "EURJPYm"; //   -''-
double lots = 0.77;

double amountPair = lots*tickValueReliable(Pair);
double amountHedge = lots*tickValueReliable(Hedge);
double lotmult=amountPair/amountHedge;
double newLots = lots * lotmult;

double newAmountHedge = newLots*tickValueReliable(Hedge);

Comment("to hedge "+Pair+" (amount: "+DoubleToStr(amountPair,2)+") -> lots "+DoubleToStr(lots,2)+" you have to send an order "+Hedge+" (amount old: "+DoubleToStr(amountHedge,2)+") -> lots "+DoubleToStr(newLots,2)+" (NEW amount: "+DoubleToStr(newAmountHedge,2)+")");
this function also:

Code: Select all

double tickValueReliable(string symbol) {
 double tval=MarketInfo(symbol,MODE_TICKVALUE) * MarketInfo(symbol,MODE_POINT) / MarketInfo(symbol,MODE_TICKSIZE);
return(tval);
}
palatine
Posts: 3
Joined: Fri Aug 09, 2013 1:34 pm

Re: 3 paires circular hedge

Post by palatine »

fxdaytrader wrote:What is the problem - to compute the correct amount of lots for the hedgepair?

if yes: I made an example, put this in an indicator, this calculation should work:

Code: Select all

string Pair = "EURUSDm"; //example, add suffix also
string Hedge = "EURJPYm"; //   -''-
double lots = 0.77;

double amountPair = lots*tickValueReliable(Pair);
double amountHedge = lots*tickValueReliable(Hedge);
double lotmult=amountPair/amountHedge;
double newLots = lots * lotmult;

double newAmountHedge = newLots*tickValueReliable(Hedge);

Comment("to hedge "+Pair+" (amount: "+DoubleToStr(amountPair,2)+") -> lots "+DoubleToStr(lots,2)+" you have to send an order "+Hedge+" (amount old: "+DoubleToStr(amountHedge,2)+") -> lots "+DoubleToStr(newLots,2)+" (NEW amount: "+DoubleToStr(newAmountHedge,2)+")");
this function also:

Code: Select all

double tickValueReliable(string symbol) {
 double tval=MarketInfo(symbol,MODE_TICKVALUE) * MarketInfo(symbol,MODE_POINT) / MarketInfo(symbol,MODE_TICKSIZE);
return(tval);
}
Hello fx day trader,

It is not the amount of lot but just the execution of the script when you try to apply to a position to cover. And I was looking over the suggestion previously submitted but no change in execution of the script.

It also help movement of over other pair like triangulation a radio signal.

(I passed over the silly message that the script open while the execution )

Regards,

JC
Post Reply

Return to “Scripts”