Hedge trade

 

Does anyone know how I can set up a hedge trade funtion that can query my current trades and if the trade is say -15 it will put in a hedge trade to close at the same stop loss as the current negative trade?

Example:

Trade 1 -5 pips.

Trade 2 -8 pips.

Trade 3 -15 pips.

Experts spots that trade three is at -15 pips and therefore enters a hedge trade to dampen the expected loss to be closed at the exact same time that trade 3 hits it's stoploss.

Does this make sense?

 
Any ideas?
 
jyett77:

Does anyone know how I can set up a hedge trade funtion that can query my current trades and if the trade is say -15 it will put in a hedge trade to close at the same stop loss as the current negative trade?

Example:

Trade 1 -5 pips.

Trade 2 -8 pips.

Trade 3 -15 pips.

Experts spots that trade three is at -15 pips and therefore enters a hedge trade to dampen the expected loss to be closed at the exact same time that trade 3 hits it's stoploss.

Does this make sense?

What happens if the original trades never hit the SL?
 
int m = 15;
for(int i=0;i<OrdersTotal();i++)
{
     if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
     if(OrderSymbol()!=Symbol()) continue;      
     if(OrderProfit()>0) continue;
     if(MathAbs(OrderOpenPrice()-OrderClosePrice())<m*Point) continue;
     
     if(OrderType()==OP_SELL) 
     {
        // place long order here
     }    
     if(OrderType()==OP_BUY) 
     {
        // place short order here
     }
 
     // take in mind that order size and stoploss of your hedge order are very important in this matter.
      
}
 
fireflies:
jyett77:

Does anyone know how I can set up a hedge trade funtion that can query my current trades and if the trade is say -15 it will put in a hedge trade to close at the same stop loss as the current negative trade?

Example:

Trade 1 -5 pips.

Trade 2 -8 pips.

Trade 3 -15 pips.

Experts spots that trade three is at -15 pips and therefore enters a hedge trade to dampen the expected loss to be closed at the exact same time that trade 3 hits it's stoploss.

Does this make sense?

What happens if the original trades never hit the SL?
 

If it doesn't hit the actual stop loss then it will go back the other way.

The original trade will hit and then have to hedge the hedge so to speak in order to minimize that loss. It will eventually go one way or the other. It has more to do with what kind of loss you are trying to take. I would only put in a hedge, then a hedge the hedge then it would just have to hit for loss.

Loss is going to happen, just trying to minimize it.

 
riyo:
int m = 15;
for(int i=0;i<OrdersTotal();i++)
{
     if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
     if(OrderSymbol()!=Symbol()) continue;      
     if(OrderProfit()>0) continue;
     if(MathAbs(OrderOpenPrice()-OrderClosePrice())<m*Point) continue;
     
     if(OrderType()==OP_SELL) 
     {
        // place long order here
     }    
     if(OrderType()==OP_BUY) 
     {
        // place short order here
     }
 
     // take in mind that order size and stoploss of your hedge order are very important in this matter.
      
}
Thanks RIYO, I have been trying to figure this out for some time.
Reason: