beginner coder question re: SENDMAIL

 

Hi,

 

I am a complete beginner playing around with code - trying to learn a few things.  I tried to add this SENDMAIL code into an old EA that was coded for me.


{SendMail("First Order Opened","First Order Opened Sucessfuly for: " + Symbol() + " at: " + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) 

      + " with price: " + DoubleToStr(getPrice(),Digits)) } 

 

I would appreciate any help with the error message below. 

This was the error message: 

 

 'getPrice' - function not defined

1 error(s), 0 warning(s)


 

Thanks,

Brian  

      

      

 

You have to define the function getPrice().

Or you can replace it with Bid or Ask depending on the Order Type.

{SendMail("First Order Opened","First Order Opened Sucessfuly for: " + Symbol() + " at: " + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) 

      + " with price: " + DoubleToStr(Bid,Digits)) } 
 
Marco vd Heijden:

You have to define the function getPrice().

Or you can replace it with Bid or Ask depending on the Order Type.

Hi Marco,

Thanks for your reply. Please excuse my ignorance. I am trying to learn a little bit of code by reverse engineering some EA's that I already have. So I copied the SendMail function from one EA to another. I suppose my idea is to learn code that I need rather than trying to learn everything. So when I find an error message I try to find out how to fix it.

 

I tried your "Orde Type" suggestion and got 18 errors. Obviously nothing to do with your suggestion. It is just my newbie ignorance:)

Can you perhaps tell me what I need to do to define the function getPrice()? Silly question I suppose but baby steps:)

 

Thanks.

Brian 

 

Please go to the old EA and find the function getPrice().

It seems you copied only half of what is needed.

 
Marco vd Heijden:

Please go to the old EA and find the function getPrice().

It seems you copied only half of what is needed.

 Hi Marco,

I went through all the code before the SendMail function and could only find: 

startPrice = Bid; 

 

I could not find getPrice()

Is this perhaps what I need. If so, where must it be declared?

The old EA has it under int OnInit() 

 

Or should I try this:

declare

double getPrice; 

and then under OnInit(), this:

getPrice = Bid; 

 

Thanks,

Brian 

 

No there has to be a function somewhere.

Usually at the very bottom of the EA.

double getPrice()
{

}

something like that.

You are calling a non present function it is perfectly normal that the compiler gives the function not declared error.

Maybe you can try it by removing the function.

{SendMail("First Order Opened","First Order Opened Sucessfuly for: " + Symbol() + " at: " + TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES) 

      + " with price: ");} 
so you can see the function returns the order open price.
 
Marco vd Heijden:

No there has to be a function somewhere.

Usually at the very bottom of the EA.

something like that.

You are calling a non present function it is perfectly normal that the compiler gives the function not declared error.

Maybe you can try it by removing the function.

so you can see the function returns the order open price.

Hi Marco,

Thanks so much for your time and patience.  

I Found

double getPrice()
{
 

I also experimented some more with your previous suggestion

"Or you can replace it with Bid or Ask depending on the Order Type. "

So I learned 2 ways to do it !!

I Really appreciate your help.

 Cheers,

Brian 

Reason: