How do i invoke an object.function in a mqh?

 

I am new to MQL5 and am currently stuck with this issue:

In my main mq5:

// EA.mq5

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>

CPositionInfo myPosition;
CTrade        myTrade;

#include <custom.mqh>

and it my mqh "custom.mqh"

...

bool MyFunction(void)
{ ...
  bool result;

  result = myPosition.PositionClose(ticket);
  
  ...
}

and when I compile the EA.mq5, I got an error saying:

Description
 File
'PositionClose' - undeclared identifier
custom.mqh

Thanks for helping.

 
Wilson Wong :

I am new to MQL5 and am currently stuck with this issue:

In my main mq5:

and it my mqh "custom.mqh"

and when I compile the EA.mq5, I got an error saying:

Description
 File
'PositionClose' - undeclared identifier
custom.mqh

Thanks for helping.

Wrap the lines

CPositionInfo myPosition;
CTrade        myTrade;

to your *.mqh file.

 
Vladimir Karputov #:

Wrap the lines

to your *.mqh file.

Would this work if objects "myPosition" and "myTrade" are called in another function in another .mqh?

 
Wilson Wong # :

Would this work if objects "myPosition" and "myTrade" are called in another function in another .mqh?

If there is no code, then there is no help.