xavilin: It took time to me to learn good old mql4, then stayed some time away from it, and now that i come back i find it all changed. double KAMA[] = iCustom(NULL,0,"kaufman-adaptive-moving-average",5,0); bool ArraySetAsSeries(KAMA , true); return(iMomentumOnArray(KAMA,MK_Period+30,MK_Period,MK_Shift));} |
|
xavilin: It took time to me to learn good old mql4, then stayed some time away from it, and now that i come back i find it all changed. |
|
I know my issues are with old version too. As I said, I wanted now to learn things I didn't learn before. And besides OOP, also init, deinnit and start (ontick) functions changed as well. Your answer was very useful, I do not want anybody to code this for me, I wanted exactly what you did, to put my eyes on what I did wrong. I understand the problem you answered on point 3., I'll take a look at it. However, I do not understand point 4.: from the F1 I thought ArraySetAsSeries is a bool function, what are you trying to point that I cannot see?
Thanks again, I'll try to read on what you pointed. If I have any more doubts I cannot solve by myself I'll ask here again!
xavilin: I know my issues are with old version too. also init, deinnit and start (ontick) functions changed as well. I thought ArraySetAsSeries is a bool function, what are you trying to point that I cannot see? |
|
xavilin: I know my issues are with old version too. also init, deinnit and start (ontick) functions changed as well. I thought ArraySetAsSeries is a bool function, what are you trying to point that I cannot see? |
|
1.I did not complain, I stated it from my ignorance trying to make kind of a joke. Do not be in defensive mode please, I find this community really helpful for people willing to learn, and if there's been people complaining about it i have nothing to do with them. I understand this forum is to find this kind of help, if i want my code programmed I'll just hire someone, and if I want to complain, I know I should do it to mql5 admins. Peace man!
2.Thanks, I did not know that.
3.Thanks again!
If anyone is interested, I found the solution writing this:
//-----Calculate MOMENTUM on KAMA data double MomentumKAMA(int MK_Shift){ int i, // Bar index Counted_bars; // Number of counted bars double KAMA[],MK[]; Counted_bars=IndicatorCounted(); // Number of counted bars i=Bars-Counted_bars-1; // Index of the first uncounted while(i>=0) // Loop for uncounted bars {KAMA[i] = iCustom(NULL,0,"kaufman-adaptive-moving-average",K_Period,K_Fast,K_Slow,5,i); //array containing KAMA data. KAMA parameters are EA input int variables MK[MK_Shift] = iMomentumOnArray(KAMA,50,MK_Period,MK_Shift); //array containing MomentumKAMA data i--; } // Calculating index of the next bar;} return(MK[MK_Shift]);} //returns the exact value of my indicator over KAMA for the given function parameter(shift) so i can compare different time periods (NOT FRAMES!)
Hope this helps somebody.
xavilin: I found the solution writing this: double KAMA[],MK[]; : {KAMA[i] = iCustom(NULL,0 ... | Trying to write to a zero length array isn't a solution. |
xavilin: I found the solution writing this: | Trying to write to a zero length array isn't a solution. |
then please give me some tip instead of trolling, i know you know a lot about arrays as i've seen you on some of the documentation i've been looking for ( http://www.forexfactory.com/showthread.php?t=165411 ), i've done my homework, investigated, read and find out how to write a code which i thought was going to work as it gives no error when compiled (haven't tested yet, maybe i should add some print statement and test it to see what it returns. could you at least help me in this point, please?). if i am in this forum is in search for help, and i've had little 'til the moment, sincerely.
back to the problem, the only documentation i've found on the internet of someone trying to do what i am aiming to do is seen in this link (if it is spam please ask and i'll remove):
http://www.metatrader4.com/forum/378
But unfortunately i do not fully understand what it is done there, so i tryed to adapt this code to something i more less understand. But it happens to be wrong and i get no help...
//-----decide wether to trade or not and which kind of trade (B/S) void Trade_Condition(){ int i, // Bar index, Counted_bars; // Number of counted bars double KAMA[],MK[]; ArrayResize(KAMA,MK_Period+5); ArrayResize(MK,5); Counted_bars=IndicatorCounted(); // Number of counted bars i=Bars-Counted_bars-1; // Index of the first uncounted while(i>=0) // Loop for uncounted bars {KAMA[i] = iCustom(NULL,0,"kaufman-adaptive-moving-average",K_Period,K_Fast,K_Slow,5,i); //array containing KAMA data MK[i] = iMomentumOnArray(KAMA,50,MK_Period,i); //array containing MomentumKAMA data i--; } // Calculating index of the next bar;} //----Now check for Buy or Sell conditions static bool BUY = False; //---define the variable that will give the go for a buy static bool SELL = False; //---define the variable that will give the go for a sell if (MK[1]>MK_Bands && MK[2]<=MK_Bands){ //---Buy condition BUY = True;} if (MK[1]<MK_Bands && MK[2]>=-MK_Bands){ //---Sell condition SELL = True;} }one doubt that i have is wether i should call ArrayResize in the init function (with array declarations in the general part) or leave it this way. also, if static bool BUY and SELL should be declared in the function or outside it.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody,
It took time to me to learn good old mql4, then stayed some time away from it, and now that i come back i find it all changed. Far from discouraging, I am trying to use this changes to learn a little bit more than what i used to know.. Thus, i before only programmed few indicators and easy EA that displayed signals for me to manual trade. Now i want to automate everything, and I am trying to learn how functions work so that i can write long and extent codes and use them in multitimeframes and multi-asset EAs.
The code I am trying to buld now is the function that gives me the buy condition. But before i need to calculate the value of momentum over a custom indicator data array. So i am writing this:
But it does not work. All variables are declared, some as input parameters, , and the errors I get from the MetaEditor are:
'KAMA' - invalid array access prueba1.mq4 33 11
'ArraySetAsSeries' - function can be declared only in the global scope prueba1.mq4 34 9
'KAMA' - declaration without type prueba1.mq4 34 26
'true' - declaration without type prueba1.mq4 34 33
'true' - comma expected prueba1.mq4 34 33
5 error(s), 0 warning(s) 6 1
Any help will be appreciated. The aim is to get a value for the momentum in order to be compared in my BUY Condition function. Thanks!