//+------------------------------------------------------------------+ //| 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 6 #property indicator_plots 6 #include "..\..\TF-Dateien\TF-Class\TFIndicator.mqh" //--- Eingabe Variablen input color i_ColorLong=clrBlue; // Farbe Long input color i_ColorShort=clrRed; // Farbe Short input int i_DrawBegin=0; // Zeichnen Anfang input string i_ArrowName0="Kreis"; // Namen der Periode 0 input int i_PeriodenZahl0=12; // Perioden Zahl 0 input ushort i_ArrowCode0=159; // Zeichen Arrow Code 0 input int i_ArrowWidth0=5; // Zeichen Arrow Width 0 input int i_ArrowShift0=6; // Zeichen Arrow Shift 0 input string i_ArrowName1="Sonne"; // Namen der Periode 1 input int i_PeriodenZahl1=34; // Perioden Zahl 1 input ushort i_ArrowCode1=82; // Zeichen Arrow Code 1 input int i_ArrowWidth1=5; // Zeichen Arrow Width 1 input int i_ArrowShift1=6; // Zeichen Arrow Shift 1 //--- Periode 0 int i_Arrow0_Periode=i_PeriodenZahl0; //--- Periode 1 int i_Arrow1_Periode=i_PeriodenZahl1; //--- Buffer double i_Arrow0_Buffer_High[]; double i_Arrow0_Buffer_Low[]; double i_Arrow0_Buffer_Flag[]; double i_Arrow1_Buffer_High[]; double i_Arrow1_Buffer_Low[]; double i_Arrow1_Buffer_Flag[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,i_Arrow0_Buffer_High,INDICATOR_DATA); SetIndexBuffer(1,i_Arrow0_Buffer_Low,INDICATOR_DATA); SetIndexBuffer(2,i_Arrow0_Buffer_Flag,INDICATOR_DATA); SetIndexBuffer(3,i_Arrow1_Buffer_High,INDICATOR_DATA); SetIndexBuffer(4,i_Arrow1_Buffer_Low,INDICATOR_DATA); SetIndexBuffer(5,i_Arrow1_Buffer_Flag,INDICATOR_DATA); ArraySetAsSeries(i_Arrow0_Buffer_High,true); ArraySetAsSeries(i_Arrow0_Buffer_Low,true); ArraySetAsSeries(i_Arrow0_Buffer_Flag,true); ArraySetAsSeries(i_Arrow1_Buffer_High,true); ArraySetAsSeries(i_Arrow1_Buffer_Low,true); ArraySetAsSeries(i_Arrow1_Buffer_Flag,true); //--- PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_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,i_ColorShort); PlotIndexSetInteger(0,PLOT_LINE_WIDTH,i_ArrowWidth0); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(0,PLOT_LABEL,i_ArrowName0+" High"); //--- PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_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,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_ArrowName0+" Low"); //--- PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(2,PLOT_LABEL,"Flag Periode 1"); //--- PlotIndexSetInteger(3,PLOT_DRAW_TYPE,DRAW_ARROW); PlotIndexSetInteger(3,PLOT_ARROW,i_ArrowCode1); PlotIndexSetInteger(3,PLOT_ARROW_SHIFT,i_ArrowShift1*-1); //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,i_ColorShort); PlotIndexSetInteger(3,PLOT_LINE_WIDTH,i_ArrowWidth1); PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(3,PLOT_LABEL,i_ArrowName1+" High"); //--- PlotIndexSetInteger(4,PLOT_DRAW_TYPE,DRAW_ARROW); PlotIndexSetInteger(4,PLOT_ARROW,i_ArrowCode1); PlotIndexSetInteger(4,PLOT_ARROW_SHIFT,i_ArrowShift1); //PlotIndexSetInteger(4,PLOT_SHIFT,0); PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,i_DrawBegin); //PlotIndexSetInteger(4,PLOT_COLOR_INDEXES,3); PlotIndexSetInteger(4,PLOT_LINE_COLOR,i_ColorLong); //PlotIndexSetInteger(4,PLOT_LINE_COLOR,1,i_ColorShort); PlotIndexSetInteger(4,PLOT_LINE_WIDTH,i_ArrowWidth1); PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(4,PLOT_LABEL,i_ArrowName1+" Low"); //--- PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0.0); PlotIndexSetString(5,PLOT_LABEL,"Flag Periode 1"); //--- 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[]) { //--- Variablen int suche=rates_total-prev_calculated; ArraySetAsSeries(open,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); ArraySetAsSeries(close,true); //--- Testeinstellungen i_Arrow0_Periode=2; i_Arrow1_Periode=0; //--- if(rates_total-prev_calculated==1) { suche=1; } //--- if(prev_calculated==0) { suche--; //Print("Anfang = "+(string)suche); //Print(__FUNCTION__+" / rates_total = "+(string)rates_total+" / prev_calculated = "+(string)prev_calculated+" / high = "+(string)high[suche]+" / low = "+(string)low[suche]+" / close = "+(string)close[suche]); } //--- for(suche; suche>=0 && !IsStopped(); suche--) { Periode_Berechnen(high,low,close,i_Arrow0_Buffer_High,i_Arrow0_Buffer_Low,i_Arrow0_Buffer_Flag,i_Arrow0_Periode,suche); Periode_Berechnen(high,low,close,i_Arrow1_Buffer_High,i_Arrow1_Buffer_Low,i_Arrow1_Buffer_Flag,i_Arrow1_Periode,suche); } ChartRedraw(); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+