As the first experience I decided to implement the following algorithm: we can expect a sharp market movement up or down in some time after the Bollinger lines converge into a narrow corridor. In my Expert Advisor, I analyze the state of Bollinger lines and when they are getting very close(Delta pips), we put a pending sell order in the lower direction (at stepOpen pips below the lower line), hoping that the market will suddenly go in that direction. If the market went in another direction, we simply delete this order.
externdouble Delta=800.0; // Ширина канала, которую мы считаем достаточно узкой чтобы ожидать скоро серьезного движения в одну из сторонexterndouble StepOpen=150.0; // Отступ от линии Боллинджера для открытия отложенного ордераexterndouble TP=350.0; // Take Profitexterndouble SL=400.0; // Stop Lossint start()
{
double T1=iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,0); // верхняя линия Боллинджераdouble T2=iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,0); // нижняя линия Боллинджераif ((Ask>T1+StepOpen*Point)&&OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true) OrderDelete(0); // если рынок пошел вверх – то удаляем отложенный ордерif (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true) return(0); // если есть ранее открытый ордер – прекращаем выполнение текущей итерации советникаif (T1-T2<Delta*Point) { // если линии Боллинджера сблизились ближе чем на Delta пунктов начинаем операцию открытия ордераdouble PriceOpen=NormalizeDouble(T2-StepOpen*Point,5); // вычисляем цену открытияdouble StopLoss=NormalizeDouble(T2-StepOpen*Point+SL*Point,5); // вычисляем StopLossdouble TakeProfit=NormalizeDouble(T2-StepOpen*Point-TP*Point,5); // вычисляем TakeProfitOrderSend(Symbol(),OP_SELL,0.1,PriceOpen,5,StopLoss,TakeProfit,0,0,0,Green); // открываем ордер на продажу
}
return(0);
}
The algorithm works unstable, sometimes opens two orders in a short period of time, constantly gives errors OrderSend Error 130 and OrderSend Error 138, and removing open orders in case the market moves in the other direction does not work at all.
Good afternoon, dear forum users. Need help in changing the EA, ie leave everything as is, but change the action (buy/sell) to (sell/buy), my tests showed that the uptrend is sell, and the downtrend buy. a simple change in the code BUY on SELL me nothing, or something is missing, or .... Anyway,i need help Thanks in advance.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
How is the iMA calculated?
Is there anywhere I can find how iMA function is calculated (or is it classified)?
Especially I am interested in MODE_LWMA.
I want to look and tweak to my liking, but something googling the source code did not work
https://docs.mql4.com/ru/indicators/iMA
You need a formula, so Google can easily find it too.
https://docs.mql4.com/ru/indicators/iMA
You need a formula, Google can easily find it too.
Or don't you understand the term "linear-weighted"?
Где-нибудь можно найти как вычисляется функция iMA (или она засекреченная)
Особеннно меня интересует MODE_LWMA.
Хочу посмотреть и подправить на свой вкус, но что-то нагуглить исходники не получилось
Good afternoon!
As the first experience I decided to implement the following algorithm: we can expect a sharp market movement up or down in some time after the Bollinger lines converge into a narrow corridor. In my Expert Advisor, I analyze the state of Bollinger lines and when they are getting very close(Delta pips), we put a pending sell order in the lower direction (at stepOpen pips below the lower line), hoping that the market will suddenly go in that direction. If the market went in another direction, we simply delete this order.
The algorithm works unstable, sometimes opens two orders in a short period of time, constantly gives errors OrderSend Error 130 and OrderSend Error 138, and removing open orders in case the market moves in the other direction does not work at all.Please, advise us! Thank you!
Victor Ivanovich!
So much to leaf through, why didn't you give a link? You put in the code... What for?
//--Your basic code
PrevTime=Time[0]; // Remember the time of the zero bar opening
If you have a bar open setup, here's the template, it works.
Could you please write this function in the EA yourself? In the picture you can see 3 orders opened on one bar. I need only one. I can't fix the code.
Hi all ))))
Help in the adviser to limit opening of orders to 1 per day, no matter how many times it will pass an entry point...
I am trying to write something like this, it checks history of last closed order before opening, and if it matches then don't open...
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
{
if(OrderCloseTime()==Day()
break;
}
this is not working, please help the lamochinka ))))
order on one bar site:mql4.com
https://www.mql5.com/ru/forum/102366/page3
Need help in changing the EA, ie leave everything as is, but change the action (buy/sell) to (sell/buy), my tests showed that the uptrend is sell, and the downtrend buy. a simple change in the code BUY on SELL me nothing, or something is missing, or .... Anyway,i need help
Thanks in advance.