Probably so that the market is not swarming with tester grails =)
Yes!!!
//+------------------------------------------------------------------+ || Trailing| //+------------------------------------------------------------------+ void Trailing() { if(InpTrailingStop==0) return; for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions if(m_position.SelectByIndex(i)) if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic) { if(m_position.PositionType()==POSITION_TYPE_BUY) { if(m_position.PriceCurrent()-m_position.PriceOpen()>ExtTrailingStop+ExtTrailingStep) if(m_position.StopLoss()<m_position.PriceCurrent()-(ExtTrailingStop+ExtTrailingStep)) { if(!m_trade.PositionModify(m_position.Ticket(), m_symbol.NormalizePrice(m_position.PriceCurrent()-ExtTrailingStop), m_position.TakeProfit())) Print("Modify ",m_position.Ticket(), " Position -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription()); continue; } } else { if(m_position.PriceOpen()-m_position.PriceCurrent()>ExtTrailingStop+ExtTrailingStep) if((m_position.StopLoss()>(m_position.PriceCurrent()+(ExtTrailingStop+ExtTrailingStep))) || (m_position.StopLoss()==0)) { if(!m_trade.PositionModify(m_position.Ticket(), m_symbol.NormalizePrice(m_position.PriceCurrent()+ExtTrailingStop), m_position.TakeProfit())) Print("Modify ",m_position.Ticket(), " Position -> false. Result Retcode: ",m_trade.ResultRetcode(), ", description of result: ",m_trade.ResultRetcodeDescription()); } } } }
What is the point of the highlighted?
When the original was written (2007), there was no MQL5 and, accordingly, no strict-directive in MQL4. That is why there is a much nested if construct there. At the moment, this has long been a rudiment. And since the KB carries training functions, there is no need to drag this relic into MQL5, so as not to cause ridicule among programmers of other languages.
If the original is rewritten to the current strcit-MQL4, its source code will be reduced by 1.5-2 times. In this sense, the MT5 variant is ***looks *** - 4 times larger in size than the original (this is still in the old MQL4). Why persistently make such an anti-advertisement of MT5!
This will not place a trade on my 5-digit ECN account.
m
This will not place a trade on my 5-digit ECN account.
m
If you do not trade - then of course: it will not affect :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Alexav SpeedUp M1:
Simultaneous opening of two opposite positions. Trailing Stop.
Author: Vladimir Karputov