Download MetaTrader 5
To add comments, please log in or register
Having difficulties in understanding the Trading Signals service? Read the article!
nick13
41
nick13 2015.04.25 18:08 
Hi, it's been a few days since I'm trying to code, I do not have coding background (at all) so it's little bit hard for me at this point, but I'm gonna make it, I need that way too much to quit.

so here is my first indicator (nothing that much, just trying to code something that will work) but at the fine point, I do not know what I'm doing wrong. can you help me please? I do not want you to improve it, just tell me what I'm doing wrong and how to avoid such mistakes in the future.

Best regards
Files:
honest_knave
951
honest_knave 2015.04.25 19:36  

Hello nik13,

You need to be very precise with your coding. Just a letter missing or added in the wrong place will stop it from working. Everything you write (or don't write) will have a meaning.

At the moment, your code will not compile because of missing or extra code where it shouldn't be. My guess is that you have cut and paste other bits of code (which is a good way to learn) but you've either cut-off part of it or pasted too much.

I suggest you start with the standard template and very carefully insert your code into it. Be very careful with brackets, commas and semicolons.

Do it little by little, checking that it compiles as you go along. That way you know exactly what has stopped it working and can fix it straight away.

Move your cursor onto anything that shows up as purple or blue and press F1. You can then read about what that bit of code is doing, and also examples of how it should be used.

//+------------------------------------------------------------------+
//|                                                     Template.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
nick13
41
nick13 2015.04.26 08:09  
honest_knave:

Hello nik13,

You need to be very precise with your coding. Just a letter missing or added in the wrong place will stop it from working. Everything you write (or don't write) will have a meaning.

At the moment, your code will not compile because of missing or extra code where it shouldn't be. My guess is that you have cut and paste other bits of code (which is a good way to learn) but you've either cut-off part of it or pasted too much.

I suggest you start with the standard template and very carefully insert your code into it. Be very careful with brackets, commas and semicolons.

Do it little by little, checking that it compiles as you go along. That way you know exactly what has stopped it working and can fix it straight away.

Move your cursor onto anything that shows up as purple or blue and press F1. You can then read about what that bit of code is doing, and also examples of how it should be used.

Hi Honest!

I'm glad that you replayed here, thanks!

Can you explain please what exactly is the string?
Well, at this point I know, that > extern string info=example < will be showed on the indicator/EA window as some sort of "description" of everything that is below/above of it.  
But is that the only use for string? what else it can? unfortunately I was not able to find good explanation of it.
nick13
41
nick13 2015.04.26 08:09  
honest_knave:

Hello nik13,

You need to be very precise with your coding. Just a letter missing or added in the wrong place will stop it from working. Everything you write (or don't write) will have a meaning.

At the moment, your code will not compile because of missing or extra code where it shouldn't be. My guess is that you have cut and paste other bits of code (which is a good way to learn) but you've either cut-off part of it or pasted too much.

I suggest you start with the standard template and very carefully insert your code into it. Be very careful with brackets, commas and semicolons.

Do it little by little, checking that it compiles as you go along. That way you know exactly what has stopped it working and can fix it straight away.

Move your cursor onto anything that shows up as purple or blue and press F1. You can then read about what that bit of code is doing, and also examples of how it should be used.

Hi Honest!

I'm glad that you replayed here, thanks!

Can you explain please what exactly is the string?
Well, at this point I know, that > extern string info=example < will be showed on the indicator/EA window as some sort of "description" of everything that is below/above of it.  
But is that the only use for string? what else it can? unfortunately I was not able to find good explanation of it.
honest_knave
951
honest_knave 2015.04.26 08:13  

Hello nik,

I've sent you an email. 

Demos Stogios
184
Demos Stogios 2015.04.26 16:52  

Hello Nik13,

sorry to tell you bu t I doubt that you are going to learn how to code straight out off the MQL language. The reason is that the manual is not really intended for that purpose but it is rather an informative book of the functions (not to be mixed with the functions as a part of the MQL language) , and the book present here is, as well, quite basic and introductory. My main advise is to learn first some C. I say "some" because you do not really have to go to the end when learning that language, but only a few parts out of it could suffice as well. I do not recommend C++ as it is unnecessary complex (IMO) and you are often forced to change the way you are programming, compared to the C language. But as I said, this is my personal view and nothing more and you may decide for your self. Now, to get you on I believe you have to grab a good book or site;  sites are often free as well. I do not know if I am allowed to write about specific books here, but you may also find very good books online for low prices - that means you can buy and download books in electronic format if you wish. 

best regards

nick13
41
nick13 2015.04.28 03:51  
Demos:

Hello Nik13,

sorry to tell you bu t I doubt that you are going to learn how to code straight out off the MQL language. The reason is that the manual is not really intended for that purpose but it is rather an informative book of the functions (not to be mixed with the functions as a part of the MQL language) , and the book present here is, as well, quite basic and introductory. My main advise is to learn first some C. I say "some" because you do not really have to go to the end when learning that language, but only a few parts out of it could suffice as well. I do not recommend C++ as it is unnecessary complex (IMO) and you are often forced to change the way you are programming, compared to the C language. But as I said, this is my personal view and nothing more and you may decide for your self. Now, to get you on I believe you have to grab a good book or site;  sites are often free as well. I do not know if I am allowed to write about specific books here, but you may also find very good books online for low prices - that means you can buy and download books in electronic format if you wish. 

best regards

Thanks for replay and advice Demos!

I found one good book, one video tutorial and one good guy who's willing to help, so I will make it somehow. 

best regards 
/
To add comments, please log in or register