Questions from Beginners MQL5 MT5 MetaTrader 5 - page 678
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
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?