Good day to you,
Programming is a problem for me. I was hoping someone with skill could assist.
I need code added to the standard Stoch indicator to allow a sensitivity factor to be chosen. The creator has given a full explanation here:
http://codebase.mql4.com/6224
The code to be added:
The indicator fields is the same as for iStochastic, the difference is that there is an additional parameter Sens - sensivity.
The output buffers are the same: 0-Stochastic value itself, 1-signal line.
double iCustom(string symbol, int timeframe, "_StochNR", int %Kperiod, int %Dperiod, int slowing, int method, int price_field, int Sens, int mode, int shift); // StochNR added new Sens fielddouble iStochastic(string symbol, int timeframe, int %Kperiod, int %Dperiod, int slowing, int method, int price_field, int mode, int shift) // standard stochastic For a practical use, it is possible to calll it as specified above, but better to perform it in another way. Just add some code to yours Stoch function:
double Stoch(int Kperiod, int Slowing, int PriceFild, double sens, int i) { // maximal and minimal prices double max,min,c; for(int j=i; j<i+Slowing; j++) { if(PriceFild==1) { // по Close max+=Close[ArrayMaximum(Close,Kperiod,j)]; min+=Close[ArrayMinimum(Close,Kperiod,j)]; } else { // по High/Low max+=High[ArrayMaximum(High,Kperiod,j)]; min+=Low[ArrayMinimum(Low,Kperiod,j)]; } c+=Close[j]; } double delta=max-min; if(delta<sens) { sens/=2; max+=sens; min-=sens; } delta=max-min; if(delta==0) double s0=1; else s0=(c-min)/delta; return(100*s0); }It's clear, that if you need a signal line, you need an additional moving average of its value. Another way is to get it from the iCustom's 1st buffer, but it will be slow.
As you see, now the name is more informative, there is a price calculation type. If sensivity is defined greater than 0, its value is added to the oscillator's name.
I attach the Stoch indi as well as the additional information/ code.
Could anyone see if they can do this?
With great appeciation.
Regards and thank you
Programming is a problem for me. I was hoping someone with skill could assist.
I need code added to the standard Stoch indicator to allow a sensitivity factor to be chosen. The creator has given a full explanation here:
http://codebase.mql4.com/6224
The code to be added:
The indicator fields is the same as for iStochastic, the difference is that there is an additional parameter Sens - sensivity.
The output buffers are the same: 0-Stochastic value itself, 1-signal line.
double iCustom(string symbol, int timeframe, "_StochNR", int %Kperiod, int %Dperiod, int slowing, int method, int price_field, int Sens, int mode, int shift); // StochNR added new Sens fielddouble iStochastic(string symbol, int timeframe, int %Kperiod, int %Dperiod, int slowing, int method, int price_field, int mode, int shift) // standard stochastic For a practical use, it is possible to calll it as specified above, but better to perform it in another way. Just add some code to yours Stoch function:
double Stoch(int Kperiod, int Slowing, int PriceFild, double sens, int i) { // maximal and minimal prices double max,min,c; for(int j=i; j<i+Slowing; j++) { if(PriceFild==1) { // по Close max+=Close[ArrayMaximum(Close,Kperiod,j)]; min+=Close[ArrayMinimum(Close,Kperiod,j)]; } else { // по High/Low max+=High[ArrayMaximum(High,Kperiod,j)]; min+=Low[ArrayMinimum(Low,Kperiod,j)]; } c+=Close[j]; } double delta=max-min; if(delta<sens) { sens/=2; max+=sens; min-=sens; } delta=max-min; if(delta==0) double s0=1; else s0=(c-min)/delta; return(100*s0); }It's clear, that if you need a signal line, you need an additional moving average of its value. Another way is to get it from the iCustom's 1st buffer, but it will be slow.
As you see, now the name is more informative, there is a price calculation type. If sensivity is defined greater than 0, its value is added to the oscillator's name.
I attach the Stoch indi as well as the additional information/ code.
Could anyone see if they can do this?
With great appeciation.
Regards and thank you
Attached File(s)
_StochNR.mq4
4 KB
|
309 downloads
StochNR.mqh
< 1 KB
|
242 downloads