correct iCustom Parameters for this kalman filter indicator

To add comments, please log in or register
Hydaspes23
14
Hydaspes23  

Hi all,


I have been unable  so far  to figure out the correct (number of ) parameters (value) to be fed into the iCustom helper for this indicator.   https://www.mql5.com/en/code/7313


I want to download the data into a csv file with a script (excerpt below). The script currently returns 1, which is obviously wrong.


Parameters tested  so far:

NULL,0,"kalman-filter-indicator",6,1,1,0

6,1,1,0 i.e.:

mode = 6,(weighted average close)

k =1,

sharpness =1,

shift =0,


Any help appreciated.


Thanks


int KF_handle;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
  {
   
 
  KF_handle=iCustom(NULL,0,"kalman-filter-indicator",6,1,1,0) ;
 
  return (0);

Kalman filter
Kalman filter
  • www.mql5.com
LGP_Ivanoff_Maloma-Demark_levels The indicator shows the price points of reference. LWMA-Crossover_Signal In the case of weighted moving average, the latest data is of more value than...
William Roeder
19417
William Roeder  
  1. Hydaspes23: I have been unable  so far  to figure out the correct (number of ) parameters (value) t

    And yet you correctly identify them. You also know the two buffers. You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 programming forum

    Help you with what, you haven't stated a problem.

  2. Probably doesn't matter, but that indicator is not a Kalman, it is a alpha-beta (a poor man's Kalman.)
              Alpha beta filter - Wikipedia
Hydaspes23
14
Hydaspes23  

William thank you for your prompt reply.


The problem is being unable to correctly implement the iCustom to retrieve a csustom indicator's values in an export script



 I have read the thread on the iCustom implementation though it is still unclear to me  being not familiar with MQL4.


  •    How do I correctly call this Indicator in an export script? Do I have to call the two buffers separately? ( I believe that is not the case).
   However I have attached  below an example (with no encapsulation) where the 2 buffers return the same value, which is understandable. The problem is the indicator's value is not updated throughout the time series.


   What am I missing?





extern string file_name = "Indi2csv.csv";

int fileh =-1;
int lasterror;
double  ExtMapBufferUp;
double ExtMapBufferDown;
//+------------------------------------------------------------------+

int init()
  {
 
   IndicatorShortName("Indicators2CSV");

   fileh = FileOpen(file_name,FILE_CSV|FILE_WRITE,',');
   if(fileh<1)
   {
      lasterror = GetLastError();
      Print("Error updating file: ",lasterror);
      return(false);
   }
   
   // file header - need to be the identifiers of the indicators to be exported   
   FileWrite(fileh,"time","close","open","atr","cci","macd","rsi","stoch","wpr","af1","af2");

   return(0);
   
  }

//+------------------------------------------------------------------+

int deinit()
  {
      if(fileh>0) 
      {
         FileClose(fileh);
      }
   
   return(0);
   
  }
  
//+------------------------------------------------------------------+
  
int start()
  {
   int barcount = IndicatorCounted();
   if (barcount<0) return(-1);
   if (barcount>0) barcount--;
   
   int barind=Bars-barcount-1;
   
      while(barind>1)
      {
         ExportIndiData(barind);
         barind--;
      }
      
   return(0);
   
  }
//+------------------------------------------------------------------+

void ExportIndiData(int barind) 
{
   datetime t = Time[barind];
   string inditime =  
      StringConcatenate(TimeYear(t)+"_"+
                        TimeMonth(t)+"_"+
                        TimeDay(t)+"_"+
                        TimeHour(t)+"_"+
                        TimeMinute(t)+"_"+
                        TimeSeconds(t));
                        
   // add indicators at will (do not forget to update line 31!
   FileWrite(fileh, 
         inditime,
                        Close[barind],
                        Open[barind],
                        iATR(Symbol(),0,14,barind),
                        iCCI(Symbol(),0,14,PRICE_CLOSE,barind),
                        iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,0,barind),
                        iRSI(Symbol(),0,14,PRICE_CLOSE,barind),
                        iStochastic(Symbol(),0,5,3,3,MODE_EMA,0,0,barind),
                        iWPR(Symbol(),0,14,barind),
                        ExtMapBufferUp  = iCustom(NULL,0,"af1",6,1,1,0,barind),     //first buffer       

                        ExtMapBufferDown = iCustom(NULL,0,"af2",6,1,1,1,barind));   //second buffer 
                        
                        
}
time,close,open,atr,cci,macd,rsi,stoch,wpr,af1,af2
2017_12_13_11_0_0,1.17509,1.17495,0,0,0,0,0,0,2147483647,2147483647                              
2017_12_13_12_0_0,1.17391,1.17508,0,0,-9.413105413091927e-05,0,0,0,2147483647,2147483647
2017_12_13_13_0_0,1.174,1.17392,0,0,-0.0001596282497706714,0,0,0,2147483647,2147483647
2017_12_13_14_0_0,1.17574,1.17394,0,0,-7.03211722830055e-05,0,0,0,2147483647,2147483647
2017_12_13_15_0_0,1.17509,1.17575,0,0,-5.140171074979882e-05,0,0,0,2147483647,2147483647
2017_12_13_16_0_0,1.17573,1.1751,0,0,1.506113473381809e-05,0,0,0,2147483647,2147483647
2017_12_13_17_0_0,1.17606,1.17575,0,0,9.328631413274557e-05,0,0,0,2147483647,2147483647
2017_12_13_18_0_0,1.17625,1.17608,0,0,0.0001686674511076625,0,0,0,2147483647,2147483647
2017_12_13_19_0_0,1.17739,1.17626,0,0,0.0003167447812033597,0,79.56521739130575,0,2147483647,2147483647
2017_12_13_20_0_0,1.18203,1.17734,0,0,0.0007992926064213091,0,89.16723087339167,0,2147483647,2147483647
Hydaspes23
14
Hydaspes23  
Can anyone review it?
lippmaje
858
lippmaje  
See here for a MT4 iCustom call sample with explanations. https://www.mql5.com/en/forum/317466#comment_12381978
i need help in writing icustom function for this indicator for sell and buy signal
i need help in writing icustom function for this indicator for sell and buy signal
  • 2019.07.08
  • www.mql5.com
Need help in writing icustom function for this indicator to produce sell and buy signal...
Seng Joo Thio
944
Seng Joo Thio  
Hydaspes23:
Can anyone review it?

Check your "af1" and "af2", because with these lines:

   for (int i=0; i<20; i++)
   {
      double bufUp = iCustom(NULL,0,"Kalman Filter",6,1,1,0,i);
      double bufDn = iCustom(NULL,0,"Kalman Filter",6,1,1,1,i);
      PrintFormat("%d) %s || %f || %f", i, (bufUp==INT_MAX)?"DN":"UP", bufUp, bufDn);
   }

I can get:


William Roeder
19417
William Roeder  
Hydaspes23:
 KF_handle=iCustom(NULL,0,"kalman-filter-indicator",6,1,1,0) ;
Hydaspes23:
                        ExtMapBufferUp  = iCustom(NULL,0,"af1",6,1,1,0,barind),     //first buffer       

                        ExtMapBufferDown = iCustom(NULL,0,"af2",6,1,1,1,barind));   //second buffer 

First you identify a Kalman filter with four parameters, using MT5.

Now you use two unknown indicators with three parameters, using MT4.

To add comments, please log in or register