//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2012, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #property copyright "sanderz" #property link "https://login.mql5.com/ru/users/sanderz/seller" #property version "1.00" #property indicator_chart_window #property indicator_plots 0 //--- input string sect1 = ""; // SUPERTREND PARAMETERS input int PeriodST=10; // Supertrend period input double Multiplier=3; // Supertrend multiplier //--- input string sect2 = ""; // TIMEFRAME PARAMETERS input bool swTF1=false; // Use TF 1 min input bool swTF2=false; // Use TF 2 min input bool swTF3=false; // Use TF 3 min input bool swTF4=false; // Use TF 4 min input bool swTF5=false; // Use TF 5 min input bool swTF6=false; // Use TF 6 min input bool swTF10=false; // Use TF 10 min input bool swTF12=false; // Use TF 12 min input bool swTF15=true; // Use TF 15 min input bool swTF20=true; // Use TF 20 min input bool swTF30=true; // Use TF 30 min input bool swTFH1=true; // Use TF 1 h input bool swTFH2=false; // Use TF 2 h input bool swTFH3=false; // Use TF 3 h input bool swTFH4=false; // Use TF 4 h input bool swTFH6=false; // Use TF 6 h input bool swTFH8=false; // Use TF 8 h input bool swTFH12=false; // Use TF 12 h input bool swTFD=false; // Use TF D input bool swTFW=false; // Use TF W input bool swTFM=false; // Use TF M //--- input string sect3 = ""; // DESIGN PARAMETERS input int sizeFont=8; // Text size input int sizeP=1; // Price mark size int handleSTr1=INVALID_HANDLE,handleSTr2=INVALID_HANDLE,handleSTr3=INVALID_HANDLE,handleSTr4=INVALID_HANDLE, handleSTr5=INVALID_HANDLE,handleSTr6=INVALID_HANDLE,handleSTr10=INVALID_HANDLE,handleSTr12=INVALID_HANDLE, handleSTr15=INVALID_HANDLE,handleSTr20=INVALID_HANDLE,handleSTr30=INVALID_HANDLE,handleSTrH1=INVALID_HANDLE, handleSTrH2=INVALID_HANDLE,handleSTrH3=INVALID_HANDLE,handleSTrH4=INVALID_HANDLE,handleSTrH6=INVALID_HANDLE, handleSTrH8=INVALID_HANDLE,handleSTrH12=INVALID_HANDLE,handleSTrD=INVALID_HANDLE,handleSTrW=INVALID_HANDLE, handleSTrM=INVALID_HANDLE; double SuperTr1[],SuperTr2[],SuperTr3[],SuperTr4[],SuperTr5[],SuperTr6[],SuperTr10[],SuperTr12[], SuperTr15[],SuperTr20[],SuperTr30[],SuperTrH1[],SuperTrH2[],SuperTrH3[],SuperTrH4[],SuperTrH6[], SuperTrH8[],SuperTrH12[],SuperTrD[],SuperTrW[],SuperTrM[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- handleSTr1=iCustom(_Symbol,PERIOD_M1,"SuperTrend",PeriodST,Multiplier); if(handleSTr1==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr2=iCustom(_Symbol,PERIOD_M2,"SuperTrend",PeriodST,Multiplier); if(handleSTr2==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr3=iCustom(_Symbol,PERIOD_M3,"SuperTrend",PeriodST,Multiplier); if(handleSTr3==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr4=iCustom(_Symbol,PERIOD_M4,"SuperTrend",PeriodST,Multiplier); if(handleSTr4==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr5=iCustom(_Symbol,PERIOD_M5,"SuperTrend",PeriodST,Multiplier); if(handleSTr5==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr6=iCustom(_Symbol,PERIOD_M6,"SuperTrend",PeriodST,Multiplier); if(handleSTr6==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr10=iCustom(_Symbol,PERIOD_M10,"SuperTrend",PeriodST,Multiplier); if(handleSTr10==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr12=iCustom(_Symbol,PERIOD_M12,"SuperTrend",PeriodST,Multiplier); if(handleSTr12==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr15=iCustom(_Symbol,PERIOD_M15,"SuperTrend",PeriodST,Multiplier); if(handleSTr15==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr20=iCustom(_Symbol,PERIOD_M20,"SuperTrend",PeriodST,Multiplier); if(handleSTr20==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTr30=iCustom(_Symbol,PERIOD_M30,"SuperTrend",PeriodST,Multiplier); if(handleSTr30==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrH1=iCustom(_Symbol,PERIOD_H1,"SuperTrend",PeriodST,Multiplier); if(handleSTrH1==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrH2=iCustom(_Symbol,PERIOD_H2,"SuperTrend",PeriodST,Multiplier); if(handleSTrH2==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrH3=iCustom(_Symbol,PERIOD_H3,"SuperTrend",PeriodST,Multiplier); if(handleSTrH3==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrH4=iCustom(_Symbol,PERIOD_H4,"SuperTrend",PeriodST,Multiplier); if(handleSTrH4==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrH6=iCustom(_Symbol,PERIOD_H6,"SuperTrend",PeriodST,Multiplier); if(handleSTrH6==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrH8=iCustom(_Symbol,PERIOD_H8,"SuperTrend",PeriodST,Multiplier); if(handleSTrH8==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrH12=iCustom(_Symbol,PERIOD_H12,"SuperTrend",PeriodST,Multiplier); if(handleSTrH12==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrD=iCustom(_Symbol,PERIOD_D1,"SuperTrend",PeriodST,Multiplier); if(handleSTrD==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrW=iCustom(_Symbol,PERIOD_W1,"SuperTrend",PeriodST,Multiplier); if(handleSTrW==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } handleSTrM=iCustom(_Symbol,PERIOD_MN1,"SuperTrend",PeriodST,Multiplier); if(handleSTrM==INVALID_HANDLE) {//--- Report the failure and return the error number PrintFormat("Failed to create the handle of the Supertrend indicator. Error=",GetLastError()); return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- indexing elements in arrays as in timeseries ArraySetAsSeries(high,true);ArraySetAsSeries(low,true);ArraySetAsSeries(tick_volume,true); ArraySetAsSeries(time,true);ArraySetAsSeries(open,true);ArraySetAsSeries(spread,true); ArraySetAsSeries(close,true);ArraySetAsSeries(volume,true); //--- if(swTF1) { ArrayResize(SuperTr1,2);ArrayInitialize(SuperTr1,0.0); if(CopyBufferAsSeries(handleSTr1,2,0,2,true,SuperTr1)) { color clr=clrBlack; if(close[0]SuperTr1[0])clr=clrGreen; if(close[0]==SuperTr1[0]&&close[1]>SuperTr1[1])clr=clrGreen; if(close[0]==SuperTr1[0]&&close[1]SuperTr2[0])clr=clrGreen; if(close[0]==SuperTr2[0]&&close[1]>SuperTr2[1])clr=clrGreen; if(close[0]==SuperTr2[0]&&close[1]SuperTr3[0])clr=clrGreen; if(close[0]==SuperTr3[0]&&close[1]>SuperTr3[1])clr=clrGreen; if(close[0]==SuperTr3[0]&&close[1]SuperTr4[0])clr=clrGreen; if(close[0]==SuperTr4[0]&&close[1]>SuperTr4[1])clr=clrGreen; if(close[0]==SuperTr4[0]&&close[1]SuperTr5[0])clr=clrGreen; if(close[0]==SuperTr5[0]&&close[1]>SuperTr5[1])clr=clrGreen; if(close[0]==SuperTr5[0]&&close[1]SuperTr6[0])clr=clrGreen; if(close[0]==SuperTr6[0]&&close[1]>SuperTr6[1])clr=clrGreen; if(close[0]==SuperTr6[0]&&close[1]SuperTr10[0])clr=clrGreen; if(close[0]==SuperTr10[0]&&close[1]>SuperTr10[1])clr=clrGreen; if(close[0]==SuperTr10[0]&&close[1]SuperTr12[0])clr=clrGreen; if(close[0]==SuperTr12[0]&&close[1]>SuperTr12[1])clr=clrGreen; if(close[0]==SuperTr12[0]&&close[1]SuperTr15[0])clr=clrGreen; if(close[0]==SuperTr15[0]&&close[1]>SuperTr15[1])clr=clrGreen; if(close[0]==SuperTr15[0]&&close[1]SuperTr20[0])clr=clrGreen; if(close[0]==SuperTr20[0]&&close[1]>SuperTr20[1])clr=clrGreen; if(close[0]==SuperTr20[0]&&close[1]SuperTr30[0])clr=clrGreen; if(close[0]==SuperTr30[0]&&close[1]>SuperTr30[1])clr=clrGreen; if(close[0]==SuperTr30[0]&&close[1]SuperTrH1[0])clr=clrGreen; if(close[0]==SuperTrH1[0]&&close[1]>SuperTrH1[1])clr=clrGreen; if(close[0]==SuperTrH1[0]&&close[1]SuperTrH2[0])clr=clrGreen; if(close[0]==SuperTrH2[0]&&close[1]>SuperTrH2[1])clr=clrGreen; if(close[0]==SuperTrH2[0]&&close[1]SuperTrH3[0])clr=clrGreen; if(close[0]==SuperTrH3[0]&&close[1]>SuperTrH3[1])clr=clrGreen; if(close[0]==SuperTrH3[0]&&close[1]SuperTrH4[0])clr=clrGreen; if(close[0]==SuperTrH4[0]&&close[1]>SuperTrH4[1])clr=clrGreen; if(close[0]==SuperTrH4[0]&&close[1]SuperTrH6[0])clr=clrGreen; if(close[0]==SuperTrH6[0]&&close[1]>SuperTrH6[1])clr=clrGreen; if(close[0]==SuperTrH6[0]&&close[1]SuperTrH8[0])clr=clrGreen; if(close[0]==SuperTrH8[0]&&close[1]>SuperTrH8[1])clr=clrGreen; if(close[0]==SuperTrH8[0]&&close[1]SuperTrH12[0])clr=clrGreen; if(close[0]==SuperTrH12[0]&&close[1]>SuperTrH12[1])clr=clrGreen; if(close[0]==SuperTrH12[0]&&close[1]SuperTrD[0])clr=clrGreen; if(close[0]==SuperTrD[0]&&close[1]>SuperTrD[1])clr=clrGreen; if(close[0]==SuperTrD[0]&&close[1]SuperTrW[0])clr=clrGreen; if(close[0]==SuperTrW[0]&&close[1]>SuperTrW[1])clr=clrGreen; if(close[0]==SuperTrW[0]&&close[1]SuperTrM[0])clr=clrGreen; if(close[0]==SuperTrM[0]&&close[1]>SuperTrM[1])clr=clrGreen; if(close[0]==SuperTrM[0]&&close[1]