Today we will finish up with conditional (branching) statements by looking at the else ifstatement. It all really comes together in this tutorial. Detailed visualisations of a EURUSD chart are used to illustrate how the implemented logic would be used in an Algorithmic Trading. You will notice from this video that we are actually looking at a the backbone of a real working trading strategy! Psssstt: by the end of this course you will be able to build the whole strategy start to finish! Isn’t that exciting?!
Get the full course here: https://www.forexboat.com/learn-mql4
Code For This Tutorial
Tutorial10.mq4:
//+------------------------------------------------------------------+
//| Tutorial10.mq4 |
//| Copyright 2014, ForexBoat |
//| http://www.forexboat.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, ForexBoat"
#property link "http://www.forexboat.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
double level1 = 1.36900;
double level2 = 1.37900;
Alert("Bid = " + string(Bid));
if(Bid < level1)
{
Alert("The price is below " + string(level1) + " -> SELL");
}
else if(Bid < level2)
{
Alert("The price is between level1 and level2");
}
else
{
Alert("The price is above " + string(level2) + " -> BUY");
}
}