hey,
i have a custom indicator i would like to use (included here),
i need a certain value from a function,
the function calculates the MA angle,
if you will look at the code you will see a var called fAngle there,
i tried to Return it and failed...
how can i extract it to my main mq4 file?
thanks.
UpBuffer[i] = fAngle;
You need to look at UpBuffer . . . . you can do it using iCustom()
There has been a thread about iCustom recently, search for it and it will help you . . .
hey,
i have a custom indicator i would like to use (included here),
i need a certain value from a function,
the function calculates the MA angle,
if you will look at the code you will see a var called fAngle there,
i tried to Return it and failed...
how can i extract it to my main mq4 file?
thanks.
I see the function ReturnAngle and it is not called anywhere. In any case that is not how you get data from an indicator. This variable you want will be a pain to get to as it is because you would have to read all three buffers to figure out which one was holding the fAngle value. I think it is going to be easier to just include a fourth buffer which is always set to fAngle (which does not need to be displayed) and read that using iCustom as Raptor has suggested.
//---- indicator buffers double UpBuffer[]; double DownBuffer[]; double ZeroBuffer[]; double fAngleBuffer[]; // NEW BUFFER
DownBuffer[i] = 0.0; UpBuffer[i] = 0.0; ZeroBuffer[i] = 0.0; if(fAngle > AngleTreshold) { UpBuffer[i] = fAngle; } else if (fAngle < -AngleTreshold) { DownBuffer[i] = fAngle; } else ZeroBuffer[i] = fAngle; fAngleBuffer[i] = fAngle; // POPULATE the new buffer
Change indicator buffer count to 4 and ...
//---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2); SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,2); SetIndexStyle(3,DRAW_NONE); // don't show this one IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2); //---- 4 indicator buffers mapping if(!SetIndexBuffer(0,UpBuffer) && !SetIndexBuffer(1,DownBuffer) && !SetIndexBuffer(2,ZeroBuffer) && !SetIndexBuffer(3,fAngleBuffer)) // new buffer linked Print("cannot set indicator buffers!");
hey, thanks again for the replays, it really helped me.
there is something i dont understand,
the loop for(i=0; i<nLimit; i++)
as i understood the nLimit is the delta each time you recompile it takes only the new bars,
and still using double angle = iCustom(NULL, 0, "angle ma",3, 0); giving me the right answer -> the current angle (ima(....0) and ima(....6));
is that taking the parameter fAngleBuffer[0]?
the loop for(i=0; i<nLimit; i++)
as i understood the nLimit is the delta each time you recompile it takes only the new bars,
"recompile" is not the right word there. When you first run the indicator all the chart positions need to be created. Then on the next price update (tick) everything is already in place and correct apart from the most recent position on the chart so nLimit starts off really large and almost immediately drops down to something around 2. "compile" or "recompile" is what you do in the metaeditor when you change your code and the editor/compiler works out how to convert your code into something the computer can understand (source code -.MQ4 become executable code .EX4).
double angle = iCustom(NULL, 0, "angle ma",3, 0)
is not the right call. Read this again carefully ...
https://docs.mql4.com/indicators/icustom
//---- indicator parameters extern int EMAPeriod=10; extern double AngleTreshold=0.2; extern int StartEMAShift=6; extern int EndEMAShift=0;
You need to supply these parameters as well. You got the mode and shift correct! Just fill in 4 missing parameters and you should be good to go.
double angle = iCustom(NULL, 0, "angle ma",10,0.2,6,0,3, 0)
The format:
iCustom(NULL, 0, "angle ma",3, 0);
is the correct call.
Providing values the indicator already have is redundant.
If you have the source code for the indicator, it's much more error proof if you modify the parameters within the indicator itself instead of having to remember the order-of-declaration of the external values. You can comment the original values next to the changed values for future reference.
Parameters set (if necessary). <----From the Docs should mean something.
The format:
is the correct call.
Providing values the indicator already have is redundant.
If you have the source code for the indicator, it's much more error proof if you modify the parameters within the indicator itself instead of having to remember the order-of-declaration of the external values. You can comment the original values next to the changed values for future reference.
Parameters set (if necessary). <----From the Docs should mean something.
Sadly, I have to agree with you. The idea that those parameters are optional in the middle of a function call was too bizarre to contemplate. Ordinarily default parameters are at the end of a function call. I have tried it and it apparently works as you say. I interpreted the (if necessary) comment to mean that not all indicators need parameters set (if there are no extern parameters).
It's all good, we're like a tight nit family here :). Happy Piping.
To be fair a "tight nit family" would be a family of parasites :-)
https://en.wikipedia.org/wiki/Head_lice definition in the contents #3
The idiom you were looking for is
http://www.merriam-webster.com/dictionary/tight-knit
knitting being the action of taking a pair of things like chopsticks and making woolen garments :-)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hey,
i have a custom indicator i would like to use (included here),
i need a certain value from a function,
the function calculates the MA angle,
if you will look at the code you will see a var called fAngle there,
i tried to Return it and failed...
how can i extract it to my main mq4 file?
thanks.