stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Empty4 v600 for Coders
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3439
Page 4 of 5
Author:  genaja [ Mon Jun 02, 2014 12:09 pm ]
Post subject:  return value of 'OrderSend' should be checked

[/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
Author:  milanese [ Mon Jun 02, 2014 12:19 pm ]
Post subject:  return value of 'OrderSend' should be checked

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
Author:  genaja [ Mon Jun 02, 2014 12:46 pm ]
Post subject:  return value of 'OrderSend' should be checked

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
Author:  matfx [ Fri Jun 13, 2014 5:39 pm ]
Post subject:  Empty4 v600 for Coders

Thank you guys. The tips posted help a lot indeed.
Author:  sheriffonline [ Fri Aug 28, 2015 8:21 pm ]
Post subject:  Empty4 v600 for Coders

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

Code: Select all

for (i = 0; i < orders; i++)
How to resolve the issue?
Author:  milanese [ Fri Aug 28, 2015 9:20 pm ]
Post subject:  Empty4 v600 for Coders

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
Author:  sheriffonline [ Sat Aug 29, 2015 7:00 am ]
Post subject:  Empty4 v600 for Coders

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.
Author:  renexxxx [ Sat Aug 29, 2015 7:30 am ]
Post subject:  Empty4 v600 for Coders

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.
Author:  milanese [ Sat Aug 29, 2015 8:22 am ]
Post subject:  Empty4 v600 for Coders

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
Author:  sheriffonline [ Sat Aug 29, 2015 6:11 pm ]
Post subject:  Empty4 v600 for Coders

Thank you lot milanese and renexxxx.

I fixed the warning with both of your support.

I appreciate your support.
All times are UTC Page 4 of 5