|
(Just for demo version)
The sample of write CCI.mq4 to DLL
The origin int start() of CCI.mq4 as below: //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+
When we write it to DLL, it will be: //+------------------------------------------------------------------+ int start() { double Zlock[][6]; ArrayCopyRates(Zlock); Jmi8_dll_mq4 (Zlock,IndicatorCounted(), Bars, CCIPeriod, CCIBuffer, RelBuffer, DevBuffer, MovBuffer); return(0); } //+------------------------------------------------------------------+ We use one row code ( red ) take the place of original 50 rows code. Thus, if someone turns the ex4 to mq4 by EX4-MQ4 decompiler, he will not understand how the Jmi8_dll_mq4() to work, and the function Jmi8_dll_mq4() can’t work if it not been registered.
If you want to protect your mq4 by this method, you must give me your all or part of mq4 files. I can write a special DLL function for your mq4 code. Please trust to me, I will not use or sold your mq4 code.
|
||