Thread: Jurik
View Single Post
  #18 (permalink)  
Old 11-03-2005, 10:56 AM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 20,059
Blog Entries: 241
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
I want to say about JJMASeries.mqh file.
This file was created by Nikolay Kositsin to help the mql4 program developers to get JMA smoothing for the almost all indicators.


Please find this file translated to the English and note that it should be in your MetaTrader\experts\include\ folder.

The description of this function is the following:

JJMASeries function is created for the implementation of JMA algorithm during the programming all indicators for the changing the calculation of the classic averaging to this JMA algorithm. This version of file is not supporting EAs.

Input parameters:

nJMAnumber - access number to the function JJMASeries. (0, 1, 2, 3 etc).

nJMAdinJ - parameter, allowing to change the parameters nJMALength and nJMAPhase on every bar. 0 - changing prohibited, any other value - permission.

nJMAMaxBar - maximum value, it may be the number of the calculating bar. Usually Bars-1.

nJMAlimit - number of not counted bars yet plus 1 or number of last uncounted bar, usually: Bars-IndicatorCounted()-1.

nJMALength - intensity of smoothing.

nJMAPhase - parameter changing the value between -100 ... +100, affecting on the quality of the transition process.

dJMAseries - input parameter for the calculation of the JJMASeries function.

nJMAbar - number of the calculating bar; this parameter should be changed by loop operator from the max value to zero.

nJMAreset - parameter, the inner variables of the JJMASeries function will be initialized if the value is -1.


Output parameters:

JJMASeries() - value of dJMAJMA function.

nJMAreset - parameter returning the non-zero value in case of error in function calculation. This parameter should be variable only, not the value!


Function call mechanism:

When the number of the bars is 0 it is necessary to initialize the inner variables of JJMASeries function before calling the JJMASeries function. Do it using the following parameters:
reset=-1; dJMAJMASeries(0,MaxJMAnumber+1,0,0,0,0,0,0,reset);
It is necessary the make the nJMAnumber(MaxJMAnumber) parameter equal to the number of calls to the JJMASeries function, that is increase of nJMAnumber maximum by 1. And nJMAreset should be assigned by the reset variable to -1 (do not insert the -1 in the function, it should be done by parameter only!). Other parameters must be assigned to 0. During the programming custom indicators and EA with JJMASeries function it is not recommended for variable to name indicators and EAs starting from JMA... or dJMA...


Example of function call:

Code:
int start()
{
int reset,counted_bars=IndicatorCounted();
//----+ check for possible errors
if (counted_bars<0) return (-1);
int limit=Bars-counted_bars-1;
//----+ initialization if inner variables of JJMASeries function (one calling, nJMAPhase and nJMALength parameters are not changed )
if (limit==Bars-1){reset=-1;int set=JdJMAJMASeries(0,1,0,0,0,0,0,0,reset);if((reset==1)||(set!=0))return(-1);reset=1;}
//----+ JJMASeries function call for the Ind_Buffer[] buffer calculation
for(int x=limit;x>=0;x--)
 (
  reset=1;
  Series=Close[x];
  Ind_Buffer[x]=JJMASeries(0,0,Bars-1,limit,Phase,Length,Series,x,reset);
  if (reset!=0)return(-1);
 }
return(0);
}
#include <JJMASeries.mqh>
Attached Files
File Type: zip JJMASeries.zip (5.0 KB, 809 views)
Reply With Quote