Empty4 v600 for Coders

genaja
Trader
Posts: 52
Joined: Wed Mar 21, 2012 12:42 pm

return value of 'OrderSend' should be checked

Post by genaja »

[/quote]
you can ignore it, as it is only a warning, if you want remove the warning just change

Code: Select all

 bool ticket1=OrderSend(Symbol(),OP_BUY,LOT,Ask,3,Ask-SL*Poin,Ask+20.0*Poin,"DAX_tripple2",2,0,CLR_NONE);
ecc...
Cheers :)

Tommaso[/quote]


Hi Tommaso,

bool ticket1=
bool ticket2=

was the solution. But what is the difference?

Is it not alowed to fill 3 orders in one "int" variable?


Thanks
Genaja
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

return value of 'OrderSend' should be checked

Post by milanese »

you can ignore it, as it is only a warning, if you want remove the warning just change

Code: Select all

 bool ticket1=OrderSend(Symbol(),OP_BUY,LOT,Ask,3,Ask-SL*Poin,Ask+20.0*Poin,"DAX_tripple2",2,0,CLR_NONE);
ecc...
Cheers :)

Tommaso[/quote]


Hi Tommaso,

bool ticket1=
bool ticket2=

was the solution. But what is the difference?

Is it not alowed to fill 3 orders in one "int" variable?


Thanks
Genaja[/quote]
the new compiler wants you to check the result from all OrderSend ecc, that is the difference..

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
genaja
Trader
Posts: 52
Joined: Wed Mar 21, 2012 12:42 pm

return value of 'OrderSend' should be checked

Post by genaja »

the new compiler wants you to check the result from all OrderSend ecc, that is the difference..

Cheers :)

Tommaso
Ah, I understand. Tree orders into one variable is not o.k.

Many thanks Tommaso!

cu genaja
User avatar
matfx
Posts: 2
Joined: Mon May 12, 2014 10:13 am
Location: Malaysia

Empty4 v600 for Coders

Post by matfx »

Thank you guys. The tips posted help a lot indeed.
sheriffonline
Posts: 6
Joined: Fri Aug 28, 2015 8:09 pm

Empty4 v600 for Coders

Post by sheriffonline »

I get the error "'i' - undeclared identifier" for following lines!

Code: Select all

for (i = 0; i < orders; i++)
How to resolve the issue?
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Empty4 v600 for Coders

Post by milanese »

sheriffonline » Fri Aug 28, 2015 8:21 pm wrote:I get the error "'i' - undeclared identifier" for following lines!

Code: Select all

for (i = 0; i < orders; i++)
How to resolve the issue?
you should use

Code: Select all

 for(int i=0 ; i< orders; i++)
Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
sheriffonline
Posts: 6
Joined: Fri Aug 28, 2015 8:09 pm

Empty4 v600 for Coders

Post by sheriffonline »

milanese » Sat Aug 29, 2015 2:50 am wrote:
sheriffonline » Fri Aug 28, 2015 8:21 pm wrote:I get the error "'i' - undeclared identifier" for following lines!

Code: Select all

for (i = 0; i < orders; i++)
How to resolve the issue?
you should use

Code: Select all

 for(int i=0 ; i< orders; i++)
Cheers

Tommaso
Thank you so much. The error was fixed now. but still i get 3 warnings. i removed 1 warning by the help of the topic here.

Code: Select all

Before:     + "Account Number:     " + AccountNumber()+ "\n"
Shows warning as implicit conversion from 'number' to 'string'
Now i change the line as  + "Account Number:     " + StringConcatenate(AccountNumber())+ "\n"
But still 3warnings to fix gven below:

Code: Select all

warning 1:
possible loss of data due to type conversion online 
ordticket[orders][0] = OrderOpenTime();

warning 2:
possible use of uninitialized variable 'ordticket' on line
if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)

warning 3:
possible loss of data due to type conversion on line
int datetime800 = TimeCurrent();

Please help to fix this warnings.
User avatar
renexxxx
Trader
Posts: 860
Joined: Sat Dec 31, 2011 3:48 am

Empty4 v600 for Coders

Post by renexxxx »

My friend,

The AccountNumber line should be:

Code: Select all

 ...  + StringFormat("AccountNumber          : %d\n", AccountNumber() );
StringConcatenate() does the job, but it is not the right way to do it.

And it is much better and easier to create a struct for your order data, like so:

Code: Select all

struct ORDER {
   datetime openTime;
   int ticket;
};

ORDER orders[];

//...
//...

   orders[iOrder].openTime = OrderOpenTime();

if ( OrderSelect( orders[iOrder].ticket, SELECT_BY_TICKET ) ) { // bla bla }

//...
//...

datetime datetime800 = TimeCurrent()

You must have set #property strict at the top of your code. The compiler is giving you 'warnings', which is good. You should always create variables of same type as the value you are assigning. Eg. TimeCurrent() returns a 'datetime' not an 'int'. If you assign it to a variable of type 'int' and you have set #property strict, you get a warning that the compiler needs to do an implicit conversion from datetime to int.

Hope this helps.
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Empty4 v600 for Coders

Post by milanese »

sheriffonline » Sat Aug 29, 2015 7:48 am wrote:

Code: Select all

warning 1:
possible loss of data due to type conversion online
Issue shows on line: ordticket[orders][0] = OrderOpenTime();
Detailed Code:
int orderstotal = OrdersTotal();
    int orders = 0;
    int ordticket[30][2];
    double lots = 0;
    for (int i = 0; i < orderstotal; i++)
    {
        bool BuyVar=OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 9)
        {
            continue;
        }
        ordticket[orders][0] = OrderOpenTime();
        ordticket[orders][1] = OrderTicket();
        orders++;
    }
         
Warning 2:
possible use of uninitialized variable 'ordticket' on line
Issue shows on line: if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
Detailed Code:
if (orders > 1)
    {
        ArrayResize(ordticket,orders);
        ArraySort(ordticket);
    }
    for(int i=0 ; i< orders; i++)
    {
        if (OrderSelect(ordticket[i][1], SELECT_BY_TICKET) == true)
        {
            lots = OrderLots()*LockFirstProfitPercent/100;
            lots=NormalizeDouble(lots, NDigits);
            bool ret = OrderClose(OrderTicket(), lots, OrderClosePrice(), 4, Red);
            if (ret == false)
            Print("OrderClose() error - ", ErrorDescription(GetLastError()));
            
        }
    }
Warning 3:
possible loss of data due to type conversion on line
Issue shows on line: int datetime800 = TimeCurrent();
Detailed Code: 
int datetime800 = TimeCurrent();
    int hour0 = TimeHour(datetime800);
    
    if ((FromHour < ToHour && hour0 >= FromHour && hour0 < ToHour) ||
    (FromHour > ToHour && (hour0 < ToHour || hour0 >= FromHour))) 

Please help to fix this warnings.
renexxxx had explained very clear how you can change your code avodiding the warnings, so there is no reason to repat your question!
If you have no idea how the newer compiler are changed in resp. to the older ones just read there ---> http://docs.mql4.com/mql4changes#compiler_difference
Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
sheriffonline
Posts: 6
Joined: Fri Aug 28, 2015 8:09 pm

Empty4 v600 for Coders

Post by sheriffonline »

Thank you lot milanese and renexxxx.

I fixed the warning with both of your support.

I appreciate your support.
Post Reply

Return to “Coders Hangout”