//+------------------------------------------------------------------+ //| Saya_MA_Cross.mq4| //| Copyright (c) 2012, FX_Kuraisora| //| http://goldsearch.blog24.fc2.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright ゥ 2010, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 7 #property indicator_color1 MediumBlue #property indicator_width1 1 #property indicator_style1 0 #property indicator_color2 Aqua #property indicator_width2 2 #property indicator_style2 0 #property indicator_color3 Magenta #property indicator_width3 2 #property indicator_style3 0 #property indicator_color4 LightSeaGreen #property indicator_width4 1 #property indicator_style4 2 #property indicator_color5 LightSeaGreen #property indicator_width5 1 #property indicator_style5 2 //---- buffers double Saya[]; double SayaSSM[]; double SayaLSM[]; double SayaSTD; double STDUL[]; double STDDL[]; double open,close; double open2,close2; double Kairi; extern string symbol = "AUDJPY";//通貨ペア1 1st_Pair extern string symbol2 = "NZDJPY";//通貨ペア1 2nd_Pair extern int SSMPriod = 21;//ShortMA計算期間 extern int LSMPriod = 200;//LongMA計算期間 extern int MAMethod = 1;// 0:SMA 1:EMA 2:SMMA 3:LWMA extern double Pair1_double = 1;//倍率 Def=1 extern double Pair2_double = 1;//倍率 Def=1 extern bool RawdataMODE = false;//サヤの生データ表示機能 extern bool STDEnvelope = false;//標準偏差エンベロープ表示機能 extern int STDPriod = 200;//エンベロープ標準偏差計算期間 extern int STDdouble = 2;//エンベロープ標準偏差倍率 extern color Color_0 = MediumBlue; extern color Color_1 = Aqua; extern color Color_2 = Magenta; extern color Color_3 = LightSeaGreen; string ShortName = "Saya_MA_Cross"; int init() { string label = ShortName +" "+symbol+" vs "+symbol2+" SMA("+SSMPriod+") LMA("+LSMPriod+")"; IndicatorShortName(label); IndicatorBuffers(5); SetIndexStyle(0,DRAW_LINE,0,EMPTY,Color_0); SetIndexBuffer(0, Saya); SetIndexStyle(1,DRAW_LINE,0,EMPTY,Color_1); SetIndexBuffer(1, SayaSSM); SetIndexStyle(2,DRAW_LINE,0,EMPTY,Color_2); SetIndexBuffer(2, SayaLSM); SetIndexStyle(3,DRAW_LINE,EMPTY,EMPTY,Color_3); SetIndexBuffer(3, STDUL); SetIndexStyle(4,DRAW_LINE,EMPTY,EMPTY,Color_3); SetIndexBuffer(4, STDDL); if(!RawdataMODE) { SetIndexStyle(0,DRAW_NONE); } if(!STDEnvelope) { SetIndexStyle(3,DRAW_NONE); SetIndexStyle(4,DRAW_NONE); } return(0); } //---- Loop int start() { double spread = Ask-Bid; int limit = Bars-IndicatorCounted(); for(int i=limit-1; i>=0; i--) { //open = Open[i]*Pair1_double ; open = iOpen(symbol, NULL, i)*Pair1_double; open2 = iOpen(symbol2, NULL, i)*Pair2_double; //close = iClose(symbol, NULL, i)*Pair1_double; //close2 = iClose(symbol2, NULL, i)*Pair2_double; Saya[i] = open-open2; } for(i=limit-1; i>=0; i--) { SayaSSM[i] = iMAOnArray(Saya, 0, SSMPriod, 0, MAMethod, i); SayaLSM[i] = iMAOnArray(Saya, 0, LSMPriod, 0, 0, i); Kairi = (Saya[0]-SayaLSM[0])/SayaLSM[0]*100; SayaSTD = iStdDevOnArray(Saya, 0, STDPriod, 0, MAMethod, 0)*STDdouble; STDUL[i] = SayaLSM[i]+SayaSTD+spread; STDDL[i] = SayaLSM[i]-SayaSTD-spread; } } return(0);