//+------------------------------------------------------------------+ //| Complex_pairs.mq4 | //| SemSemFX@rambler.ru | //| http://onix-trade.net/forum/index.php?showtopic=107 | //| http://forum.alpari-idc.ru/viewtopic.php?t=46916 | //+------------------------------------------------------------------+ #property copyright "SemSemFX@rambler.ru" #property link "http://onix-trade.net/forum/index.php?showtopic=107" #property link "http://forum.alpari-idc.ru/viewtopic.php?t=46916" //---- #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Black #property indicator_color2 Green #property indicator_color3 Red //---- buffers double ExtBuffer0[]; double ExtBuffer1[]; double ExtBuffer2[]; //---- parameters // for monthly int mn_per=12; int mn_fast=3; // for weekly int w_per=9; int w_fast=3; // for daily int d_per=5; int d_fast=3; // for H4 int h4_per=60; int h4_fast=12; // for H1 int h1_per=50; int h1_fast=12; // for M30 int m30_per=50; int m30_fast=12; // for M15 int m15_per=45; int m15_fast=12; // for M5 int m5_per=18; int m5_fast=10; // for M1 int m1_per=30; int m1_fast=10; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexStyle(2,DRAW_HISTOGRAM); IndicatorDigits(Digits+1); SetIndexDrawBegin(0,34); SetIndexDrawBegin(1,34); SetIndexDrawBegin(2,34); SetIndexBuffer(0,ExtBuffer0); SetIndexBuffer(1,ExtBuffer1); SetIndexBuffer(2,ExtBuffer2); IndicatorShortName(Symbol() + "(" + Period() + "): "); SetIndexLabel(0, Symbol()); SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); double OPEN,HIGH,LOW,CLOSE; //---- проверка на возможные ошибки if(counted_bars<0) return(-1); //---- последний посчитанный бар будет пересчитан if(counted_bars>0) counted_bars-=10; //---- limit=Bars-counted_bars; //---- основной цикл int Price=6; int Mode=3; int per1,per2; double prev,current; switch(Period()) { case 1: per1=m1_per; per2=m1_fast; break; case 5: per1=m5_per; per2=m5_fast; break; case 15: per1=m15_per;per2=m15_fast; break; case 30: per1=m30_per;per2=m30_fast; break; case 60: per1=h1_per; per2=h1_fast; break; case 240: per1=h4_per; per2=h4_fast; break; case 1440: per1=d_per; per2=d_fast; break; case 10080: per1=w_per; per2=w_fast; break; case 43200: per1=mn_per; per2=mn_fast; break; } for(int i=0; i0) { ExtBuffer1[i]=ExtBuffer0[i]; ExtBuffer2[i]=0.0; } else if (ExtBuffer0[i]==0) { ExtBuffer1[i]=0.0; ExtBuffer2[i]=0.0; } else { ExtBuffer1[i]=0.0; ExtBuffer2[i]=ExtBuffer0[i]; } } //---- return(0); } //+------------------------------------------------------------------+ double USD(int Mode, int Price, int i, int per1, int per2) { return( (iMA("EURUSD",0,per1,0,Mode,Price,i)- iMA("EURUSD",0,per2,0,Mode,Price,i))*10000 + (iMA("GBPUSD",0,per1,0,Mode,Price,i)- iMA("GBPUSD",0,per2,0,Mode,Price,i))*10000 + (iMA("USDCHF",0,per2,0,Mode,Price,i)- iMA("USDCHF",0,per1,0,Mode,Price,i))*10000 + (iMA("USDJPY",0,per2,0,Mode,Price,i)- iMA("USDJPY",0,per1,0,Mode,Price,i))*100 ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double EUR(int Mode, int Price, int i, int per1, int per2) { return( (iMA("EURUSD",0,per2,0,Mode,Price,i)- iMA("EURUSD",0,per1,0,Mode,Price,i))*10000 + (iMA("EURGBP",0,per2,0,Mode,Price,i)- iMA("EURGBP",0,per1,0,Mode,Price,i))*10000 + (iMA("EURCHF",0,per2,0,Mode,Price,i)- iMA("EURCHF",0,per1,0,Mode,Price,i))*10000 + (iMA("EURJPY",0,per2,0,Mode,Price,i)- iMA("EURJPY",0,per1,0,Mode,Price,i))*100 ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double GBP(int Mode, int Price, int i, int per1, int per2) { return( (iMA("GBPUSD",0,per2,0,Mode,Price,i)- iMA("GBPUSD",0,per1,0,Mode,Price,i))*10000 + (iMA("EURGBP",0,per1,0,Mode,Price,i)- iMA("EURGBP",0,per2,0,Mode,Price,i))*10000 + (iMA("GBPCHF",0,per2,0,Mode,Price,i)- iMA("GBPCHF",0,per1,0,Mode,Price,i))*10000 + (iMA("GBPJPY",0,per2,0,Mode,Price,i)- iMA("GBPJPY",0,per1,0,Mode,Price,i))*100 ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double CHF(int Mode, int Price, int i, int per1, int per2) { return( (iMA("USDCHF",0,per1,0,Mode,Price,i)- iMA("USDCHF",0,per2,0,Mode,Price,i))*10000 + (iMA("EURCHF",0,per1,0,Mode,Price,i)- iMA("EURCHF",0,per2,0,Mode,Price,i))*10000 + (iMA("GBPCHF",0,per1,0,Mode,Price,i)- iMA("GBPCHF",0,per2,0,Mode,Price,i))*10000 + (iMA("CHFJPY",0,per2,0,Mode,Price,i)- iMA("CHFJPY",0,per1,0,Mode,Price,i))*100 ); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double JPY(int Mode, int Price, int i, int per1, int per2) { return( (iMA("USDJPY",0,per1,0,Mode,Price,i)- iMA("USDJPY",0,per2,0,Mode,Price,i))*100 + (iMA("EURJPY",0,per1,0,Mode,Price,i)- iMA("EURJPY",0,per2,0,Mode,Price,i))*100 + (iMA("GBPJPY",0,per1,0,Mode,Price,i)- iMA("GBPJPY",0,per2,0,Mode,Price,i))*100 + (iMA("CHFJPY",0,per1,0,Mode,Price,i)- iMA("CHFJPY",0,per2,0,Mode,Price,i))*100 ); } //+------------------------------------------------------------------+