Discussing the article: "Ready-made templates for including indicators to Expert Advisors (Part 1): Oscillators"
//--- Set and adjust if necessary the calculation period period=int(InpPeriod<1 ? 14 : InpPeriod);
I understand that input is a constant. I just can't imagine the task.
Well, only as a defence against a fool who put a minus, but then it would be better to have an alert that the person made a mistake.
Why from uint to int and why such a construction at all?
I understand that input is a constant. I just can't imagine the task.
Well, only as a defence against a fool who put a minus, but then it would be better to have an alert that the person made a mistake.
InpPeriod is an input variable input. There is no way to put a minus there. You can put a zero there. Such checks (for less than one) are a habit not to compare numbers with zero directly - if suddenly in another similar construction there will be an input variable with double type, it will allow me to avoid direct comparison of two double numbers. Yes, this is "foolproof". First of all from myself - to make fewer mistakes when porting code to other places.
InpPeriod - input variable input. There is no way to put a minus there. You can put a zero there. Such checks (for less than one) are a habit not to compare numbers with zero directly - if suddenly in another similar construct there will be an input variable with double type, it will allow me to avoid direct comparison of two double numbers. Yes, this is "foolproof". First of all from myself - to make fewer mistakes when porting code to other places.
Well, yes, it's uint)))))) You can't put a minus on it))))
And zero is possible. But the indicator will be set to the default value in this case.
But the point of your question was something else - you already know about zero.
But I won't guess
And zero is possible. But the indicator will be set to the default value in this case.
But the point of your question was something else - you already know about zero.
But I won't guess
That's right. There's no need to guess. It was just a question for Valery. You can't put a minus, but a zero?
So zero is current)))) As a foolproof design is fine))))))
And you can put a mask on the keyboard, so that only the digits are pressed, and the other keys are not pressed)))))) For soldiers in the 90s did)))))) And when pressing other keys, a warning appeared in big letters))
Hi. I don't think I've done text output to cells with different anchor points.
But if we assume that column_width is the width of the cell, column_height is its height,
and text_w and text_h are the corresponding dimensions of the text to be output to the cell,
then the coordinates of the upper left corner of the text should be calculated using these formulas:
Anchor | text_x | text_y |
---|---|---|
LEFT_UPPER | 0 | 0 |
LEFT | 0 | (column_height - text_h)/2 |
LEFT_LOWER | 0 | column_height - text_h |
LOWER | (column_width - text_w)/2 | column_height - text_h |
RIGHT_LOWER | column_width - text_w | column_height - text_h |
RIGHT | column_width - text_w | (column_height - text_h)/2 |
RIGHT_UPPER | column_width - text_w | 0 |
UPPER | (column_width - text_w)/2 | 0 |
CENTER | (column_width - text_w)/2 | (column_height - text_h)/2 |
Here text anchoring - by default - initial text coordinates in the upper left corner, and to display text depending on the anchor point (anchor in the table header), you need to calculate the text coordinates using the above formulas.
Hi. I don't think I have done text output to cells with different anchor points.
But if we assume that column_width is the width of the cell, column_height is its height,
and text_w and text_h are the corresponding sizes of the text to be output to the cell,
then the coordinates of the upper left corner of the text should be calculated using these formulas:
Anchor | text_x | text_y |
---|---|---|
LEFT_UPPER | 0 | 0 |
LEFT | 0 | (column_height - text_h)/2 |
LEFT_LOWER | 0 | column_height - text_h |
LOWER | (column_width - text_w)/2 | column_height - text_h |
RIGHT_LOWER | column_width - text_w | column_height - text_h |
RIGHT | column_width - text_w | (column_height - text_h)/2 |
RIGHT_UPPER | column_width - text_w | 0 |
UPPER | (column_width - text_w)/2 | 0 |
CENTER | (column_width - text_w)/2 | (column_height - text_h)/2 |
Here text anchoring - by default - initial coordinates of text in the upper left corner, and to display text depending on the anchor point (anchor in the table header), you need to calculate the text coordinates according to the given formulas.
That's roughly what I thought, but thought there was a simpler solution.
Thanks!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Check out the new article: Ready-made templates for including indicators to Expert Advisors (Part 1): Oscillators.
The article considers standard indicators from the oscillator category. We will create ready-to-use templates for their use in EAs - declaring and setting parameters, indicator initialization and deinitialization, as well as receiving data and signals from indicator buffers in EAs.
Including indicators to an EA and using data from the indicator buffer in the EA is a fairly simple task, although it requires constant browsing through reference materials. We need to remember all the parameters passed to the indicator creation function, formalize some of them as EA inputs, introduce validity checks, etc. To obtain data, we need to write functions that return the necessary data from the desired bar. All this involves spending time on accessing help, entering the required variables into the EA, writing functions for receiving and monitoring data to determine signals, etc.
The purpose of this article is to create templates for including indicators to EAs. Let's look at indicators from the oscillator category, their input variables, creating an indicator handle and obtaining the required data from it.
Author: Artyom Trishkin