hello steve, hello everyone, and regards.
along with the gradual turn from mql4 to mql5 language, codes are becoming less and less understood, at least for the amateur coder. as new codes are published, some of them seems to be very professional in which plenty of thought were invested.
for instance this volatility indicator, coded by mladen rakic.
i tried to disintegrate the main class of the code and transform it into simple function which returns value by requested pair and timeframe, as seen in some of steve's codes, and which can be embeded easily in the shell ea. as for now i went lost with it. will someone take the challenge?
https://www.mql5.com/en/code/26159
embedding class from an indicator in an expert.
-
- Posts: 6
- Joined: Tue Nov 15, 2011 10:06 pm
- tomele
- Administrator
- Posts: 1166
- Joined: Tue May 17, 2016 3:40 pm
- Location: Germany, Forest of Odes, Defending the Limes
embedding class from an indicator in an expert.
Why? MQL4 knows classes ...dvirma wrote:i tried to disintegrate the main class of the code and transform it into simple function which returns value by requested pair and timeframe, as seen in some of steve's codes, and which can be embeded easily in the shell ea. as for now i went lost with it. will someone take the challenge?
Happy pippin, Thomas
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
-
- Posts: 6
- Joined: Tue Nov 15, 2011 10:06 pm
embedding class from an indicator in an expert.
yes. the code itself is in mql4. the thing is that the form of classes isn't common in steve's codes. and i don't manage to merge it. how to call it? how many bars to count? how to inverse the index? how to refer symbol and timeframe to it?
what we are used to is something like that:
double getvolatility(string pair, int timeframe, int shift)
{...
...
return(volatility);
}
and here it works differently.
what we are used to is something like that:
double getvolatility(string pair, int timeframe, int shift)
{...
...
return(volatility);
}
and here it works differently.
- tomele
- Administrator
- Posts: 1166
- Joined: Tue May 17, 2016 3:40 pm
- Location: Germany, Forest of Odes, Defending the Limes
embedding class from an indicator in an expert.
Nobody is interested in what you are used to. Fact is, it will work in Steve's (or any other) code exactly as in the code you attached.
Define a class with constructor (for initialization), (optional) destructor and methods:
Create an instance of the class:
Initialize the instance in OnInit() by calling the constructor:
Call method of the class in OnCalculate() or OnTimer() to get a value (this is the function you are looking for)
You better learn to integrate that than trying to reverse-engineer classes.
Cheers
Define a class with constructor (for initialization), (optional) destructor and methods:
Code: Select all
class cStdDevVolatilityRatio
{...};
Code: Select all
cStdDevVolatilityRatio iVolatilityRatio;
Code: Select all
iVolatilityRatio.init(inpPeriod);
Code: Select all
val[i] = iVolatilityRatio.calculate(iMA(_Symbol,_Period,1,0,MODE_SMA,inpPrice,i),rates_total-i-1,rates_total);
Cheers
Happy pippin, Thomas
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
-
- Posts: 6
- Joined: Tue Nov 15, 2011 10:06 pm
embedding class from an indicator in an expert.
thank you thomas. i will try to do that. i'm also trying to fill the gap and learn the class section in c++.
- tomele
- Administrator
- Posts: 1166
- Joined: Tue May 17, 2016 3:40 pm
- Location: Germany, Forest of Odes, Defending the Limes
embedding class from an indicator in an expert.
Glad to help.
My approach always was to study working code and then look up everything in the language reference that I don't understand. You might try that for yourself. The MQ4 language reference is quite good.
Cheers
My approach always was to study working code and then look up everything in the language reference that I don't understand. You might try that for yourself. The MQ4 language reference is quite good.
Cheers
Happy pippin, Thomas
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate