C-4: What do you mean by 'align'? Normalize the mantissa by the number of decimal places? - That's what the NormalizeDouble function is for. If something else, describe it in more detail.
At input any positive double, at output rounded to the real price that can be at this instrument.
If the price step is 0.25, then round to 0.25. Sort of like this:
Newalligator: Thanks for the reply, I trade live and MT5 is always on. If the program itself prompts me to update, it's good, but if not, where is this Live update?
When you connect to your account at the MetaQuotes-Demo server, the MetaTrader will check for updates automatically. If there is an update, it will automatically download the new version.
Good day to you all! There is a problem - I can't use the readings of another custom indicator in a custom indicator. I am almost sure I am doing it wrong but I will paste the code anyway:
intOnCalculate(constint rates_total, constint prev_calculated, constint begin, constdouble &price[]) {
if(rates_total < iPeriod ) {
return(0);
}
int first;
if ( prev_calculated == 0 ) {
first = iPeriod + begin;
} else {
first = prev_calculated - 1;
}
// Пользовательский индикатор ROC для EURUSD double aRocRatesEURUSD[];
int iRocHandleEURUSD = iCustom("EURUSD", 0, "Examples\\ROC");
CopyBuffer(iRocHandleEURUSD, 0, 0, rates_total, aRocRatesEURUSD);
for(int bar = first; bar < rates_total; bar++) {
In this code, the buffer of the Rate Of Changes indicator(aRocRatesEURUSD) is not available. I don't understand how to connect this indicator correctly, please help me to understand it.
Good day to you all! There is a problem - I can't use the readings of another custom indicator in a custom indicator. I am almost sure I am doing it wrong but I will paste the code anyway:
In this code, the buffer of the Rate Of Changes indicator(aRocRatesEURUSD) is not available. I cannot understand how to connect this indicator correctly, please help me to understand it.
Indicator handles must be declared in OnInit():
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
// Пользовательский индикатор ROC для EURUSD double aRocRatesEURUSD[];
int iRocHandleEURUSD = iCustom("EURUSD", 0, "Examples\\ROC");
}
Otherwise, it turns out that you create a new custom indicator each time you call OnCalculate().
jommerbot: This does not work either. As a result, the array with the buffer is either empty or full of left values.
Nevertheless, it is correct to declare the indicators handles in OnInit(). Another matter is why do you need to write each time a new tick comes (the OnCalculate() function)
rates_total, // размер входных таймсерий
to the buffer
aRocRatesEURUSD
? This can really slow down the terminal. And besides, this is a very deep story.
#property indicator_chart_window#property indicator_buffers1#property indicator_plots1#property indicator_type1 DRAW_LINE#property indicator_color1 Red
double ExtLineBuffer[];
int iRocHandleEURUSD;
int iPlotShift = 0;
int iPeriod = 6;
voidOnInit() {
SetIndexBuffer(0, ExtLineBuffer, INDICATOR_DATA);
PlotIndexSetInteger(0, PLOT_SHIFT, iPlotShift);
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, iPeriod - 1);
int iRocHandleEURUSD = iCustom("EURUSD", 0, "Examples\\ROC");
if( iRocHandleEURUSD == INVALID_HANDLE )
{
Print("Не удалось получить хендл индикатора ROC EURUSD");
}
}
intOnCalculate(constint rates_total, constint prev_calculated, constint begin, constdouble &price[]) {
if(rates_total < iPeriod ) {
return(0);
}
int first;
double aRocRatesEURUSD[];
if ( prev_calculated == 0 ) {
first = iPeriod + begin;
} else {
first = prev_calculated - 1;
}
for(int bar = first; bar < rates_total; bar++) {
CopyBuffer(iRocHandleEURUSD, 0, bar, 1, aRocRatesEURUSD);
Print(aRocRatesEURUSD[ 0 ]);
ExtLineBuffer[ bar ] = NormalizeDouble(aRocRatesEURUSD[ 0 ], SYMBOL_DIGITS);
}
return(rates_total);
}
I don't understand where my mistake is. Copying the same indicator buffer in EA and script works, but not in indicator. The indicator handle is initialised without error.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
What do you mean by 'align'? Normalize the mantissa by the number of decimal places? - That's what the NormalizeDouble function is for. If something else, describe it in more detail.
At input any positive double, at output rounded to the real price that can be at this instrument.
If the price step is 0.25, then round to 0.25. Sort of like this:
But that said, if there is an offset (like 0.13; 0.38; 0.63; 0.88), then it counts. Then:
on input 1.0 on output 1.13;
1.25 as input and 1.38 as output;
1,5 ---> 1,63...
At the API level, this could be coded into a couple of assembly language commands and it's clearly a basic function. I thought there was one =/
how to make an update to the new build via Live update. Where is this Live update
Thanks for the reply, I trade live and MT5 is always on. If the program itself prompts me to update, it's good, but if not, where is this Live update?
Good day to you all! There is a problem - I can't use the readings of another custom indicator in a custom indicator. I am almost sure I am doing it wrong but I will paste the code anyway:
In this code, the buffer of the Rate Of Changes indicator(aRocRatesEURUSD) is not available. I don't understand how to connect this indicator correctly, please help me to understand it.
Good day to you all! There is a problem - I can't use the readings of another custom indicator in a custom indicator. I am almost sure I am doing it wrong but I will paste the code anyway:
In this code, the buffer of the Rate Of Changes indicator(aRocRatesEURUSD) is not available. I cannot understand how to connect this indicator correctly, please help me to understand it.
Indicator handles must be declared in OnInit():
Otherwise, it turns out that you create a new custom indicator each time you call OnCalculate().Indicator handles should be declared in OnInit():
This does not work either. As a result, the array with the buffer is either empty or full of left values.
rates_total, // размер входных таймсерийto the buffer
? This can really slow down the terminal. And besides, this is a very deep story.
I think you will find it interesting to read the articleThe Principles of Economical Recalculation of Indicators
And also read the help on the OnCalculate() function.
OK, even in the simplest case it doesn't work:
I don't understand where my mistake is. Copying the same indicator buffer in EA and script works, but not in indicator. The indicator handle is initialised without error.