//+------------------------------------------------------------------+ //| Sun-V0.mq5 | //| Thorsten Fischer Copyright 2019-2020 | //| https://mql5.tfsystem.de | //+------------------------------------------------------------------+ #property copyright "Thorsten Fischer Copyright 2019-2020" #property link "https://mql5.tfsystem.de" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 10 #property indicator_plots 6 //--- input color i_ColorLong=clrBlue; // Farbe Long input color i_ColorShort=clrRed; // Farbe Short input int i_DrawBegin=5; // Anfang aussetzen input string i_Name0="Kreis"; // Namen der Sonnenwerte0 input ushort i_ArrowCode0=159; // ArrowCode0 input int i_ArrowWidth0=5; // Arrow Width0 input int i_ArrowShift0=6; // ArrowShift0 input string i_Name1="Sonne"; // Namen der Sonnenwerte1 input ushort i_ArrowCode1=82; // ArrowCode1 input int i_ArrowWidth1=5; // Arrow Width1 input int i_ArrowShift1=6; // ArrowShift1 //--- int i_Handle_MA_H; int i_Handle_MA_L; //--- double i_KreisHigh=0; double i_KreisHighLast=0; double i_KreisLow=0; double i_KreisLowLast=0; double i_SunHigh=0; double i_SunHighLast=0; double i_SunLow=0; //--- double i_Buffer_Kreis_Oben[]; double i_Buffer_Kreis_Oben_Color[]; double i_Buffer_Kreis_Unten[]; double i_Buffer_Kreis_Unten_Color[]; double i_Buffer_Sun_Oben[]; double i_Buffer_Sun_Oben_Color[]; double i_Buffer_Sun_Unten[]; double i_Buffer_Sun_Unten_Color[]; double i_Buffer_MA_H[]; double i_Buffer_MA_L[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- i_Handle_MA_H=iMA(Symbol(),PERIOD_CURRENT,5,0,MODE_SMMA,PRICE_HIGH); i_Handle_MA_L=iMA(Symbol(),PERIOD_CURRENT,5,0,MODE_SMMA,PRICE_LOW); if(i_Handle_MA_H==INVALID_HANDLE || i_Handle_MA_L==INVALID_HANDLE) { Print("Indicator handle error"); return(INIT_FAILED); } //--- indicator buffers mapping SetIndexBuffer(0,i_Buffer_Kreis_Oben,INDICATOR_DATA); SetIndexBuffer(1,i_Buffer_Kreis_Oben_Color,INDICATOR_COLOR_INDEX); SetIndexBuffer(2,i_Buffer_Kreis_Unten,INDICATOR_DATA); SetIndexBuffer(3,i_Buffer_Kreis_Unten_Color,INDICATOR_COLOR_INDEX); SetIndexBuffer(4,i_Buffer_Sun_Oben,INDICATOR_DATA); SetIndexBuffer(5,i_Buffer_Sun_Oben_Color,INDICATOR_COLOR_INDEX); SetIndexBuffer(6,i_Buffer_Sun_Unten,INDICATOR_DATA); SetIndexBuffer(7,i_Buffer_Sun_Unten_Color,INDICATOR_COLOR_INDEX); SetIndexBuffer(8,i_Buffer_MA_H,INDICATOR_DATA); SetIndexBuffer(9,i_Buffer_MA_L,INDICATOR_DATA); //--- PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_COLOR_ARROW); PlotIndexSetInteger(0,PLOT_ARROW,i_ArrowCode0); PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,i_ArrowShift0*-1); //PlotIndexSetInteger(0,PLOT_SHIFT,0); PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,i_DrawBegin); PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,2); PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,i_ColorLong); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,i_ColorShort); PlotIndexSetInteger(0,PLOT_LINE_WIDTH,i_ArrowWidth0); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(0,PLOT_LABEL,i_Name0+" Oben"); //--- PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_COLOR_ARROW); PlotIndexSetInteger(1,PLOT_ARROW,i_ArrowCode0); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,i_ArrowShift0); //PlotIndexSetInteger(1,PLOT_SHIFT,0); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,i_DrawBegin); PlotIndexSetInteger(1,PLOT_COLOR_INDEXES,3); PlotIndexSetInteger(1,PLOT_LINE_COLOR,0,i_ColorLong); PlotIndexSetInteger(1,PLOT_LINE_COLOR,1,i_ColorShort); PlotIndexSetInteger(1,PLOT_LINE_WIDTH,i_ArrowWidth0); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(1,PLOT_LABEL,i_Name0+" Unten"); //--- PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_COLOR_ARROW); PlotIndexSetInteger(2,PLOT_ARROW,i_ArrowCode1); PlotIndexSetInteger(2,PLOT_ARROW_SHIFT,i_ArrowShift1*-1); //PlotIndexSetInteger(2,PLOT_SHIFT,0); PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,i_DrawBegin); PlotIndexSetInteger(2,PLOT_COLOR_INDEXES,3); PlotIndexSetInteger(2,PLOT_LINE_COLOR,0,i_ColorLong); PlotIndexSetInteger(2,PLOT_LINE_COLOR,1,i_ColorShort); PlotIndexSetInteger(2,PLOT_LINE_WIDTH,i_ArrowWidth1); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(2,PLOT_LABEL,i_Name1+" Oben"); //--- PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_COLOR_ARROW); PlotIndexSetInteger(3,PLOT_ARROW,i_ArrowCode1); PlotIndexSetInteger(3,PLOT_ARROW_SHIFT,i_ArrowShift1); //PlotIndexSetInteger(3,PLOT_SHIFT,0); PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,i_DrawBegin); PlotIndexSetInteger(3,PLOT_COLOR_INDEXES,3); PlotIndexSetInteger(3,PLOT_LINE_COLOR,0,i_ColorLong); PlotIndexSetInteger(3,PLOT_LINE_COLOR,1,i_ColorShort); PlotIndexSetInteger(3,PLOT_LINE_WIDTH,i_ArrowWidth1); PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(3,PLOT_LABEL,i_Name1+" Unten"); //--- PlotIndexSetString(4,PLOT_LABEL,"MA High"); PlotIndexSetString(5,PLOT_LABEL,"MA Low"); //--- IndicatorSetString(INDICATOR_SHORTNAME,"TF Sun"); IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| 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[]) { //--- int i=prev_calculated; //--- CopyBuffer(i_Handle_MA_H,0,0,BarsCalculated(i_Handle_MA_H),i_Buffer_MA_H); CopyBuffer(i_Handle_MA_L,0,0,BarsCalculated(i_Handle_MA_L),i_Buffer_MA_L); //--- for(i; i