Questions from Beginners MQL5 MT5 MetaTrader 5 - page 678

 
Vladimir Karputov:

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 crossover price. a piece of code
 
Movlat Baghiyev:
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
static double my_price=0;

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.

 
Movlat Baghiyev:
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.
Kindergarten.
 
Vladimir Karputov:
static double my_price=0;

if(пересечение)
   my_price=текущая цена

if(текущая цена - my_price > ExtDistanse)
   покупаем или продаём
With the signs yourself - how you need above or below the intersection to catch the indentation.
That's what I think you need. God bless you.
 
Please advise how to stop the Expert Advisor after two losing trades.
 
Movlat Baghiyev:
Please advise how to stop an Expert Advisor after two losing trades ...

ExpertRemove()
 
if (FMA1>GrossMA1 && FMA2<GrossMA2  &&  Ask-my_price>Distanse*Point )
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");}
Is the push message function correctly spelled out ?
 
Vitalie Postolache:

ExpertRemove()
Is there one for MT4?
 
Movlat Baghiyev:
Is there one for MT4?
Is opening a help desk a bad idea?
 
Vitalie Postolache:
and it's bad form to open a certificate?
No, you're right. Well, we're newbies. We're excused.
Reason: