Anyone can help and set EA that it only close the pip profit target without closing the other lower positions in my martingale system?
thanks
int g_magic_76;
int gi_unused_80;
extern int TakeProfit = 10;
extern int Step = 30;
extern int Slippage = 3;
extern string Comm = "ProfitStream Advisor";
extern int EA_MagicNo = 123456;
bool gi_104 = TRUE;
double gPoint;
int init()
{
gi_unused_80 = 0;
g_magic_76 = EA_MagicNo;
Update_Point();
HideTestIndicators(TRUE);
return (0);
}
void Update_Point()
{
switch (MarketInfo(Symbol(), MODE_DIGITS))
{
case 5: gPoint = 0.0001; break;
case 3: gPoint = 0.01; break;
default: gPoint = Point;
}
}
int start()
{
string ls_0;
double l_lots_8;
double l_ord_open_price_16;
double l_ord_open_price_24;
double l_ord_profit_32;
double l_ord_profit_40;
Update_Point();
if (gi_104)
{
ls_0 = "ProfitStream Advisor";
Comment(ls_0);
}
int l_count_48 = 0;
int l_count_52 = 0;
if (!IsTradeAllowed())
{
Comment("Error: This currency pair is not allowed or connection failed");
return (0);
}
Comment("");
if (Bars < 100) return (0);
double l_ord_lots_56 = 0;
double l_ord_lots_64 = 0;
for (int l_pos_72 = 0; l_pos_72 < OrdersTotal(); l_pos_72++)
{
OrderSelect(l_pos_72, SELECT_BY_POS);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_76) continue;
if (OrderType() == OP_BUY)
{
if (OrderLots() > l_ord_lots_56)
{
l_ord_lots_56 = OrderLots();
l_ord_open_price_16 = OrderOpenPrice();
l_ord_profit_32 = OrderProfit();
}
l_count_48++;
}
else
{
if (OrderType() == OP_SELL)
{
if (OrderLots() > l_ord_lots_64)
{
l_ord_lots_64 = OrderLots();
l_ord_open_price_24 = OrderOpenPrice();
l_ord_profit_40 = OrderProfit();
}
l_count_52++;
}
}
}
bool l_bool_76 = FALSE;
bool l_bool_80 = FALSE;
bool li_84 = FALSE;
bool li_88 = FALSE;
l_bool_76 = l_count_48 < 1 || l_ord_open_price_16 - Step * gPoint > Ask && AccountFreeMargin() > AccountBalance() / 2.0;
l_bool_80 = l_count_52 < 1 || l_ord_open_price_24 + Step * gPoint < Bid && AccountFreeMargin() > AccountBalance() / 2.0;
if (l_ord_lots_56 > 0.0) li_84 = l_ord_profit_32 / (10.0 * l_ord_lots_56) > TakeProfit;
if (l_ord_lots_64 > 0.0) li_88 = l_ord_profit_40 / (10.0 * l_ord_lots_64) > TakeProfit;
if (li_84)
{
for (l_pos_72 = OrdersTotal() - 1; l_pos_72 >= 0; l_pos_72--)
{
OrderSelect(l_pos_72, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_76 && OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, White);
}
}
else
{
if (li_88)
{
for (l_pos_72 = OrdersTotal() - 1; l_pos_72 >= 0; l_pos_72--)
{
OrderSelect(l_pos_72, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_76 && OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, White);
}
}
else
{
RefreshRates();
if (l_bool_76)
{
if (l_ord_lots_56 == 0.0) l_lots_8 = 0.1;
else l_lots_8 = 2.0 * l_ord_lots_56;
OrderSend(Symbol(), OP_BUY, l_lots_8, Ask, Slippage, 0, Ask + (TakeProfit + 25) * gPoint, Comm, g_magic_76, 0, Yellow);
}
else
{
if (l_bool_80)
{
if (l_ord_lots_64 == 0.0) l_lots_8 = 0.1;
else l_lots_8 = 2.0 * l_ord_lots_64;
OrderSend(Symbol(), OP_SELL, l_lots_8, Bid, Slippage, 0, Bid - (TakeProfit + 25) * gPoint, Comm, g_magic_76, 0, Red);
}
}
}
}
return (0);
}
thanks
int g_magic_76;
int gi_unused_80;
extern int TakeProfit = 10;
extern int Step = 30;
extern int Slippage = 3;
extern string Comm = "ProfitStream Advisor";
extern int EA_MagicNo = 123456;
bool gi_104 = TRUE;
double gPoint;
int init()
{
gi_unused_80 = 0;
g_magic_76 = EA_MagicNo;
Update_Point();
HideTestIndicators(TRUE);
return (0);
}
void Update_Point()
{
switch (MarketInfo(Symbol(), MODE_DIGITS))
{
case 5: gPoint = 0.0001; break;
case 3: gPoint = 0.01; break;
default: gPoint = Point;
}
}
int start()
{
string ls_0;
double l_lots_8;
double l_ord_open_price_16;
double l_ord_open_price_24;
double l_ord_profit_32;
double l_ord_profit_40;
Update_Point();
if (gi_104)
{
ls_0 = "ProfitStream Advisor";
Comment(ls_0);
}
int l_count_48 = 0;
int l_count_52 = 0;
if (!IsTradeAllowed())
{
Comment("Error: This currency pair is not allowed or connection failed");
return (0);
}
Comment("");
if (Bars < 100) return (0);
double l_ord_lots_56 = 0;
double l_ord_lots_64 = 0;
for (int l_pos_72 = 0; l_pos_72 < OrdersTotal(); l_pos_72++)
{
OrderSelect(l_pos_72, SELECT_BY_POS);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_76) continue;
if (OrderType() == OP_BUY)
{
if (OrderLots() > l_ord_lots_56)
{
l_ord_lots_56 = OrderLots();
l_ord_open_price_16 = OrderOpenPrice();
l_ord_profit_32 = OrderProfit();
}
l_count_48++;
}
else
{
if (OrderType() == OP_SELL)
{
if (OrderLots() > l_ord_lots_64)
{
l_ord_lots_64 = OrderLots();
l_ord_open_price_24 = OrderOpenPrice();
l_ord_profit_40 = OrderProfit();
}
l_count_52++;
}
}
}
bool l_bool_76 = FALSE;
bool l_bool_80 = FALSE;
bool li_84 = FALSE;
bool li_88 = FALSE;
l_bool_76 = l_count_48 < 1 || l_ord_open_price_16 - Step * gPoint > Ask && AccountFreeMargin() > AccountBalance() / 2.0;
l_bool_80 = l_count_52 < 1 || l_ord_open_price_24 + Step * gPoint < Bid && AccountFreeMargin() > AccountBalance() / 2.0;
if (l_ord_lots_56 > 0.0) li_84 = l_ord_profit_32 / (10.0 * l_ord_lots_56) > TakeProfit;
if (l_ord_lots_64 > 0.0) li_88 = l_ord_profit_40 / (10.0 * l_ord_lots_64) > TakeProfit;
if (li_84)
{
for (l_pos_72 = OrdersTotal() - 1; l_pos_72 >= 0; l_pos_72--)
{
OrderSelect(l_pos_72, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_76 && OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, White);
}
}
else
{
if (li_88)
{
for (l_pos_72 = OrdersTotal() - 1; l_pos_72 >= 0; l_pos_72--)
{
OrderSelect(l_pos_72, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_76 && OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, White);
}
}
else
{
RefreshRates();
if (l_bool_76)
{
if (l_ord_lots_56 == 0.0) l_lots_8 = 0.1;
else l_lots_8 = 2.0 * l_ord_lots_56;
OrderSend(Symbol(), OP_BUY, l_lots_8, Ask, Slippage, 0, Ask + (TakeProfit + 25) * gPoint, Comm, g_magic_76, 0, Yellow);
}
else
{
if (l_bool_80)
{
if (l_ord_lots_64 == 0.0) l_lots_8 = 0.1;
else l_lots_8 = 2.0 * l_ord_lots_64;
OrderSend(Symbol(), OP_SELL, l_lots_8, Bid, Slippage, 0, Bid - (TakeProfit + 25) * gPoint, Comm, g_magic_76, 0, Red);
}
}
}
}
return (0);
}