You can take this approach:
//+------------------------------------------------------------------+ //| test.mq5 | *** //--- int handle_1_1; // variable for storing the handle of the iCustom indicator int handle_2_1; // variable for storing the handle of the iCustom indicator int handle_3_1; // variable for storing the handle of the iCustom indicator int handle_1_2; // variable for storing the handle of the iCustom indicator int handle_2_2; // variable for storing the handle of the iCustom indicator int handle_3_2; // variable for storing the handle of the iCustom indicator int handle_1_3; // variable for storing the handle of the iCustom indicator int handle_2_3; // variable for storing the handle of the iCustom indicator int handle_3_3; // variable for storing the handle of the iCustom indicator //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create handle of the indicator iCustom handle_1_1=iCustom(Symbol(),PERIOD_M1,"Indicator1",0,1); //--- if the handle is not created if(handle_iMACD==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle ('handle_1_1') of the iCustom indicator for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } *** //--- return(INIT_SUCCEEDED); }
OP's posted code was MT4.
ind1_1 = iCustom(NULL,PERIOD_M1,"Indicator1",0,1);
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time, post in the correct place. The moderators will likely move this thread there soon.
Thanks William, could you, or any of the moderators, please move it to the correct section?
Thanks Vladimir, now how exactly does this improve the code performance? I am missing that part.
Thanks William, could you, or any of the moderators, please move it to the correct section?
Thanks Vladimir, now how exactly does this improve the code performance? I am missing that part.
Please ask all questions about the OLD TERMINAL in the SPECIAL SECTION: ( MQL4 and MetaTrader 4 ) - do not bring confusion and rows of MQL5 users!
I cannot create a new topic now. I need to wait 5 hours apparently. That's why I asked if someone can move it over there.
Hi,
I have 3 indicators. I need to check their values on 3 timeframes. What would be the efficient way to code it?
I currently have it like this (pseudo code):
Please let me know if there's a way to code it better.
Thanks
-RJ
set partition for each indicator
for example:
if(1 & 2 & 3) Indicator_1 == true if(4 & 5 & 6) Indicator_2 == true if(Indicator_1 || Indicator_2) Buy Place; . . .
Your code | Indicator_1 == false if(1 & 2 & 3) Indicator_1 == true |
simplified | Indicator_1 = 1 && 2 && 3; |
Well, in the original logic any one of the 9 conditions can satisfy the trade condition.
There is no (1 & 2 & 3) there.
I mean, if the condition is satisfied on M1, the trade is true. If it is satisfied on M5, the trade is true and so on.
I was thinking of a function where you pass the indicator name as parameter, it checks all the required timeframes and returns a yes or no. I am not sure how to code it or if it will yield better performance. Code might look concise and neat though.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have 3 indicators. I need to check their values on 3 timeframes. What would be the efficient way to code it?
I currently have it like this (pseudo code):
Please let me know if there's a way to code it better.
Thanks
-RJ