Function not referenced warning ?

 

hello, when I complie an EA I get warnings like;

Function "CloseTheseTrades" is not referenced and will be removed from exp-file

is there a way to fix? or does it matter? Do I just have to define them? if so what is the code?

Thank you

 

Warnings

It means that the compiler notices that pieces of code are not being used.

The warnings you see are just optimisation messages; the compiler will not include these functions in the created executable.

The original programmer may have had several reasons for writing these (now non-used) functions in the first place, but technically speaking, your expert will work without them.

 
HerbertH:
It means that the compiler notices that pieces of code are not being used.

The warnings you see are just optimisation messages; the compiler will not include these functions in the created executable.

The original programmer may have had several reasons for writing these (now non-used) functions in the first place, but technically speaking, your expert will work without them.

Ok, thanks. is it because the main secction of code was voided but the bottom line wasn't voided with it?

This is more of the code that references

void CloseLoosingTrades(){ // included by Renato

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

if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicfromSymbol()) && (OrderComment()==GetCommentForOrder()) ) {

if (OrderType()==OP_BUY)

if ( iFXAnalyser(240,MODE_DIV,0)<-DVLimit*Point )

OrderClose(OrderTicket(),OrderLots(),Bid,GetSlippage(),clCloseBuy);

if (OrderType()==OP_SELL)

if ( iFXAnalyser(240,MODE_DIV,0)>DVLimit*Point )

OrderClose(OrderTicket(),OrderLots(),Ask,GetSlippage(),clCloseSell);

double GetSlippage() { return((Ask-Bid)/Point); }

 

No, void here means that the function is not supposed to return anything to it's caller.

Don't worry, the function "CloseLoosingTrades" is just never being used anywhere in the main code, that's all.

 
HerbertH:
No, void here means that the function is not supposed to return anything to it's caller. Don't worry, the function "CloseLoosingTrades" is just never being used anywhere in the main code, that's all.

Ok, thanks for the info. Could I be safe then in removing the code? I just like having the 0 Errors and 0 warrnings show

 

Comment unwanted code

matrixebiz:
Ok, thanks for the info. Could I be safe then in removing the code? I just like having the 0 Errors and 0 warrnings show

To save you from having to put it back if you remove too much:

Just surround the code by multi-line comment /* ... */ like the example below.

/*

void CloseLoosingTrades() { // included by Renato

{ ...

...

}

*/
 
matrixebiz:
Ok, thanks for the info. Could I be safe then in removing the code? I just like having the 0 Errors and 0 warrnings show

Can you ever be safe if you remove "close losing orders" from the code???

You can! If your aim is to blow up the account

 
Shinigami:
Can you ever be safe if you remove "close losing orders" from the code??? You can! If your aim is to blow up the account

Shinigami, stop scaring the man. (He is wise enough to demo first, I am sure..)

There might be dozens of unused functions which have nothing to with the code this expert is using. It could even contain much worse code that we are unaware of.

You and I do not know the functionality of this expert, so we cannot tell if this function is realy needed.

If you do not agree, would you be so kind to tell him where to put the call to this routine, without having seen any of this experts code....?

Cheers

 

Ok, I'll just leave it the way it is

 
matrixebiz:
Ok, I'll just leave it the way it is

That piece of code is not used for some reason. If it is not used, it can be:

removed

commented out

In either case things won't change.

But I'm saying that if there is some function that is not used, take a look at the logic of the EA. Maybe its actually a bug?

Reason: