- Don't type inside your SRC blocks. MQL4 Forum editor problem - MQL4 forum
- double mytakeprofit=Ask + 300 * Point;Your take profit never changes, you need to assign a value inside start.
- How do you know "only one buy executed?" Answer, you don't because you didn't check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 forum.) Always use time. New candle - MQL4 forum
whroeder1:
Thank you so much Mr.whroeder1. I will go through the link and learn it.
- Don't type inside your SRC blocks. MQL4 Forum editor problem - MQL4 forum
- double mytakeprofit=Ask + 300 * Point;Your take profit never changes, you need to assign a value inside start.
- How do you know "only one buy executed?" Answer, you don't because you didn't check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
- Bars is unreliable (a refresh/reconnect can change number of bars on chart,) volume is unreliable (miss ticks,) Price is unreliable (duplicate prices and The == operand. - MQL4 forum.) Always use time. New candle - MQL4 forum

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
//--------------------------------------------------------------------
//+GLOBAL Variable declaration
//+-------------------------------------------------------------------
double ExecutedBarOpenPrice=0;
//+------------------------------------------------------------------+
//| EA initialization function |
//+------------------------------------------------------------------+
int init()
{
Alert("EA Initiated");
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| EA tick function |
//+------------------------------------------------------------------+
int LotSize = 1;
extern double myvol=1;
double mystoploss=0;
double mytakeprofit=Ask + 300 * Point;
int start()
{
double Bar_zero_Open_Price = iOpen("XAUUSD",0,0);
if(ExecutedBarOpenPrice!=Bar_zero_Open_Price)
{
OrderSend("XAUUSD",OP_BUY,myvol,Ask,2,mystoploss,mytakeprofit);
ExecutedBarOpenPrice=Bar_zero_Open_Price;
}
Hi, I tried to place order at each bar (xauusd daily chart), but only one buy executed in 22 bars. Could you please correct me where i'm wrong?
Please have look at the link for the visual result https://www.mql5.com/en/charts/6344538/xauusd-d1-forex-capital-markets