Enjoy Interactive Tools and Indicators

Monday, September 3, 2012

2. Introduction should be always short 


How much you understand from the code below? It's MetaQuotes Language(MQL) code. If you have some programming experience you know that this is C-like code. If you don't have any programming experience this might be your time to learn something. If you always wanted to understand what indicators and EA's are doing and maybe to write your own stuff you are in the right place. Cutting to the chase: there is a lot of information regarding programming indicators and expert advisers (and scripts!) out there but is either too technical and assumes that you are working for Goldman-Sachs or it's for retards and it stops always when it should continue. The process of learning needs practice more than theory and something like "Thinking in MQL" was never done before. This is our intention.
//+------------------------------------------------------------------+
//|                                                   HelloWorld.mq4 |
//|                        Copyright 2012, Aimetraders               |
//|                                http://aimetatraders.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
//----
   string myString = StringConcatenate("counting bars: ",counted_bars);
   Print(myString);
//----
   return(0);
  }
//+------------------------------------------------------------------+
The result at the "console": the experts tab is showing the indicator named Hello World counting bars as they are drawn by the Metatrader:
Every tutorial in any programming language has to start with its own "Hello World" example. They say that MQL is an algorithmic language. We strongly disagree: it's as algorithmic as your native language. More of the making of "Hello World" next time.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.