[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 359

 
sergeev:
everyone
I mean the normal ones.
 
drm1:
I mean normal

What is normal?
 
Zhunko:
You are expressing it in a funny way... Show me the code which will work with ticks, open/close positions without start function. The code of a complete Expert Advisor without the strat function?

Actually, judging from your portfolio, it's not up to me to explain something to you!) Let me first explain my understanding of the start() function, and why I don't like the idea of organizing a cycle in it. I believe that the start() function is a procedure, allocated to user (or rather to his program - Expert) from internal interrupt system of terminal program. And to loop inside of this interrupt or to organize there own interrupt system - well, I probably can not do it. Although, MQ-specialists write in documentation, please - while () loop in your hands, loop as you wish in start(). And who prevents us from looping in init(), through the same vaille loop, and no one will jerk us from the outside! All variables and constants are accessible, all functions work the same way. Do you want to get a quote, with what periodicity? Well, here's a sample code, with periodicity of 5 sec you will get a fresh quote, obtained from the last tick and saved in Close [0] array:

//-------------------------------------------
int init()
{
bool end;
while(!end)
{
Sleep (5000);
Print ("Quote = ", Close[0]);
}
return(0);
}
//--------------------------------------------
int start() {return(0);}
//--------------------------------------------
int deinit() {return(0);}
//--------------------------------------------

In MT5, by the way, the developers have already given users some interruptions, for which I thank them humanly! I can't refrain from quoting:

In MQL5 several types of events can contain predefined handler functions

OnTick - receipt of a new tick;

OnTimer - timer event;

OnTrade is a trade event;

OnChartEvent - events of input from keyboard and mouse, events of moving graphical object, event of finishing text editing in the entry field of the LabelEdit object;

OnBookEvent - event of Depth of Market status change.


 
Vinin:

What is normal?
to work, the standard converter does not work in any way
 
drm1:
to work, the standard converter does not work in any way

It works for everyone.
 
sergeev:

everybody works.
It's a good thing everyone's working, so I'm slow.
 
Grein:

Actually, judging from your portfolio, it's not up to me to explain something to you!) Let me first explain my understanding of the start() function, and why I don't like the idea of organizing a cycle in it. I believe that the start() function is a procedure, allocated to user (or rather to his program - Expert) from internal interrupt system of terminal program. And to loop inside of this interrupt or to organize there own interrupt system - well, I probably can not do it. Although, MQ-specialists write in documentation, please - while () loop in your hands, loop as you wish in start(). And who prevents us from looping in init(), through the same vaille loop, and no one will jerk us from the outside! All variables and constants are accessible, all functions work the same way. Do you want to get a quote, with what periodicity? Well, here's a sample code, with periodicity of 5 seconds you'll get a fresh quote, obtained from the last tick and saved in Close [0] array:

//-------------------------------------------
int init()
{
bool end;
while(!end)
{
Sleep (5000);
Print ("Котировка = ", Close[0]);
}
return(0);
}
//--------------------------------------------
int start() {return(0);}
//--------------------------------------------
int deinit() {return(0);}
//--------------------------------------------

Finally, read about it here. Only functions with waiting period work in Expert Advisor and script start. It is strictly prohibited in all other places.

Your code does not fit the standards of MQL4. Also, it was written somewhere that the waiting time in the ininit and deinit functions during a system call is limited to 2.5 seconds. Then, the function is forcibly terminated.

 

Experts, a word of advice! How to implement this in life? I am working with the indicator "Bollinger Bands", I need to activate the threshold after crossing the line in the middle.

1. All according to the standard, if the price is < the lower line, then Bay

2. If > the upper line, then Sell

If the price broke through the line in the middle, then TrailingStop would be activated

Attention question! How do I associate the trailing stop threshold with the line in the middle?

 
Top2n:

Experts, a word of advice! How to implement this in life? I am working with the "Bollinger Bands" indicator, I need to activate the trigger threshold after crossing the line in the middle.

1. All according to the standard, if the price is < the lower line, then Bay

2. If > the upper line, then Sell

If the price broke through the line in the middle, then TrailingStop would be activated

Attention question! How do I associate the trailing stop threshold with the line in the middle?


The first thing that came to mind:
If the bottom line is at 20 and the top line is at 40, then the line that is exactly in the middle between them, at what level will it be located?

I'm sure you'll answer quickly - at level 30. And now, hopefully, you can find how to calculate it all. Although... maybe you'll find another method... :)

 
Top2n:

Experts, a word of advice! How to implement this in life? I am working with the "Bollinger Bands" indicator, I need to activate the trigger threshold after crossing the line in the middle.

1. All according to the standard, if the price is < the lower line, then Bay

2. If > the upper line, then Sell

If the price broke through the line in the middle, then TrailingStop would be activated

Attention question! How do I set the trailing stop threshold to the centre line?



1. "All according to the standard, if the price got < the bottom line, then Wow" - yeah, and if it got higher, then buy buy deposit... :-))) Learn some literacy for starters - Bay - that's from the Aglitsky for now... Somehow, I am sure it is not a misprint...

2. You have by Bollinger - you have direct access to its upper and lower limits...or rather their values... get those values.

"If the bottom line is at 20 and the top line is at 40, the line that is exactly midway between them, at what level will it be located?" -

as people have already recommended to you...

Add up these values and divide them by two - as a result, you have the middle line of this indicator - this value and knit the threshold for turning on the trawl.

P.S. Artem, sorry for "correcting" the starter of your answer - I liked it too much ... and after my comment on this question - I needed to finish this "threshold of trailing stop to the middle line ".