Pls help a line of code, it giving error ''INIT_FAILED' - expression not boolean' and not able to compile.
Your "LotsOrRisk" is declared as returning a boolean, but you are trying to return an integer value instead.
Next time, please identify on which line and character position the error is being given so that we don't have to go "hunting" for it.
bool LotsOrRisk(const double lots,const double risk,const int digits_adjust) { ... if(!m_money.Init(GetPointer(m_symbol),Period(),m_symbol.Point()*digits_adjust)) return(INIT_FAILED); ... else { Print(__FUNCTION__,", ERROR: Object CMoneyFixedMargin is NULL"); return(INIT_FAILED); } } ... }
-
Exactly
Your code bool RefreshRates(void) { ⋮ if(m_symbol.Ask()==0 || m_symbol.Bid()==0) return(false); //--- return(true); }
Simplified bool RefreshRates(void){ ⋮ return m_symbol.Ask()!=0 && m_symbol.Bid()!=0; }
Your code bool CheckPositions(const ENUM_POSITION_TYPE pos_type) { bool result=true; for(int i=PositionsTotal()-1;i>=0;i--) if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic) { if(m_position.PositionType()==pos_type) { if(!m_trade.PositionClose(m_position.Ticket())) result=false; } else result=false;
Simplified bool CheckPositions(const ENUM_POSITION_TYPE pos_type){ for(int i=PositionsTotal()-1;i>=0;i--) if(m_position.SelectByIndex(i) // selects the position by index for further access to its properties && m_position.Symbol() == m_symbol.Name() && m_position.Magic() == m_magic ){ if(m_position.PositionType()==pos_type) return m_trade.PositionClose( m_position.Ticket() ); return false; } return true; }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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