stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

3 paires circular hedge
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2880
Page 1 of 2
Author:  phil_trade [ Sun Aug 04, 2013 8:45 pm ]
Post subject:  Re: 3 paires circular hedge

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 ;)
Author:  aSushiRoll [ Mon Aug 05, 2013 1:42 am ]
Post subject:  Re: 3 paires circular hedge

Script is still missing, ;) how is it working out for you?
Author:  phil_trade [ Mon Aug 05, 2013 6:34 am ]
Post subject:  Re: 3 paires circular hedge

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);
Author:  mobthehop [ Tue Aug 06, 2013 3:51 am ]
Post subject:  Re: 3 paires circular hedge

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
Author:  phil_trade [ Tue Aug 06, 2013 8:36 am ]
Post subject:  Re: 3 paires circular hedge

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
Author:  kwanann [ Tue Aug 06, 2013 9:00 am ]
Post subject:  Re: 3 paires circular hedge

Amazing thing browser history

http://codebase.mql4.com/6185
Author:  palatine [ Fri Aug 09, 2013 1:47 pm ]
Post subject:  Re: 3 paires circular hedge

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
Author:  palatine [ Thu Aug 22, 2013 1:19 pm ]
Post subject:  Re: 3 paires circular hedge

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
Author:  fxdaytrader [ Thu Aug 22, 2013 2:18 pm ]
Post subject:  Re: 3 paires circular hedge

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);
}
Author:  palatine [ Thu Aug 22, 2013 7:27 pm ]
Post subject:  Re: 3 paires circular hedge

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
All times are UTC Page 1 of 2