//+------------------------------------------------------------------+ //| Kamikaze.mq4 | //| Copyright © 2009, klentz | //| periods are fixed: 5, 15, 30, 60 minutes | //+------------------------------------------------------------------+ #property copyright "klentz" #property indicator_separate_window #property indicator_buffers 8 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Blue #property indicator_color4 Red #property indicator_color5 Blue #property indicator_color6 Red #property indicator_color7 Blue #property indicator_color8 Red #property indicator_minimum -0.5 #property indicator_maximum 5 extern int SMA = 50; double buffer1[], buffer2[], buffer3[], buffer4[], buffer5[], buffer6[], buffer7[], buffer8[]; int init() { for (int i=0; i<8; i++) { SetIndexStyle(i,DRAW_ARROW); SetIndexArrow(i,110); SetIndexEmptyValue(i,EMPTY_VALUE); } SetIndexBuffer(0,buffer1); SetIndexBuffer(1,buffer2); SetIndexBuffer(2,buffer3); SetIndexBuffer(3,buffer4); SetIndexBuffer(4,buffer5); SetIndexBuffer(5,buffer6); SetIndexBuffer(6,buffer7); SetIndexBuffer(7,buffer8); return(0); } int start() { int limit; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars-=60/Period()+1; limit = Bars - counted_bars; double tf_scale5 = Period()/5.0; double tf_scale15 = Period()/15.0; double tf_scale30 = Period()/30.0; double tf_scale60 = Period()/60.0; int i5 = 0, i15 = 0, i30 = 0, i60 = 0; for(int i = 0; i < limit; i++) { if (tf_scale5<1.0 && Time[i]<iTime(NULL,PERIOD_M5,i5)) i5++; if (tf_scale5>1.0) i5 = i+1; if (tf_scale5==1.0) i5 = i; double price_typical5 = (iHigh(NULL, PERIOD_M5, i5) + iLow(NULL, PERIOD_M5, i5) + iClose(NULL, PERIOD_M5, i5)) / 3; double sma_trend5 = price_typical5 - iMA(NULL, PERIOD_M5, SMA, 0, MODE_SMA, PRICE_TYPICAL, i5); if (tf_scale15<1.0 && Time[i]<iTime(NULL,PERIOD_M15,i15)) i15++; if (tf_scale15>1.0) i15 = i+1; if (tf_scale15==1.0) i15 = i; double price_typical15 = (iHigh(NULL, PERIOD_M15, i15) + iLow(NULL, PERIOD_M15, i15) + iClose(NULL, PERIOD_M15, i15)) / 3; double sma_trend15 = price_typical15 - iMA(NULL, PERIOD_M15, SMA, 0, MODE_SMA, PRICE_TYPICAL, i15); if (tf_scale30<1.0 && Time[i]<iTime(NULL,PERIOD_M30,i30)) i30++; if (tf_scale30>1.0) i30 = i+1; if (tf_scale30==1.0) i30 = i; double price_typical30 = (iHigh(NULL, PERIOD_M30, i30) + iLow(NULL, PERIOD_M30, i30) + iClose(NULL, PERIOD_M30, i30)) / 3; double sma_trend30 = price_typical30 - iMA(NULL, PERIOD_M30, SMA, 0, MODE_SMA, PRICE_TYPICAL, i30); if (tf_scale60<1.0 && Time[i]<iTime(NULL,PERIOD_H1,i60)) i60++; if (tf_scale60>1.0) i60 = i+1; if (tf_scale60==1.0) i60 = i; double price_typical60 = (iHigh(NULL, PERIOD_H1, i60) + iLow(NULL, PERIOD_H1, i60) + iClose(NULL, PERIOD_H1, i60)) / 3; double sma_trend60 = price_typical60 - iMA(NULL, PERIOD_H1, SMA, 0, MODE_SMA, PRICE_TYPICAL, i60); buffer1[i]=EMPTY_VALUE; buffer2[i]=EMPTY_VALUE; buffer3[i]=EMPTY_VALUE; buffer4[i]=EMPTY_VALUE; buffer5[i]=EMPTY_VALUE; buffer6[i]=EMPTY_VALUE; buffer7[i]=EMPTY_VALUE; buffer8[i]=EMPTY_VALUE; if (sma_trend5 > 0) buffer1[i] = 1; else buffer2[i] = 1; if (sma_trend15 > 0) buffer3[i] = 2; else buffer4[i] = 2; if (sma_trend30 > 0) buffer5[i] = 3; else buffer6[i] = 3; if (sma_trend60 > 0) buffer7[i] = 4; else buffer8[i] = 4; } return(0); }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_ARROW
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: