// file vecchio della strategia DIMENTICATELO //+------------------------------------------------------------------ #property copyright "© KKxFF, 2020" //#property link "mladenfx@gmail.com" #property description "Strategy" //+------------------------------------------------------------------ #property indicator_chart_window #property indicator_buffers 15 #property indicator_plots 7 //SMA #property indicator_label1 "SMA" #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 clrDeepSkyBlue,clrDeepSkyBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //EMA #property indicator_label2 "EMA" #property indicator_type2 DRAW_COLOR_LINE #property indicator_color2 clrOrange,clrOrange #property indicator_style2 STYLE_SOLID #property indicator_width2 2 //Ichimoku #property indicator_label3 "Tenkan-sen" #property indicator_type3 DRAW_LINE #property indicator_color3 clrNONE #property indicator_label4 "Kijun-sen" #property indicator_type4 DRAW_LINE #property indicator_color4 Blue #property indicator_label5 "Senkou Span A;Senkou Span B" #property indicator_type5 DRAW_FILLING #property indicator_color5 SandyBrown,Thistle #property indicator_label6 "Chikou Span" #property indicator_type6 DRAW_LINE #property indicator_color6 clrNONE //incroci medie #property indicator_label7 "ColorArrow" #property indicator_type7 DRAW_COLOR_ARROW #property indicator_color7 clrRed #property indicator_style7 STYLE_SOLID #property indicator_width7 10 //SMA & EMA input int inpPeriod = 6; // Period input ENUM_APPLIED_PRICE inpPrice = PRICE_CLOSE; // Price input int inpPeriodEma = 12; // Period double val[],valc[]; double valEma[],valcEma[]; double ExtMA_MinimumDistance=0.0; //Ichimoku input int InpTenkan=8; // Tenkan-sen input int InpKijun=42; // Kijun-sen input int InpSenkou=120; // Senkou Span B input int InpCloudOffset=42;// Cloud offset double ExtTenkanBuffer[]; double ExtKijunBuffer[]; double ExtSpanABuffer[]; double ExtSpanBBuffer[]; double ExtChikouBuffer[]; //incroci medie input ushort code=159; // Symbol code to draw in DRAW_ARROW int color_sections; double ColorArrowBuffer[]; int OnInit() { IndicatorSetString(INDICATOR_SHORTNAME,"strategy2"); //SMA & Ema SetIndexBuffer(0,val,INDICATOR_DATA); SetIndexBuffer(1,valc,INDICATOR_COLOR_INDEX); _sma.init(inpPeriod); SetIndexBuffer(2,valEma,INDICATOR_DATA); SetIndexBuffer(3,valcEma,INDICATOR_COLOR_INDEX); _ema.init(inpPeriodEma); //incroci medie //--- indicator buffers mapping SetIndexBuffer(9,ColorArrowBuffer,INDICATOR_DATA); //--- Define the symbol code for drawing in PLOT_ARROW PlotIndexSetInteger(9,PLOT_ARROW,code); //--- Set the vertical shift of arrows in pixels PlotIndexSetInteger(9,PLOT_ARROW_SHIFT,5); //--- Set as an empty value 0 PlotIndexSetDouble(9,PLOT_EMPTY_VALUE,0); //Ichimoku //--- indicator buffers mapping SetIndexBuffer(4,ExtTenkanBuffer,INDICATOR_DATA); SetIndexBuffer(5,ExtKijunBuffer,INDICATOR_DATA); SetIndexBuffer(6,ExtSpanABuffer,INDICATOR_DATA); SetIndexBuffer(7,ExtSpanBBuffer,INDICATOR_DATA); SetIndexBuffer(8,ExtChikouBuffer,INDICATOR_DATA); //--- sets first bar from what index will be drawn PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpTenkan); PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,InpKijun); PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,InpSenkou-1); //--- lines shifts when drawing PlotIndexSetInteger(4,PLOT_SHIFT,InpCloudOffset); PlotIndexSetInteger(5,PLOT_SHIFT,-InpKijun); //--h- change labels for DataWindow PlotIndexSetString(2,PLOT_LABEL,"Tenkan-sen("+string(InpTenkan)+")"); PlotIndexSetString(3,PLOT_LABEL,"Kijun-sen("+string(InpKijun)+")"); PlotIndexSetString(4,PLOT_LABEL,"Senkou Span A;Senkou Span B("+string(InpSenkou)+")"); //--- initialization done return (INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| get highest value for range | //+------------------------------------------------------------------+ double Highest(const double&array[],int range,int fromIndex) { double res=0; //--- res=array[fromIndex]; for(int i=fromIndex;i>fromIndex-range && i>=0;i--) { if(resfromIndex-range && i>=0;i--) { if(res>array[i]) res=array[i]; } //--- return(res); } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // 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[]) { //medie e Ichimoku int i=prev_calculated-1; if (i<0) i=0; for (; i0) ? (val[i]>val[i-1]) ? 0 : (val[i]0) ? (valEma[i]>valEma[i-1]) ? 0 : (valEma[i]=1 && val[i-1]>valEma[i-1] && val[i]=1 && valEma[i-1]>val[i-1] && valEma[i]1) ? period : 1; } double calculate(double value, int i, int bars) { if (m_arraySizem_period) m_array[i].sum = m_array[i-1].sum + value - m_array[i-m_period].value; else { m_array[i].sum = 0; for(int k=0; k=k; k++) m_array[i].sum += m_array[i-k].value; } return(m_array[i].sum / (double)m_period); } }; CSma _sma; class CEma { private : double m_period; double m_alpha; double m_array[]; int m_arraySize; public : CEma() : m_period(1), m_alpha(1), m_arraySize(-1) { return; } ~CEma() { return; } // //--- // void init(int period) { m_period = (period>1) ? period : 1; m_alpha = 2.0/(1.0+m_period); } double calculate(double value, int i, int bars) { if (m_arraySize0) m_array[i] = m_array[i-1]+m_alpha*(value-m_array[i-1]); else m_array[i] = value; return (m_array[i]); } }; CEma _ema; // //--- // template double getPrice(ENUM_APPLIED_PRICE tprice, T& open[], T& high[], T& low[], T& close[], int i) { switch(tprice) { case PRICE_CLOSE: return(close[i]); case PRICE_OPEN: return(open[i]); case PRICE_HIGH: return(high[i]); case PRICE_LOW: return(low[i]); case PRICE_MEDIAN: return((high[i]+low[i])/2.0); case PRICE_TYPICAL: return((high[i]+low[i]+close[i])/3.0); case PRICE_WEIGHTED: return((high[i]+low[i]+close[i]+close[i])/4.0); } return(0); } //------------------------------------------------------------------