- I open an order long with 0.1 lot size with a take profit 40 pips
- If it goes down let's say 10 pips I want to open another order against it (sell order-opposite direction, hedging, instead of using stoploss) with 0.2 lot size,
- if loses again 10 pips open another order(long)against it with 0.3 lot size,
- I want to keep going like that till the the take profit is hit (all transactions will close) or till the order lot grows to 1 lot (in this case we will have 5 orders hedging order against each other) HOw can I code that?
I did some changes to an ea, I succeded removing the stoploss when the price hits Hedge opens transaction in opposite direction, but how can I change lots? Suppose to use OrderTotal(), anybody knows? HOw can I see what lot used last transaction and next one to be change? Remember they are all open, none are close till the price hits take profit or progression is exhausted (after 5 orders).
extern string basic="==== TP and SL Settings ========";
extern int TakeProfit=40;
extern int Stoploss=20;
extern int Hedge=10;
extern bool iWantHedging=true;
extern double MLot1=0.1;
extern double MLot2=0.2;
extern double MLot3=0.3;
extern double MLot4=0.4;
extern double MLot5=0.5;
//+----------------------------------------------------------
void iWantHedgingManager()
{
int cnt, total = OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if ((iWantHedging) && orderBelongsToMe())
{
if (OrderType()==OP_BUY)
{
if (Bid-OrderOpenPrice()<=Point*(-Hedge) && (OrderStopLoss()!= 0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderTakeProfit(),0,Green);
sendShortOrder();
}
}
else if (OrderType()==OP_SELL)
{
if ((OrderOpenPrice()-Ask<Point*(-Hedge)) && (OrderStopLoss()!= 0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderTakeProfit(),0,Green);
sendLongOrder();
}
}
}
}
}