Else If Statement – MQL4 for Complete Beginners Tutorial Part 10

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");
}

}

 

What are you waiting for?

START LEARNING FOREX TODAY!

Muhammad Awais

Leave a Reply

Your email address will not be published.

What are you waiting for?

START LEARNING FOREX TODAY!

as seen on: