//+------------------------------------------------------------------+ //| sinTrend TrendOSC.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ //mod2008fxtsd mladen ki #property copyright "Copyright © 2005, DVYU." #property link "http://www.DVYU.ox" #property indicator_buffers 4 #property indicator_color1 Gold #property indicator_color2 OrangeRed #property indicator_color3 DarkOrange #property indicator_color4 Red #property indicator_separate_window #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 // // // // // extern int TimeFrame = 0;//ïàðàìåòðû extern bool useCustom_g_period = false; extern int Custom_g_period = 36;//Îáúÿâëåíèå ãëîáàëüíûõ ïåðåìåííûõ extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF"; extern string defaultGperiods.TF = "110M1;905M,60M15,42M30,36H1;24H4;18D1;12W1;3MN1"; // // // // // double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double z_buffer[]; int g_period; //Îáúÿâëåíèå ãëîáàëüíûõ ïåðåìåííûõ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(5); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(3,ExtMapBuffer4); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexBuffer(4,z_buffer); // // // // // TimeFrame = MathMax(TimeFrame,Period()); switch(TimeFrame) { case 1 : string TimeFrameStr="M1"; g_period=110; break; case 5 : TimeFrameStr="M5"; g_period=90; break; case 15 : TimeFrameStr="M15"; g_period=60; break; case 30 : TimeFrameStr="M30"; g_period=42; break; case 60 : TimeFrameStr="H1"; g_period=36; break; case 240 : TimeFrameStr="H4"; g_period=24; break; case 1440 : TimeFrameStr="D1"; g_period=18; break; case 10080 : TimeFrameStr="W1"; g_period=12; break; case 43200 : TimeFrameStr="MN1"; g_period=3; break; default : TimeFrameStr="TF 0"; } string ShortName = ("sinTrend ["+TimeFrameStr+"] default_g ("+g_period+")"); if (useCustom_g_period) { g_period = Custom_g_period ; ShortName = (ShortName + " | g ("+g_period+")"); } // // // // // IndicatorShortName(ShortName); return(0); } int deinit() { return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int start() { int counted_bars=IndicatorCounted(); int i,limit,y; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit= Bars-counted_bars; limit= MathMax(limit,TimeFrame/Period()); // // // // // datetime TimeArray[]; ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); for(i=0,y=0;i<limit;i++) { if (Time[i]<TimeArray[y]) y++; z_buffer[i] = MathSin((iClose(NULL,TimeFrame,y)-iClose(NULL,TimeFrame,y+g_period))/g_period); } // // // // // for(i=limit;i>=0;i--) { if (z_buffer[i]==z_buffer[i+1]) { ExtMapBuffer1[i]=ExtMapBuffer1[i+1]; ExtMapBuffer2[i]=ExtMapBuffer2[i+1]; ExtMapBuffer3[i]=ExtMapBuffer3[i+1]; ExtMapBuffer4[i]=ExtMapBuffer4[i+1]; continue; } // // // // // ExtMapBuffer1[i]=EMPTY_VALUE; ExtMapBuffer2[i]=EMPTY_VALUE; ExtMapBuffer3[i]=EMPTY_VALUE; ExtMapBuffer4[i]=EMPTY_VALUE; if (z_buffer[i]>0) { if (z_buffer[i] > z_buffer[i+1]) ExtMapBuffer1[i] = z_buffer[i]; else ExtMapBuffer2[i] = z_buffer[i]; } if (z_buffer[i]<0) { if (z_buffer[i] > z_buffer[i+1]) ExtMapBuffer3[i] = z_buffer[i]; else ExtMapBuffer4[i] = z_buffer[i]; } } return(0); }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features: