
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Anybody help fix this EA
This is spesific time (19:00) trade EA, every trade is 10pips and 0.10lot
But I want add inside this EA If first trade is loss next trade will bi 0.2lot, if second also loss third will be 0.40lot etc 0.80/1.60/3.2/6.4/12.8 like martingale.
Please who can add this formula inside this EA
____________________________________________________________________________________________________________
//+------------------------------------------------------------------+
//| MACD Sample.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
extern int MagicNumber = 16384;
extern double TakeProfit = 100;
extern double StopLoss = 100;
extern double Lots = 0.1;
extern int OpenTradeTime = 1900; // Open Trade time
extern int MinutesToWaitForTick = 2;
extern bool OpenBuy = true;
extern bool OpenSell = false;
extern int NumBuys = 1;
extern int NumSells = 1;
extern int Slippage = 3;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
int ct, EndTradeTime;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external
// variables (Lots, StopLoss, TakeProfit,
// TrailingStop) in our case, we check TakeProfit
// on a chart of less than 100 bars
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
// if(TakeProfit<10)
// {
// Print("TakeProfit less than 10");
// return(0); // check TakeProfit
// }
ct = Hour() * 100 + Minute();
EndTradeTime = OpenTradeTime + MinutesToWaitForTick;
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if(ct >= OpenTradeTime && ct < EndTradeTime)
{
if (OpenBuy)
{
for ( cnt = 0; cnt < NumBuys; cnt++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid - StopLoss * Point,Ask+TakeProfit*Point,"",MagicNumber,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
}
}
// check for short position (SELL) possibility
if(OpenSell)
{
for ( cnt = 0; cnt < NumSells; cnt++)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask + StopLoss * Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
}
}
}
}
return(0);
}
// the end.
This is spesific time (19:00) trade EA, every trade is 10pips and 0.10lot
But I want add inside this EA If first trade is loss next trade will bi 0.2lot, if second also loss third will be 0.40lot etc 0.80/1.60/3.2/6.4/12.8 like martingale.
Please who can add this formula inside this EA
____________________________________________________________________________________________________________
//+------------------------------------------------------------------+
//| MACD Sample.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
extern int MagicNumber = 16384;
extern double TakeProfit = 100;
extern double StopLoss = 100;
extern double Lots = 0.1;
extern int OpenTradeTime = 1900; // Open Trade time
extern int MinutesToWaitForTick = 2;
extern bool OpenBuy = true;
extern bool OpenSell = false;
extern int NumBuys = 1;
extern int NumSells = 1;
extern int Slippage = 3;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
int ct, EndTradeTime;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external
// variables (Lots, StopLoss, TakeProfit,
// TrailingStop) in our case, we check TakeProfit
// on a chart of less than 100 bars
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
// if(TakeProfit<10)
// {
// Print("TakeProfit less than 10");
// return(0); // check TakeProfit
// }
ct = Hour() * 100 + Minute();
EndTradeTime = OpenTradeTime + MinutesToWaitForTick;
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if(ct >= OpenTradeTime && ct < EndTradeTime)
{
if (OpenBuy)
{
for ( cnt = 0; cnt < NumBuys; cnt++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid - StopLoss * Point,Ask+TakeProfit*Point,"",MagicNumber,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
}
}
// check for short position (SELL) possibility
if(OpenSell)
{
for ( cnt = 0; cnt < NumSells; cnt++)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask + StopLoss * Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
}
}
}
}
return(0);
}
// the end.asadovelvin
You have to loop though the whole history (not opened orders), find the last closed order for that symbol and check if it was a loss or not
This is spesific time (19:00) trade EA, every trade is 10pips and 0.10lot
But I want add inside this EA If first trade is loss next trade will bi 0.2lot, if second also loss third will be 0.40lot etc 0.80/1.60/3.2/6.4/12.8 like martingale.
Please who can add this formula inside this EA
____________________________________________________________________________________________________________
//+------------------------------------------------------------------+
//| MACD Sample.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
extern int MagicNumber = 16384;
extern double TakeProfit = 100;
extern double StopLoss = 100;
extern double Lots = 0.1;
extern int OpenTradeTime = 1900; // Open Trade time
extern int MinutesToWaitForTick = 2;
extern bool OpenBuy = true;
extern bool OpenSell = false;
extern int NumBuys = 1;
extern int NumSells = 1;
extern int Slippage = 3;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
int ct, EndTradeTime;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external
// variables (Lots, StopLoss, TakeProfit,
// TrailingStop) in our case, we check TakeProfit
// on a chart of less than 100 bars
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
// if(TakeProfit<10)
// {
// Print("TakeProfit less than 10");
// return(0); // check TakeProfit
// }
ct = Hour() * 100 + Minute();
EndTradeTime = OpenTradeTime + MinutesToWaitForTick;
total=OrdersTotal();
if(total<1)
{
// no opened orders identified
if(AccountFreeMargin()<(1000*Lots))
{
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
// check for long position (BUY) possibility
if(ct >= OpenTradeTime && ct < EndTradeTime)
{
if (OpenBuy)
{
for ( cnt = 0; cnt < NumBuys; cnt++)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid - StopLoss * Point,Ask+TakeProfit*Point,"",MagicNumber,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
}
}
// check for short position (SELL) possibility
if(OpenSell)
{
for ( cnt = 0; cnt < NumSells; cnt++)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask + StopLoss * Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
}
}
}
}
return(0);
}
// the end.You can use the code from here to find the last closed order result (easy to change from volume to $) : https://www.mql5.com/en/forum/181755
You can use the code from here to find the last closed order result (easy to change from volume to $) : https://www.mql5.com/en/forum/181755
Yep
To save some time, here is a version that returns the exact profit of the last order :
{
datetime lastTime = 0;
double lastProfit = 0;
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==false) break;
if (magicNumber!=0)
if (OrderMagicNumber() != magicNumber) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderCloseTime() <= lastTime) continue;
lastTime = OrderCloseTime();
lastProfit = OrderProfit()+OrderCommission()+OrderSwap();
}
return(lastProfit);
}
Hello,
You can fix this scripts for new build mt4 830 ? Thank you
shorty_siatka.mq4
longi_siatka.mq4
On the picture you see problem, why ? (same with longi siatka) Please help me
Hello,
You can fix this scripts for new build mt4 830 ? Thank you
shorty_siatka.mq4
longi_siatka.mq4
On the picture you see problem, why ? (same with longi siatka) Please help me
Hi matmar,
No major error, light correction added.
Compiling with no more error .
Try it now.
Have a good Week End.
Sincerely.
Tomcat98
Hi !
I need help with this script, he not set BE in good place. Why ? You can fix it ? Very Thanks
be.mq4
Hi !
I need help with this script, he not set BE in good place. Why ? You can fix it ? Very Thanks
be.mq4It takes an average open price of multiple orders and then takes that as a BE for that lot of opened orders. If the intention was to handle multiple orders and to place stop loss at a BE for the whole lot of orders, it is doing it correctly
But he set BE all position (buy, sell, pending) you can change it ? I need set BE only profit positions buys or sells
. Please help me 
But he set BE all position (buy, sell, pending) you can change it ? I need set BE only profit positions buys or sells
Try using this one : https://www.mql5.com/en/forum/176995 instead. It has all the whistles and bells that are needed for order management