//------------------------------------------------------------------ // Digital Filter // Dmitry Yakovlev // dmitry_yakovlev@rambler.ru // WebMoney R865705290089 //------------------------------------------------------------------ // Original DF.dll // copyright "Copyright (c) 2005, Sergey Iljukhin, Novosibirsk" // "mailto:sergey@tibet.ru" //------------------------------------------------------------------ #property copyright "Dmitry Yakovlev, Russia,Omsk, WM R865705290089" #property link "dmitry_yakovlev@rambler.ru" #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 CLR_NONE #property indicator_color2 Lime #property indicator_color3 Red #property indicator_width1 0 #property indicator_width2 2 #property indicator_width3 2 #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); #import "DF.dll" int DigitalFilter(int FType,int P1,int D1,int A1,int P2,int D2,int A2,double Ripple,int Delay,double &arr[]); #import /* Цифровые фильтры для MetaTrader 4. Внимание! Для работы требуется три дополнительных DLL содержащих блок математической обработки - bdsp.dll, lapack.dll, mkl_support.dll, которые должны быть установлены в C:\Windows\System32\ или рядом с DF.dll в \experts\libraries\ Перед использованием убедитесь: 1. что установлены пункты "Allow DLL import" и "Confirm DLL function's call" в настройках Options->Expert Advisors 2. Что в директории C:\Windows\System32\ имеются Bdsp.dll, lapack.dll, mkl_support.dll - вспомогательные математические библиотеки. Описание входных параметров: Ftype - Тип фильтра: 0 - ФНЧ (FATL/SATL/KGLP), 1 - ФВЧ (KGHP), 2 - полосовой (RBCI/KGBP), 3 - режекторный (KGBS) P1 - Период отсечки P1, бар D1 - Период отсечки переходного процесса D1, бар A1 - Затухание в полосе задержки А1, дБ P2 - Период отсечки P2, бар D2 - Период отсечки переходного процесса D2, бар A2 - Затухание в полосе задержки А2, дБ Ripple - Биения в полосе пропускания, дБ Delay - Задержка, бар Для ФНЧ и ФВЧ значения параметрой P2,D2,A2 игнорируются Условия работы: ФНЧ: P1>D1 ФВЧ: P1P2>P1>D1 */ 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 _par="Preset 0-User,1-FATL,2-SATL,3-RFTL,4-RSTL"; extern int preset=0; extern string _filt="Указываем параметры фильтра"; extern int FType=0; extern int P1=14; extern int D1=10; extern int A1=40; extern int P2=0; extern int D2=0; extern int A2=0; extern int Delay=0; extern double Ripple=0.08; extern int BarShift=0; // Сдвиг графика, бар. Минус - назад, плюс - вперед extern string _donate1="Для $ благодарности:"; extern string _donate2="R865705290089"; //---- indicator buffers double iBuffer[]; double up[]; double dn[]; double trend[]; //------ int FilterSize=0; double F[1500]; //--- int init() { CheckDonate(); if(tf0) { if(Bars<=FilterSize) return(0); //------------------------------- i=(Bars-counted_bars+FilterSize-1)/koef+1; if(counted_bars==0 && i>=Bars) i=Bars-FilterSize-1; limit=i; //------------------------------- while(i>=0) { res=0; for(j=0; j //------------------------------------------------------------------------- // <-- раскрашиваем for(int x=limit-1;x>=0;x--) { trend[x]=trend[x+1]; if(iBuffer[x]> iBuffer[x+1]) trend[x] =1; if(iBuffer[x]< iBuffer[x+1]) trend[x] =-1; if(trend[x]>0) { up[x]=iBuffer[x]; if(trend[x+1]<0) up[x+1]=iBuffer[x+1]; dn[x]=EMPTY_VALUE; } else if(trend[x]<0) { dn[x]=iBuffer[x]; if(trend[x+1]>0) dn[x+1]=iBuffer[x+1]; up[x]=EMPTY_VALUE; } } // раскрашиваем --> //------------------------------------------------------------------------- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void CheckDonate() { int fd=0; string pay="0"; datetime dt=0; string fn="DigitalFilterTF.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,"Если Вам понравился индикатор DigitalFilterTF,\n хотите помочь автору материально?","Вопрос",4)==6) { ShellExecuteA(0,"Open","iexplore.exe","wmk:payto?Purse=R865705290089&Amount=100&Desc=Indicator&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); } //+------------------------------------------------------------------+