In mql4 I could just type iNameOfIndicator(Parameters), now things seem a lot more complicated, am I missing something?
Nvm, finally figured it out, will post how tomorrow, so tired.
Hi MetaNt, maybe this topic may help you too:
Forum on trading, automated trading systems and testing trading strategies
Kima, 2013.02.23 14:25
Ive tried to load this indicator to my EA: https://www.mql5.com/en/forum/9660/page9#comment_411206
But i need some help..
Ive tried:
//---- indicator parameters - in the indicator it self input int Length = 9; // Price Channel Period input ENUM_APPLIED_PRICE Price = PRICE_CLOSE; // Applied Price input double Risk = 3; // Risk Factor in units (0...10) input int UseReEntry = 1; // Re-Entry Mode: 0-off,1-on input int AlertMode = 0; // Alert Mode: 0-off,1-on input int WarningMode = 0; // Warning Mode: 0-off,1-on input string WarningSound = "tick.wav"; // input the indicator in EA int OnInit() { handles2[0]=iCustom(symbol[0],Time_Frame,"PriceChannel_Signal_v1"); if(handles2[0]<0) { Alert("Can not get icustom."); return(-1); } } // and tried int OnInit() { handles2[0]=iCustom(symbol[0],Time_Frame,"PriceChannel_Signal_v1",9,PRICE_CLOSE,3,1,0,0,"tick.wav"); if(handles2[0]<0) { Alert("Can not get icustom."); return(-1); } }
My idea was that with:
handles2[0]=iCustom(symbol[0],Time_Frame,"PriceChannel_Signal_v1");
it would just load the standaard inputs from the indicator self .. But it still says "array out of range"
In Global
Declare the array and the handle, the names of both must match, they can be anything inaccordance with syntax as long as they match.
double MACDMain[]; /////Array For MACD MAIN double MACDSignal[]; /////Array For MACD Signal int MACDMain_handle; /////Handle For MACDMAIN int MACDSignal_handle; /////Handle For MACDSIGNAL
In Init()
Create the indicator using the handle function.
MACDMain_handle=iMACD(Symbol(),0,5,50,5,Applied); MACDSignal_handle=iMACD(Symbol(),0,5,50,5,Applied);
In Ontick()
Copy the data to the array.
CopyBuffer(MACDMain_handle,0,0,100,MACDMain); CopyBuffer(MACDSignal_handle,1,0,100,MACDSignal);
It will also help to use ArraySetAsSeries() in the Ontick() function, so that you can compare different MACD positions e.g. if(MACDMain[1]>MACDMain[0]) .......;
ArraySetAsSeries(MACDMain,true); ArraySetAsSeries(MACDSignal,true);
It will also help to use ArraySetAsSeries() in the Ontick() function, so that you can compare different MACD positions e.g. if(MACDMain[1]>MACDMain[0]) .......;
Right, but not just this, as you also set the array indexing direction and it is very relevant to index as time series, as MQL4.
In Global
Declare the array and the handle, the names of both must match, they can be anything inaccordance with syntax as long as they match.
In Init()
Create the indicator using the handle function.
In Ontick()
Copy the data to the array.
It will also help to use ArraySetAsSeries() in the Ontick() function, so that you can compare different MACD positions e.g. if(MACDMain[1]>MACDMain[0]) .......;
You don't need two handles for the same indicator... you can simply have
MACD_handle=iMACD(Symbol(),0,5,50,5,Applied);
and then copy the specific buffers using the CopyBuffer() function:
CopyBuffer(MACD_handle,0,0,100,MACDMain); // Buffer 0 = Main CopyBuffer(MACD_handle,1,0,100,MACDSignal); // Buffer 1 = Signal
You don't need two handles for the same indicator... you can simply have
and then copy the specific buffers using the CopyBuffer() function:
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
In mql4 I could just type iNameOfIndicator(Parameters), now things seem a lot more complicated, am I missing something?
Nvm, finally figured it out, will post how tomorrow, so tired.