Lesson 9 - Preprocessors

 

Hi folks,

Welcome to my last theoreticallesson in this series.

In the next series of lessons we will start to build our first Customer Indicator,

So I recommend you to read all the nine lessons carefully before the real work starts.

Please download the lesson and enjoy it (I hope)

Files:
lesson9.pdf  51 kb
 

What the stacksize means?

When we are using indicator_chart_window, indicator_separate_window?

What is indicator_buffers? It may be up to 8 but what is that?

How to understand "indicator_minimum" and "indicator_maximum"? How to understand "the bottom border for the chart" and "the top border for the chart"? I know what chart is but where is the top (border) and bottom (border)?

What is indicator_colorN? I know that N can be displayed between 1 and 8 (color, number of the line ...)? What is 1 or 8? Which kind of data type is 1 in this case?

And the same question for indicator_levelN.

 

I saw in the code of some EA this line:

#include

What is stdlib.mqh file?

Why we need to use it?

What is inside this file and how to check it?

Which functions?

Is it possible ti write our own library file with most usable pieces of the code?

Where to get custom library file?

May be somebody wrote it already ...

 

Just don't be in a hurry!

newdigital:
What the stacksize means?

When we are using indicator_chart_window, indicator_separate_window?

What is indicator_buffers? It may be up to 8 but what is that?

How to understand "indicator_minimum" and "indicator_maximum"? How to understand "the bottom border for the chart" and "the top border for the chart"? I know what chart is but where is the top (border) and bottom (border)?

What is indicator_colorN? I know that N can be displayed between 1 and 8 (color, number of the line ...)? What is 1 or 8? Which kind of data type is 1 in this case?

And the same question for indicator_levelN.

Hi newdigital,

Thank you very much for your valuable questions.

Lesson 11 which I'm writing right now is going to answer all these questions and more, so wait for it.

 
 

Setting Stack Size

newdigital:
What the stacksize means?

Codersguru:

I read your explanation in Lesson 11 about what the stacksize is:

"It's an integer value sets the memory size for every thread, the default is 16384. The data type of the property is integer."

How do we know what size this should be?

How many threads does MetaTrader spin off for 1 Expert Advisor?

Thank you for all your advice.

 
Techguy:
Codersguru:

I read your explanation in Lesson 11 about what the stacksize is:

"It's an integer value sets the memory size for every thread, the default is 16384. The data type of the property is integer."

How do we know what size this should be?

How many threads does MetaTrader spin off for 1 Expert Advisor?

Thank you for all your advice.

Techguy,

I'm so happy for your questions

1- Each thread MT4 creates receives its own stacksize(memory space) internally, but you can set the stacksize value.

I think there's no need to change default stack_size (16384).

Note: I tried to set it to very big number

"#property stacksize 100000000000000000" and nothing has been changed and compiler didn't complain.

2- MT4 uses only onethread for the Expert Advisor.

 

Hello there Guru...

#define VariableName 1000

if the constant can have any type of value, how is it going to differentiate between numerical 1000 and ASCII 1000?

 
anasugawa:
#define VariableName 1000 if the constant can have any type of value, how is it going to differentiate between numerical 1000 and ASCII 1000?

By the context where is is used.

int var=VariableName;

double var2=VariableName;[/CODE]is equivalent to[CODE]int var=1000;

double var2=1000; // 1000.0
 

I hope this is the right place to ask this...

I like to print the Symbol for the chart I am looking at because I use a change Chart & Timeframe indicator to toggle through a pre-defined list and this short code displays the Symbol in the top right hand corner (easier to see than the small MT4 8pt font in the top left hand corner)..

When the Symbol is (say) EURUSD:

I use:

Base = StringSubstr(Symbol(),0,3);

Quote = StringSubstr(Symbol(),3,3);

SymbolName = StringConcatenate(Base,Quote)

Even if the Symbol is (say) EURUSDm, or EURUSDfx this still works fine because I'm extracting the first 3 characters ( Position 0,3 characters) and the next grouip of 3 (Position 3, 3) characters.

But, I would like to understand what I need to do when the Symbol has a prefix (say) mEURUSD or fxEURUSD. The Prefix could be 1 or 2 characters so am wondering how to count the number of characters in the Prefix so I can write if Prefix characters = 1 and adjust the Base to 1,3 and the Quote to 4,3 and if the prefix characters is 2, Base is 2,3 and Quote is 5,3.

Can anyone please point me to how to resolve this?

 
Newton51:
I hope this is the right place to ask this...

I like to print the Symbol for the chart I am looking at because I use a change Chart & Timeframe indicator to toggle through a pre-defined list and this short code displays the Symbol in the top right hand corner (easier to see than the small MT4 8pt font in the top left hand corner)..

When the Symbol is (say) EURUSD:

I use:

Base = StringSubstr(Symbol(),0,3);

Quote = StringSubstr(Symbol(),3,3);

SymbolName = StringConcatenate(Base,Quote)

Even if the Symbol is (say) EURUSDm, or EURUSDfx this still works fine because I'm extracting the first 3 characters ( Position 0,3 characters) and the next grouip of 3 (Position 3, 3) characters.

But, I would like to understand what I need to do when the Symbol has a prefix (say) mEURUSD or fxEURUSD. The Prefix could be 1 or 2 characters so am wondering how to count the number of characters in the Prefix so I can write if Prefix characters = 1 and adjust the Base to 1,3 and the Quote to 4,3 and if the prefix characters is 2, Base is 2,3 and Quote is 5,3.

Can anyone please point me to how to resolve this?

Newton51

Then you have to shift the sub-string checking by the size of the prefix string (in the first case by 1, so the expression would be :

Base = StringSubstr(Symbol(),1,3);

Quote = StringSubstr(Symbol(),4,3);

SymbolName = StringConcatenate(Base,Quote)

and in second case by 2, so the expression would be

Base = StringSubstr(Symbol(),2,3);

Quote = StringSubstr(Symbol(),5,3);

SymbolName = StringConcatenate(Base,Quote)