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))

- 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