//+------------------------------------------------------------------+ //| PointsWinnerFromPT.mq5 | //| Copyright 2021, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #include "..\\utils\\Utils.mqh" #property copyright "Copyright 2021, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 4 #property indicator_plots 4 //--- plot winners #property indicator_label1 "winners" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //--- plot losser #property indicator_label2 "losser" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrPeru #property indicator_style2 STYLE_SOLID #property indicator_width2 2 //--- plot targetProfit #property indicator_label3 "Target profit(%)" #property indicator_type3 DRAW_LINE #property indicator_color3 clrGreen #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- plot stopLoss #property indicator_label4 "Stop loss(%)" #property indicator_type4 DRAW_LINE #property indicator_color4 clrRed #property indicator_style4 STYLE_SOLID #property indicator_width4 1 //inputs input int countBarsToTest = 24; //--- indicator buffers double winnersBuffer[]; double losserBuffer[]; double targetProfitBuffer[]; double stopLossBuffer[]; Utils utils; int indicatorProbableProfitHandle=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //chart settings ChartSetInteger(0,CHART_COLOR_BACKGROUND,0); ChartSetInteger(0, CHART_FOREGROUND,16777215); ChartSetInteger(0,CHART_COLOR_CHART_UP,7451452); ChartSetInteger(0,CHART_COLOR_CHART_DOWN,255); ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,7451452); ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,255); ChartSetInteger(0,CHART_COLOR_CHART_LINE,65280); ChartSetInteger(0,CHART_COLOR_GRID,2697513); ChartSetInteger(0,CHART_SHIFT,1); ChartSetInteger(0,CHART_SHOW_ASK_LINE,1); ChartSetInteger(0,CHART_SHOW_BID_LINE,1); ChartSetInteger(0,CHART_SHOW_LAST_LINE,1); ChartSetInteger(0,CHART_SHOW_PERIOD_SEP,1); ArraySetAsSeries(winnersBuffer,true); ArraySetAsSeries(losserBuffer,true); ArraySetAsSeries(targetProfitBuffer,true); ArraySetAsSeries(stopLossBuffer,true); //--- indicator buffers mapping SetIndexBuffer(0,winnersBuffer,INDICATOR_DATA); SetIndexBuffer(1,losserBuffer,INDICATOR_DATA); SetIndexBuffer(2,targetProfitBuffer,INDICATOR_DATA); SetIndexBuffer(3,stopLossBuffer,INDICATOR_DATA); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW PlotIndexSetInteger(0,PLOT_ARROW,159); PlotIndexSetInteger(1,PLOT_ARROW,159); string path = utils.GetRelativeProgramPath(); indicatorProbableProfitHandle=iCustom(Symbol(),PERIOD_CURRENT,path + "\\ProbableTarget",0.10,countBarsToTest,countBarsToTest); if(indicatorProbableProfitHandle==INVALID_HANDLE) { Print("Probable profit error inicialization, Code = ",GetLastError()); return -1; } //--- 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[]) { //--- //--- convert to series ArraySetAsSeries(open,true); ArraySetAsSeries(close,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); if(rates_total