At the beginning we need to set these 10 points/pips - we won't argue about perception. Let's name the variable InpDistanse=10 and immediately the internal variable ExtDistanse. Let's perform tuning in OnInit - for 3 or 5 digits
//--- tuning for 3 or 5 digits int digits_adjust=1; if(m_symbol.Digits()==3 || m_symbol.Digits()==5) digits_adjust=10;
It remains to introduce a static variable into OnTick(), in which we should record the crossing price. Then we simply count the difference between the current price and the crossover price and compare the difference with ExtDistanse.
Here ...I needed an example of how to enter a static variable in which to write the crossover price. a piece of code
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.
At the beginning we need to set these 10 points/pips - we won't argue about perception. Let's name the variable InpDistanse=10 and immediately the internal variable ExtDistanse. Let's perform tuning in OnInit - for 3 or 5 digits
//--- tuning for 3 or 5 digits
int digits_adjust=1;
if(m_symbol.Digits()==3 || m_symbol.Digits()==5)
digits_adjust=10;
ExtDistanse = InpDistanse*digits_adjust*m_symbol.Point();
It remains to introduce a static variable into OnTick(), in which we should record the crossing price. Then we simply count the difference between the current price and the crossover price and compare the difference with ExtDistanse.
Here ...I needed an example of how to enter a static variable in which to write the price of the intersection. a piece of code
if(пересечение)
my_price=текущая цена
if(текущая цена - my_price > ExtDistanse)
покупаем или продаём
With the signs, it's up to you to decide whether you want the indentation above or below the intersection.
Added. That's it, the birds have already woken up outside the window, I need to sleep.
You just remember that the time will come and no one will give you a hand, and then do not look for reasons why it happened.
if(пересечение)
my_price=текущая цена
if(текущая цена - my_price > ExtDistanse)
покупаем или продаём
Please advise how to stop an Expert Advisor after two losing trades ...
ExpertRemove()
OpenPosition(Symbol(),OP_BUY,Lots,Bid-Sl*GetPoint(),Ask+TakeProfit*GetPoint());
if(Send_Notification&&TimeCurrent()>=time+10) {time=TimeCurrent(); SendNotification("BUY");}
if (FRMA1<GrossMA1 && FRMA2>GrossMA2&& my_price-Bid>Distanse*Point)
OpenPosition(Symbol(),OP_SELL,Lots,Ask+Sl*GetPoint(),Bid-TakeProfit*GetPoint());
if(Send_Notification&&TimeCurrent()>=time+10) {time=TimeCurrent(); SendNotification("SELL");}
ExpertRemove()
Is there one for MT4?
and it's bad form to open a certificate?