Hey traders!
So I’ve been spending a lot of time studying EA Coding and I want to make sure my understanding is correct. Below is the template for an EA and I’ve added comments to each section to make sure I understand how the layout is supposed to be.
//±-----------------------------------------------------------------+
//| EA Layout.mq4 |
//| Author |
//| www.website.com |
//±-----------------------------------------------------------------+
#property copyright “Author”
#property link “www.website.com”
#property version “1.00”
#property strict
Insert all precompiler lines, like External Inputs (lots, stop, etc) here with a “extern”
//±-----------------------------------------------------------------+
//| Expert initialization function |
//±-----------------------------------------------------------------+
int OnInit()
{
//—
Here is what occurs when I first start the EA. So this is where I should place all of my
Indicators to be drawn.
//—
return(INIT_SUCCEEDED);
}
//±-----------------------------------------------------------------+
//| Expert deinitialization function |
//±-----------------------------------------------------------------+
void OnDeinit(const int reason)
{
//—
Here is where I remove everything I place on the chart when I take the EA off.
}
//±-----------------------------------------------------------------+
//| Expert tick function |
//±-----------------------------------------------------------------+
void OnTick()
{
//—
Here is where the majority of my coding will be. All of my conditions for my trading signals will be identified here.
The on tick means everytime the price changes, it will run this part so when price changes, my EA will run through and
see if any of my signals are valid, otherwise I would us a return(0) so that it will end the current function and go back
to the calling function mode. This means that it will wait for another tick, or price change, to rerun it.
*I still haven’t done enough study get the whole loop part with EAs, but I’ll get there soon.
}
//±-----------------------------------------------------------------+
My next question is about test message notifications.
I know how to set everything up and I’ve done successful testing with sending a text message to my phone, but how do I determine where my SendNotification() goes in conjunction where my signal occurs in the coding? Here’s my best guess with my limited knowledge.
What I am really curious about is the notification part where it sends a message to my phone.
I know how to set it all up but I am trying to figure out where to exactly place the push notification.
From my understanding this is how it would have to work:
Coding that determine what a buy signal is goes here. If I wanted to just be alerted that my EA took the trade then I would have my coding that determines a buy signal, the order placement, then the SendNotification().
if(buysignal == true);
{
string buysignaloccurs="A buy signal has occurred, check your charts."
SendNotification(buysignaloccurs);
}
else(buysignal == false);
{
return(0);
}
Here is where the coding for determining a sell signal, the order placement code, and then below would be the sell signal notification.
if(sellsignal == true);
{
string sellsignaloccurs="A sell signal has occured, check your charts."
SendNotification(sellsignaloccurs);
}
else(sellsignal == false);
{
return(0)
}
please give your suggestions and guide my newbie mind!
Cheers,
AK