Warning Message: implicit conversion from 'number' to 'string'

 

Can someone please assist me with solution to resolve warning message in below code.

implicit conversion from 'number' to 'string'


double CalculateTotalRisk(string symbol, double sl) {

    double totalRisk = 0.0;



    for (int i = 0; i < PositionsTotal(); ++i) {

        if (PositionSelect(i)) {

            // Explicitly retrieve each value

            string posSymbol = PositionGetString(POSITION_SYMBOL);

            double posVolume = PositionGetDouble(POSITION_VOLUME);

            double posOpenPrice = PositionGetDouble(POSITION_PRICE_OPEN);

            double posSL = PositionGetDouble(POSITION_SL);



            // Breakdown the problematic line further

            double tickValue = SymbolInfoDouble(posSymbol, SYMBOL_TRADE_TICK_VALUE);

            if (tickValue <= 0) {

                Print("Failed to retrieve valid tick value for ", posSymbol);

                continue;

            }



            // Calculate position risk explicitly

            double priceDifference = posOpenPrice - posSL;

            double riskForPosition = priceDifference * tickValue * posVolume;

            totalRisk += riskForPosition;

        }

    }
 
PositionSelect needs symbol(as string input parameter).
I suggest you use PositionGetTicket to select position by index.
https://www.mql5.com/en/docs/trading/positiongetticket
 

Thanks for the suggestion, it removed the warning

Yashar Seyyedin #:
PositionSelect needs symbol(as string input parameter).
I suggest you use PositionGetTicket to select position by index.
https://www.mql5.com/en/docs/trading/positiongetticket
 
Deepu Nair:
    for (int i = 0; i < PositionsTotal(); ++i) {

use i++ 

 
Yashar Seyyedin #: use i++ 

They are equivalent by themselves. ++i is more efficient on non-optimizing compilers.