Two Suggestions

 
Dear staff of MQL

Thanks alot for your attempts to develop such powerful product. I wish you consider the following items and apply it to your product if you find it feasible.

1- MQL is a good structured language. What it is lacking now, I think, is ability to define complicated data types(Structures in C). As you know,they help avoiding complicated and out of control arrays. for example keeping various data about many open positions each of them in one instance of the same structure. These structures should be possible to pass to fuctions as well as return type of functions and making arrays of them. A standard library for saving contents of structures is also useful (streams in C?)

This can be a good start to go to OOP system.

2- Ability to save or copy values of indicators as well as OCHL values. This helps statistical analysis of data with other softwares and finding correct coefficints. A standard function for doing this from outside of indicator (some thing like iCustom, but only for saving, not for getting values) may be useful.


Again I thank you for this product.
Best regards
 
AR78:
2- Ability to save or copy values of indicators as well as OCHL values. This helps statistical analysis of data with other softwares and finding correct coefficints. A standard function for doing this from outside of indicator (some thing like iCustom, but only for saving, not for getting values) may be useful.
FileWrite might help.
int handle;
 
int init()
{
    handle = FileOpen(StringConcatenate(Symbol(), Period(), ".csv"), FILE_WRITE | FILE_CSV);
}
 
int start()
{
    FileWrite(handle, TimeToStr(Time[1]), Open[1], High[1], Low[1], Close[1], iCCI(NULL, 0, 20, PRICE_CLOSE, 1)); 
}
 
int deinit()
{
    FileClose(handle);
}
 
Irtron

Thanks for your response. right now, I'm also using the same mathod. but as you see, these are some extra lines in your EA and make it slow and complex.
 
Dear AR78 and Irtron,
Could you tell me at some easier way (I'm a really beginner with MQ) how to change the code for that indictor exactly? I try implement this function into the CCI code but it's not so easy and I really need such a function.
Here is a code for CCI indicator, where this function shuld go?
Or AR78 maybe you know already any other methods how to make it easier?
Thanks for your help!


//+------------------------------------------------------------------+
//| CCI. mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net//"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
//---- input parameters
extern int CCIPeriod = 14;
//---- buffers
double CCIBuffer[];
double RelBuffer[];
double DevBuffer[];
double MovBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 3 additional buffers are used for counting.
IndicatorBuffers(4);
SetIndexBuffer(1, RelBuffer);
SetIndexBuffer(2, DevBuffer);
SetIndexBuffer(3, MovBuffer);
//---- indicator lines
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, CCIBuffer);
//----
if(CCIPeriod <= 0)
CCIPeriod = 14;
//----
SetIndexDrawBegin(0, CCIPeriod);

//---- name for DataWindow and indicator subwindow label
short_name="CCI(" + CCIPeriod + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, short_name);
//----


return(0);
}
//+------------------------------------------------------------------+
//| Commodity Channel Index |
//+------------------------------------------------------------------+
int start()
{
int i, k, counted_bars = IndicatorCounted();
double price, sum, mul;
if(CCIPeriod <= 1)
return(0);
if(Bars <= CCIPeriod)
return(0);
//---- initial zero
if(counted_bars < 1)
{
for(i = 1; i <= CCIPeriod; i++)
CCIBuffer[Bars-i] = 0.0;
for(i = 1; i <= CCIPeriod; i++)
DevBuffer[Bars-i] = 0.0;
for(i = 1; i <= CCIPeriod; i++)
MovBuffer[Bars-i] =0. 0;
}
//---- last counted bar will be recounted
int limit = Bars - counted_bars;
if(counted_bars > 0)
limit++;
//---- moving average
for(i = 0; i < limit; i++)
MovBuffer[i] = iMA(NULL, 0, CCIPeriod, 0, MODE_SMA, PRICE_TYPICAL, i);
//---- standard deviations
i = Bars - CCIPeriod + 1;
if(counted_bars > CCIPeriod - 1)
i = Bars - counted_bars - 1;
mul = 0.015 / CCIPeriod;
while(i >= 0)
{
sum = 0.0;
k = i + CCIPeriod - 1;
while(k >= i)
{
price =(High[k] + Low[k] + Close[k]) / 3;
sum += MathAbs(price - MovBuffer[i]);
k--;
}
DevBuffer[i] = sum*mul;
i--;
}
i = Bars - CCIPeriod + 1;
if(counted_bars > CCIPeriod - 1)
i = Bars - counted_bars - 1;
while(i >= 0)
{
price = (High[i] + Low[i] + Close[i]) / 3;
RelBuffer[i] = price - MovBuffer[i];
i--;
}
//---- cci counting
i = Bars - CCIPeriod + 1;
if(counted_bars > CCIPeriod - 1)
i = Bars - counted_bars - 1;
while(i >= 0)
{
if(DevBuffer[i] == 0.0)
CCIBuffer[i] = 0.0;
else
CCIBuffer[i] = RelBuffer[i] / DevBuffer[i];
i--;
}
//----

return(0);

}

//+------------------------------------------------------------------+
Reason: