Home | MQL4 Tutorial For Dummies | Blogs | EA Builder Blogs
Memberships Login | MQL4 Course | Community | Contact Us
No Image

How to write MQL4 custom indicator tutorial step by step

May 13, 2018 admin 0

  How to write MQL4 Custom Indicator Step by Step What you’ll learn in this video How to create default indicator template How to use the onCalculate Event Prerequisites You must know the basic core knowledge before continue this tutorial You must know how the program flows You must know the basic of data type, how to use integer (int), how to use boolean (bool), how to use array You must know how to use function You must know how to use MQL4 predefined  method like iClose() You must know how to use loop You must know how to use comparison How to create default indicator template At first, you can learn how to create indicator by default from the Metatrader Editor Go to Metatrader 4 > Tools > Open MetaQuotes Languages Editor Go to New Choose Custom Indicator  Choose the default setting and key in the indicator name Choose the number of indicators that you want to add at the Plots as below Add in the number indicator number Click on Finish Then the custom indicator will be generated. How to use the onCalculate Event Next you should learn how to change the value onCalculate Event. Oncalculate is function to refresh the chart with indicator when the chart receive new price from the server. In MT4, on receiving new price from the server, it is also called on receiving new tick. Our job onCalculate Event is to add on price on the to the buffer array that we have created Label1Buffer[]. Each of the buffer array is storing the price indicator. Upon filling the price into the buffer array, then we could draw the indicator in the chart. Example 1: I am using a loop to loop through all the uncounted bar with value with two prices. With this, you will get the two lines 109.36 and 109.06 .  Example 2: Similar idea, you could design your indicator to feed in different values into the indicator buffer. Example, I’m drawing the value of price with previous bar close price.       You could access to the source code here . You could register free and access to the source code above. Post Views: 6,576