//+------------------------------------------------------------------+ //| SumLogSample.mq4 | //| Igore | //| http://forum.alpari-idc.ru/index.php | //+------------------------------------------------------------------+ #property copyright "Igore" #property link "http://forum.alpari-idc.ru/index.php" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red //---- buffers extern bool revers=false; double A1=1,A2=1,A3=1,A4=1; int N;// ïåðèîä double IndexBuffer[]; double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; int beginBar; double sign; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { int per=Period(); //---- indicators IndicatorBuffers(5); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,IndexBuffer); SetIndexBuffer(1,ExtMapBuffer1); SetIndexBuffer(2,ExtMapBuffer2); SetIndexBuffer(3,ExtMapBuffer3); SetIndexBuffer(4,ExtMapBuffer4); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); SetIndexEmptyValue(2,0.0); SetIndexEmptyValue(3,0.0); SetIndexEmptyValue(4,0.0); SetIndexLabel(0,"USD Index"); IndicatorShortName("Index USD Sample("+N+")"); switch (per) { case 15: {N=32; break;} case 30: {N=16; break;} case 60: {N=24; break;} case 240: {N=30; break;} case 1440: {N=22;break;} default: N=0; } IndicatorShortName("Index USD Sample("+N+")"); if (revers) sign=-1; else sign=1; //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- int i,limit,limit1,Bars1,Bars2,Bars3,Bars4; //if (Bars>beginBar) if (N==0) { Alert("Ñìåíèòå òàéì-ôðåéì"); return; } if (counted_bars==0) { Bars1=iBars("EURUSD",Period())-1; Bars2=iBars("GBPUSD",Period())-1; Bars3=iBars("USDJPY",Period())-1; Bars4=iBars("AUDUSD",Period())-1; beginBar=MathMin(MathMin(Bars1,Bars2),MathMin(Bars3,Bars4)); limit=MathMin(Bars-1,beginBar); limit1=limit-N; } if (counted_bars>0) { limit=Bars-counted_bars; limit1=limit; } if (counted_bars<0) return(-1); limit--; for (i=limit;i>=0;i--) { ExtMapBuffer1[i]=-MathLog(iClose("EURUSD",Period(),i)/iClose("EURUSD",Period(),i+1)); ExtMapBuffer2[i]=-MathLog(iClose("GBPUSD",Period(),i)/iClose("GBPUSD",Period(),i+1)); ExtMapBuffer3[i]=MathLog(iClose("USDJPY",Period(),i)/iClose("USDJPY",Period(),i+1)); ExtMapBuffer4[i]=-MathLog(iClose("AUDUSD",Period(),i)/iClose("AUDUSD",Period(),i+1)); } for (i=limit1;i>=0;i--) { IndexBuffer[i]=sign*(A1*iMAOnArray(ExtMapBuffer1,0,N,0,MODE_SMA,i)+ A2*iMAOnArray(ExtMapBuffer2,0,N,0,MODE_SMA,i)+ A3*iMAOnArray(ExtMapBuffer3,0,N,0,MODE_SMA,i)+ A4*iMAOnArray(ExtMapBuffer4,0,N,0,MODE_SMA,i))*N*1000; //if (i==0) Print(IndexBuffer[i]); } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen