Warning in my code "possible loss of data due to type conversion" (MarketInfo)

 

Good day All


May someone please assist me with this warning? 

Check the forum but could not find anything that worked fixing this warning


Here is the code that is giving the warning


Sorry i do not have the SRC button to post the code correctly. Thank you

void OpenPending()

  {

   int Ticket1=0, Ticket2=0;

   RefreshRates();

   {

    if(Bid<=(FiboD1) && N<NumberOfOrder) 

     {

     Ticket1 = OrderSend(Symbol(),OP_BUYSTOP,LotCalculated(),NormalizeDouble(FiboD1,MarketInfo(NULL,MODE_DIGITS)),3,
               NormalizeDouble(FiboD1-StopLoss*pips,MarketInfo(NULL,MODE_DIGITS)),NormalizeDouble(FiboD1+TakeProfit*pips,MarketInfo(NULL,MODE_DIGITS)),
               ORDERS_COMMENT,MagicNumberS1,0,clrBlue);



      Ticket2 = OrderSend(Symbol(),OP_BUYSTOP,LotCalculated(),NormalizeDouble(FiboD1,MarketInfo(NULL,MODE_DIGITS)),3,
                NormalizeDouble(FiboD1-StopLoss*pips,MarketInfo(NULL,MODE_DIGITS)), 
                NormalizeDouble(FiboD1+TakeProfit*pips+StopLoss*pips,MarketInfo(NULL,MODE_DIGITS)),ORDERS_COMMENT,MagicNumberS1,0,clrBlue);

      N=N+1;

     }

   } 


possible loss of data due to type conversion Dimba.mq4 699 85

possible loss of data due to type conversion Dimba.mq4 699 154

possible loss of data due to type conversion Dimba.mq4 699 223


Documentation on MQL5: Language Basics / Data Types / Typecasting
Documentation on MQL5: Language Basics / Data Types / Typecasting
  • www.mql5.com
Typecasting - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

There is no need to use 

MarketInfo(NULL,MODE_DIGITS)

(which returns a double) when getting digits for the chart symbol. Just use 

 Digits

Use the code button  OR (Alt+S) when pasting code.

I have edited your post this time.

Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:

There is no need to use 

(which returns a double) when getting digits for the chart symbol. Just use 

Use the code button  OR (Alt+S) when pasting code.

I have edited your post this time.

Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.


Thank you, very much.

//===============


May you aslo tell me what could be the issue,

on the same code i added  

 if(Bid<=(FiboD1) && N<NumberOfOrder) && RSI <= Buy_level)
 if(Ask >=(FiboD1) && N<NumberOfOrder) && RSI >= Buy_level)

No error, but it is only opening Buy order. No Sell order 

 
 if(Bid<=(FiboD1) && N<NumberOfOrder) && RSI <= Buy_level)
 if(Ask >=(FiboD1) && N<NumberOfOrder) && RSI >= Buy_level)

So you're saying that Buy_level is involved in your Sell decision?

 
lippmaje:

So you're saying that Buy_level is involved in your Sell decision?

Thank you for pointing this out, i dont know how i missed it.

 
SmamkeleSimz:

Good day All


May someone please assist me with this warning? 

Check the forum but could not find anything that worked fixing this warning


Here is the code that is giving the warning


Sorry i do not have the SRC button to post the code correctly. Thank you


possible loss of data due to type conversion Dimba.mq4 699 85

possible loss of data due to type conversion Dimba.mq4 699 154

possible loss of data due to type conversion Dimba.mq4 699 223


@ SmamkeleSimz

Change this Line  MarketInfo(NULL,MODE_DIGITS))

int(MarketInfo(NULL,MODE_DIGITS))


void OpenPending()

  {

   int Ticket1=0, Ticket2=0;

   RefreshRates();
   
   {

    if(Bid<=(FiboD1) && N<NumberOfOrder) 

     {

     Ticket1 = OrderSend(Symbol(),OP_BUYSTOP,LotCalculated(),NormalizeDouble(FiboD1,
               int(MarketInfo(NULL,MODE_DIGITS))),3,
               NormalizeDouble(FiboD1-StopLoss*pips,
               int(MarketInfo(NULL,MODE_DIGITS))),
               NormalizeDouble(FiboD1+TakeProfit*pips,
               int(MarketInfo(NULL,MODE_DIGITS))),
               ORDERS_COMMENT,MagicNumberS1,0,clrBlue);



      Ticket2 = OrderSend(Symbol(),OP_BUYSTOP,LotCalculated(),NormalizeDouble(FiboD1,
                int(MarketInfo(NULL,MODE_DIGITS))),3,
                NormalizeDouble(FiboD1-StopLoss*pips,
                int(MarketInfo(NULL,MODE_DIGITS))), 
                NormalizeDouble(FiboD1+TakeProfit*pips+StopLoss*pips,
                int(MarketInfo(NULL,MODE_DIGITS))),ORDERS_COMMENT,MagicNumberS1,0,clrBlue);

      N=N+1;

     }

   } 
SmamkeleSimz
SmamkeleSimz
  • 2021.02.09
  • www.mql5.com
Trader's profile
 
SmamkeleSimz:

Thank you for pointing this out, i dont know how i missed it.

:D
 
Mehmet Bastem: int(MarketInfo(NULL,MODE_DIGITS))

Be careful with NULL.

  1. On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
  2. Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
  3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
  4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
  5. Cloud Protector Bug? - MQL4 programming forum 2020.07.25
Reason: