inputint InpMA_ma_period = 25; // Параметры МА inputint InpMA_ma_shift = 0; // MA PRICE_HIGH and PRICE_LOW: horizontal shift inputENUM_MA_METHOD InpMA_ma_method = MODE_SMA; // MA PRICE_HIGH: smoothing type int handle_MA;
intOnInit()
{
handle_MA=iCustom(m_symbol.Name(),Period(),"MA",InpMA_ma_period,InpMA_ma_shift,InpMA_ma_method,PRICE_CLOSE);
}
voidOnTick()
{
double MA_price=0.0;
MA_price=iCustomGet(handle_MA,0,0);
Print("MA_price",MA_price);
}
//Получаем данные кастом МАdouble iCustomGet(int handle,constint buffer,constint index)
{
double Custom[1];
//--- reset error code ResetLastError();
//--- fill a part of the iCustom array with values from the indicator buffer that has 0 index if(CopyBuffer(handle,buffer,index,1,Custom)<0)
{
//--- if the copying fails, tell the error code PrintFormat("Failed to copy data from the iCustom indicator, error code %d",GetLastError());
//--- quit with zero result - it means that the indicator is considered as not calculated return(0.0);
}
return(Custom[0]);
}
intiMA(
string symbol, // имя символа ENUM_TIMEFRAMES period, // период int ma_period, // период усреднения int ma_shift, // смещение индикатора по горизонтали ENUM_MA_METHOD ma_method, // тип сглаживания ENUM_APPLIED_PRICE applied_price // тип цены или handle
);
Для получения текущей рыночной информации служат функции SymbolInfoInteger(), SymbolInfoDouble() и SymbolInfoString(). В качестве второго параметра этих функций допустимо передавать один из идентификаторов из перечислений ENUM_SYMBOL_INFO_INTEGER, ENUM_SYMBOL_INFO_DOUBLE и ENUM_SYMBOL_INFO_STRING соответственно. Некоторые символы (как...
You should put a flag to check if the value has changed, so you don't have to yankOnInit on every tick
Like this:
Thank you it worked.
As far as I understand, I need to doIndicatorRelease
Because old calculation is still hanging on the chart? At least in the tester.
Then the code is like this?
Thank you it's working.
As far as I understand, I will also need to performIndicatorRelease
Because the old calculation is still hanging on the chart? At least in the tester.
Then the code is like this?
And add to the code:
How to make my custom MA be drawn from RSI indicator instead of price?
I receive data of custom MA throughiCustomGet.
I want to makea compound indicator (indicator from indicator).
Examples for mt4
https://www.mql5.com/ru/forum/110186
https://www.mql5.com/ru/code/22638
How to make my custom MA be drawn from RSI indicator instead of price?
I receive data of custom MA throughiCustomGet.
I want to makea compound indicator (indicator from indicator).
Examples for mt4
https://www.mql5.com/ru/forum/110186
https://www.mql5.com/ru/code/22638
How about this:iMA
How about this:iMA
Thank you, just what I need
To this:
The compiler responds: possible loss of data due to type conversion
Question: What's the right way to do this? (so the compiler doesn't swear)
To this:
The compiler responds: possible loss of data due to type conversion
Question: what's the right way to do it? (so that the compiler won't swear)
The compiler doesn't swear but warns you that you are trying to put double into int.
To this:
The compiler responds: possible loss of data due to type conversion
Question: What's the right way to do this? (so the compiler doesn't swear)
The compiler does not swear, but warns that you are trying to put double into int.
I was just perplexed by almost the same thing.
That's because of this int ... As I remember SymbolInfoInteger used to return int type and now it suddenly returns long
I've just been perplexed about pretty much the same thing.
that's because of this int ... As I remember SymbolInfoInteger used to return int type and now it suddenly returns long
It always returns long - look at SymbolInfoInteger() property identifiers