You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
the advisor uses
value from the 0th bar is taken, the values of indicator buffers for it are changed on every tick until the close of the candle.That's right, I experimented, but in essence it does not solve the main problem.-- How to make an EA recalculate the indicator buffer not only on the requested bar, but also several bars backwards
A solution may have been found! One of them is...
For this, however, you have to make a special version of the indicator.
Gentlemen,
I'm writing an indicator: ...
int handle;
double indicatorBuffer[];
...
int OnInit()
{
... handleMA = iMA(_Symbol, _Period, periodMA, shiftMA, MODE_SMA, AppPrice);
...
}
int OnCalculate (const int rates_total, // size of array price[]
const int prev_calculated, // processed bars at previous call
const int begin, // where significant data start
const double& price[]) // array for calculation
{
... doing something
Question is - how to let handleMA = iMA(_Symbol, _Period, periodMA, shiftMA, MODE_SMA, AppPrice) know what is AppPrice?
or how to extract Apply to: from the Parameters tab to use in the code?
Thanks in advance...
Gentlemen,
The question is - how to let handleMA = iMA(_Symbol, _Period, periodMA, shiftMA, MODE_SMA, AppPrice) know what is AppPrice?
or how to extract Apply to: from the Parameters tab for use in the code?
Thank you in advance...
See OnCalculate():
Selection of a necessary time series or indicator as the price[] array is performed by a user when starting the indicator in the "Parameters" tab. To do this, you should specify the necessary item in the drop-down list of "Apply to" field.
For receiving values of a custom indicator from other mql5 programs, the iCustom() function is used, it returns the indicator handle for subsequent operations. You can also specify the appropriate price[] array or the handle of another indicator. This parameter should be passed last in the list of input variables of the custom indicator.
See OnCalculate():
Rosh thanks, but my question is exactly that. What should I specify in operator
handleMA = iMA(_Symbol, _Period, periodMA, shiftMA, MODE_SMA, AppPrice)
as AppPrice?
I'm reading the available help very carefully. Perhaps the heat has taken its toll, but ...
Rosh thanks, but my question is exactly that. What should I specify in the statement
handleMA = iMA(_Symbol, _Period, periodMA, shiftMA, MODE_SMA, AppPrice)
as AppPrice?
I read the available help very carefully. Perhaps the heat has taken its toll, but ...
Rosh thanks, but my question is exactly that. What should I specify in the statement
handleMA = iMA(_Symbol, _Period, periodMA, shiftMA, MODE_SMA, AppPrice)
as AppPrice?
I read the available help very carefully. Perhaps the heat has taken its toll, but ...
Heat. You should specify ENUM_APPLIED_PRICE as AppPrice)
Swan, thank you for your attention. But if you use
input ENUM_APPLIED_PRICE AppPrice=PRICE_CLOSE; and the first form
int OnCalculate (const int rates_total, // size of array price[]
const int prev_calculated, // processed bars at previous call
const int begin, //where significant data begin
const double& price[]) // array for calculation
We get a warning message at compilation: Two OnCalculate functions are defined. Price data function will be used NameIndicator.mq5 (pg)
and price[] array remains untied to AppPrice in any way, unless it is the same as Apply to: in the third tab "Parameters".
The question, in fact, is whether the built-in single-buffer indicators like iMA() and the first intCalculate() form can be used, if price[] array is somehow
used in calculations.
Specify the indicator handle if you want to calculate on data of another indicator. Or type of prices on which the indicator will be calculated.
We (rather me) have some misunderstanding.
The question, in fact, is whether we can use built-in single-buffer indicators like iMA() and the first form of int OnCalculate(), if price[] array is somehow
used in calculations.
We (rather me) have some misunderstanding.
The question, in fact, is whether one can use built-in one-buffer indicators of iMA() type and the first form int OnCalculate() if the price[] array is somehow
used in calculations.
YourAppPrice parameter has nothing to do with OnCalculate().
You can either give it the value of one of the price constants (option 1) or the handle of some other indicator (option 2). And then you can:
1st variant.
2nd variant.