gen_RBCI
Download scriptThis script is designed as a technical analysis tool for the MetaTrader platform. It functions by processing historical price data to create a smoothed visual representation of market movements, known as a Digital Filter indicator.
Core Functionality
The primary purpose of this tool is to filter out "market noise"—the small, erratic price fluctuations that can often make it difficult to identify the underlying trend. By applying a specific mathematical formula (a digital filter) to historical prices, the script generates a smoother line on your chart. This helps traders visualize the broader direction of the market more clearly.
How the Logic Works
- Data Input Selection: The script allows users to choose which specific price point to analyze. You can toggle between standard closing prices, opening prices, highs, or lows. It also includes a "timeframe" setting, allowing it to pull data from different time periods (e.g., looking at hourly data while viewing a 5-minute chart).
- The Filtering Process: The script utilizes a pre-defined set of mathematical coefficients (a fixed array of numbers). It moves backward through the price history and applies these coefficients to the prices to calculate a new, "filtered" value for each point in time.
- Timeframe Synchronization: Because the tool can look at higher timeframes than what is currently displayed on your screen, it includes logic to "bridge the gaps." When the script calculates a value for a larger timeframe, it automatically calculates the intermediate steps to ensure the resulting line appears smooth and continuous on your smaller timeframe chart.
- Visual Output: The final result is a single line plotted in a separate window below your main price chart. This provides a dedicated space to observe the filtered trend without cluttering the primary price action.
User Experience Features
- Automatic Updates: The script constantly recalculates as new price data enters the system, ensuring the filter remains current.
- Configuration Options: Users can customize the settings to suit their trading style, specifically determining which price source to prioritize and how many historical bars to account for in the calculation.
- Notification System: The script includes a built-in mechanism to occasionally check for user feedback and provide information regarding the developer's contact details and support options after a certain period of use.
// -----------------------------------------------------------------
// RBCI
// Dmitry Yakovlev
// dmitry_yakovlev@rambler.ru
// WebMoney R865705290089
//------------------------------------------------------------------
// Parameters DF:
// RBCI: P1=14, D1=10, A1=40, P2=32, D2=52, A2=40, Ripple=0.08, Delay=0
#property copyright "Dmitry Yakovlev, Russia,Omsk WM R865705290089"
#property link "dmitry_yakovlev@rambler.ru"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_level1 0
#import "shell32.dll" //Connect a dll (provided with Windows)
int ShellExecuteA(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import "user32.dll"
int MessageBoxA(int hWnd ,string lpText,string lpCaption,int uType);
//------------------------------------------------------------------------------------------------------
// ÏÀÐÀÌÅÒÐÛ
extern string _tf="Òàéìôðåéì (0-òåêóùèé)";
extern int tf=0;
extern string _pr="Öåíà 0-cl,1-op,2-hi,3-lo";
extern int pr=0;
extern string _donate1="Äëÿ $ áëàãîäàðíîñòè:";
extern string _donate2="R865705290089";
//---- buffers
double iBuffer[];
double F[]=
{
2.691199613192,+1.626010900780,-1.195783921680,-4.77104086644122205,-7.78505413643392075,-9.03132310064053634,-7.80372779153282536,
-4.13951827019609908,+1.163320991612,+6.76188191299163588,+11.15397741060046140,+13.11871699156124830,+12.07998148043546570,
+8.28402535146624786,+2.737459922192,-3.075898404568,-7.61579112350057930,-9.72021669407401667,-8.92742584636437719,-5.59286994202296217,
-0.770559771803,+4.10251622867368138,+7.62385544817771432,+8.82159223759700595,+7.41618031452429172,+3.87596007134544074,
-0.742564511643,-5.11669038344058524,-8.04317046030676330,-8.77429260479948425,-7.20955807400883675,-3.89443194689721528,
+0.1646559714947,+3.80806824912553266,+6.05852964426727514,+6.38719525085031226,+4.83722847765752562,+1.977522919617,
-1.290686843428,-4.00984248438742785,-5.44080640209669131,-5.25749194937778253,-3.61082293993850500,-1.052962036727,
+1.647947612134,+3.74045011527452687,+4.70038084514470800,+4.36068602221571044,+2.929629039256,+0.900339312952,
-1.112672651372,-2.557150248486,-3.092822520665,-2.666781512071,-1.501233308425,-0.003076500490530,+1.369561632998,
+2.241991878759,+2.419920555926,+1.924920789867,+0.963757414478,-0.1508117461647,-1.099668878826,-1.649038657672,
-1.704949572457,-1.322805187425,-0.670969874791,+0.0316475200492,+0.583722801884,+0.855981672339,+0.818566806255,
+0.533397368134,+0.1208537662723,-0.2795016073586,-0.557469981902,-0.654383076999,-0.573938828315,-0.368861404933,
-0.1172590492627,+0.1048565890013,+0.2451946233721,+0.2856274359772,+0.486611923475
};
int FilterSize=0;
//+------------------------------------------------------------------+
//| Digital filter indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
CheckDonate();
FilterSize=ArraySize(F);
if(tf<Period()) tf=Period();
if(pr>1)pr=0;
//---- indicator line
IndicatorShortName("RBCI-"+tf);
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,iBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
double price(int i)
{
if(pr==0) return(iClose(Symbol(),tf,i));
else if(pr==1) return(iOpen(Symbol(),tf,i));
else if(pr==2) return(iHigh(Symbol(),tf,i));
else if(pr==3) return(iLow(Symbol(),tf,i));
}
//+------------------------------------------------------------------+
int start()
{
int k, nn, nn1, i, j, counted_bars=IndicatorCounted();
int koef=(tf/Period());
double res=0, step=0;
// <--- ðàñ÷èòûâàåì çíà÷åíèÿ èíäèêàòîðà
if (FilterSize>0)
{
if(Bars<=FilterSize) return(0);
//-------------------------------
i=(Bars-counted_bars+FilterSize-1)/koef+1;
//-------------------------------
while(i>=0)
{
res=0;
for (j=0; j<FilterSize; j++)
res+=F[j]*price(i+j);
nn=i*koef;
if(nn!=-1) iBuffer[nn]=NormalizeDouble(res,Digits);
nn1=(i+1)*koef;
if(nn!=-1 && nn1!=-1 && iBuffer[nn1]!=EMPTY_VALUE && iBuffer[nn1]!=0)
{
step=(iBuffer[nn1]-iBuffer[nn])/koef;
for(k=1;k<koef;k++) iBuffer[k+nn]=NormalizeDouble(iBuffer[nn]+step*k,Digits);
}
i--;
}
} else return;
// ðàñ÷èòûâàåì -->
//-------------------------------------------------------------------------
return(0);
}
void CheckDonate()
{
int fd=0; string pay="0"; datetime dt=0;
string fn="DigFlts1.txt";
fd=FileOpen(fn,FILE_READ|FILE_CSV,";");
if(fd>=1)
{
pay=FileReadString(fd); if(pay!="0" && pay!="1") pay="0";
dt=StrToTime(FileReadString(fd));
}
else
{
dt=TimeCurrent();
fd=FileOpen(fn,FILE_WRITE|FILE_CSV,";");
FileWrite(fd,"0",TimeToStr(dt,TIME_DATE));
}
FileClose(fd);
if(pay=="0" && (TimeCurrent()-dt)>10*24*60*60) // 5 äíåé
{
if(MessageBoxA(0,"Åñëè Âàì ïîíðàâèëñÿ èíäèêàòîð RBCI,\n õîòèòå ïîìî÷ü àâòîðó ìàòåðèàëüíî?","Âîïðîñ",4)==6)
{
ShellExecuteA(0,"Open","iexplore.exe","wmk:payto?Purse=R865705290089&Amount=100&Desc=DigitalIndicators&BringToFront=Y&ExecEvenKeeperIsOffline=Y","",7);
pay="1";
}
dt=TimeCurrent();
fd=FileOpen(fn,FILE_WRITE|FILE_CSV,";");
FileWrite(fd,pay,TimeToStr(dt,TIME_DATE));
FileClose(fd);
}
FileClose(fd);
}
Comments