#property copyright "Avenger © 2023. All Rights Reserved." #property description "DISCLAIMER" #property description "Your investments are solely your responsibility and not ours. While day trading can bring serious" #property description "gains, it can also bring serious losses! So, by using this “Trading Robot” or “Expert Advisor”, you" #property description "accept taking the risk of losing your deposit 100% without any responsibility on the Author of this" #property description "“Trading Robot” or “Expert Advisor”" #property strict #property indicator_chart_window #property indicator_buffers 16 #property indicator_plots 14 #resource "\\Indicators\\Avenger_Band_Indicator - Copy.ex5" #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE #property indicator_type4 DRAW_ARROW #property indicator_type5 DRAW_ARROW #property indicator_type6 DRAW_LINE #property indicator_type7 DRAW_LINE #property indicator_type8 DRAW_ARROW #property indicator_type9 DRAW_ARROW #property indicator_type10 DRAW_ARROW #property indicator_type11 DRAW_ARROW #property indicator_type12 DRAW_ARROW #property indicator_type13 DRAW_ARROW #property indicator_type14 DRAW_ARROW #define OP_BUY 0 //Buy #define OP_SELL 1 //Sell input string ss = "==========================="; //Settings input string P = "Don't Enter Negative Amount"; //Best Choice from 0.5 to 3 input double Period_Multiplier = 1; //Period Multiplier input string T = "Don't Enter Negative Amount"; //Best Choice from 0.5 to 2 input double TP_Multiplier = 1; //TP Multiplier input bool Enable_Alert = false; //Enable Desktop Alerts input bool Enable_Notification = false; //Enable Mobile Notifications input string gg = "==========================="; //Indicator Appearance input bool Show_Trade_Direction_Arrows = true; //Show Trade Direction Arrows input string gs = "For Gold/Silver, Multiply by 10"; //Distance from Direction Arrow to Price input int Trade_Direction_Arrow_Distance = 5; //Trade Direction Arrow Distance input bool Show_Entry_and_TP = false; //Show Entry and TP input string SH = ""; //This Works if Previous Option is True input bool Show_Win_Loss_Points = false; //Show Win/Loss Points input string S1 = "0 = Left, 1 = Right"; //Show Statistics Dashboard on Which Corner? input int Statistics_Corner_OK = 1; //Statistics Dashboard Corner int Statistics_Corner = 1; input string mt = "==========================="; //Multi-Timeframe Info input bool Show_MultiTF_Info = true;//Show Multi-Timeframe Info input ENUM_TIMEFRAMES TF_1 = PERIOD_M15;//Timeframe 1 input ENUM_TIMEFRAMES TF_2 = PERIOD_H1;//Timeframe 2 input ENUM_TIMEFRAMES TF_3 = PERIOD_H4;//Timeframe 3 input ENUM_TIMEFRAMES TF_4 = PERIOD_D1;//Timeframe 4 input color MultiTF_Buy_Color = Blue;//Buy Color input color MultiTF_Sell_Color = Red;//Sell Color input string MACDF = "==========================="; //MACD Filter input bool Use_MACD_Filter = false;//Use MACD Filter input int MACD_Fast = 12;//Fast EMA input int MACD_Slow = 26;//Slow EMA input int MACD_SMA = 9;//MACD SMA input ENUM_APPLIED_PRICE MACD_Apply = PRICE_CLOSE;//Apply to input string MAF = "==========================="; //MA Filter input bool Use_MA_Filter = false;//Use MA Filter input int Fast_MA_Period = 10;//Fast MA Period input int Slow_MA_Period = 20;//Slow MA Period input ENUM_MA_METHOD MA_Method = MODE_SMA;//Method input ENUM_APPLIED_PRICE MA_Apply = PRICE_CLOSE;//Apply to input string C = "==========================="; //Indicator Colors input int UpTrend_Line_Background_Size = 5; //Uptrend Line Background Size input color UpTrend_Line_Background = clrBlue; //Uptrend Line Background Color input int UpTrend_Line_Foreground_Size = 10; //Uptrend Line Foreground Size input color UpTrend_Line_Foreground = clrBlue; //Uptrend Line Foreground Color input int DownTrend_Line_Background_Size = 5; //Downtrend Line Background Size input color DownTrend_Line_Background = clrRed; //Downtrend Line Background Color input int DownTrend_Line_Foreground_Size = 10; //Downtrend Line Foreground Size input color DownTrend_Line_Foreground = clrRed; //Downtrend Line Foreground Color input int Buy_Arrow_Size = 5; //Buy Arrow Size input color Buy_Arrow = Blue; //Buy Arrow Color input int Buy_Entry_Size = 0; //Buy Entry Arrow Size input color Buy_Entry = clrDeepSkyBlue; //Buy Entry Arrow Color input int Buy_TP_Size = 0; //Buy TP Indicator Size input color Buy_TP = clrYellow; //Buy TP Indicator Color input int Sell_Arrow_Size = 5; //Sell Arrow Size input color Sell_Arrow = clrRed; //Sell Arrow Color input int Sell_Entry_Size = 0; //Sell Entry Arrow Size input color Sell_Entry = clrRed; //Sell Entry Arrow Color input int Sell_TP_Size = 0; //Sell TP Indicator Size input color Sell_TP = clrYellow; //Sell TP Indicator Color input int Trend_Change_Bullet_Size = 1; //Trend Change Bullet Size input color Trend_Change_Bullet = clrYellow; //Trend Change Bullet Color input int TP_Reached_Size = 0; //TP Hit Indicator Size input color TP_Reached = clrYellow; //TP Hit Indicator Color input int Profit_Points_Size = 8; //Profit Points Text Size input color Profit_Points = clrYellow; //Profit Points Text Color input int SL_Reached_Size = 1; //SL Hit Indicator Size input color SL_Reached = clrOrchid; //SL Hit Indicator Color input int Loss_Points_Size = 8; //Loss Points Text Size input color Loss_Points = clrOrchid; //Loss Points Text Color input color Statistics = clrWhite; //Statistics Text Color input color Statistics_Buy = clrBlue; //Statistics Dashboard Buy Color input color Statistics_Sell = clrRed; //Statistics Dashboard Sell Color input string D = "==========================="; //Max Bars To Show input int Bar_Count = 1000;//Max Bars int CCI_Period = 40; int Indicator_Period = 3; int TP_Period = 3; double TrendUp[]; double TrendDown[]; double TrendUp_Temp[]; double TrendDown_Temp[]; double TrendUpSmall[]; double TrendDownSmall[]; double TrendChange[]; double ArrowSell[]; double ArrowBuy[]; double Entry_Buy[]; double Entry_Sell[]; double Temp[]; double TP_Sell[]; double TP_Buy[]; double TP_Hit[]; double SL_Hit[]; int Position_Buy = -1; int Position_Sell = -1; int Last_Buy = -1; int Last_Sell = -1; int Pipvalue = 1; datetime BarTime = 0; int Loss_Number = 0; int Hit_Number = 0; string Prefix = "TH_"; int CCI_Handle, ATR_Indicator_Handle, ATR_TP_Handle; double CCI[], ATR_Indicator[], ATR_TP[]; int Last_Bars_TF1, Last_Bars_TF2, Last_Bars_TF3, Last_Bars_TF4; string Indicator_Name; int TF_1_Handle, TF_2_Handle, TF_3_Handle, TF_4_Handle, MACD_Handle, Fast_MA_Handle, Slow_MA_Handle; int EntryDirection_TF1, EntryDirection_TF2, EntryDirection_TF3, EntryDirection_TF4; bool Initialized = false; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { Prefix += TF_To_String(Period()) + "_";//to avoid late object deleting when changing TF SetIndexBuffer(0, Temp, INDICATOR_CALCULATIONS); PlotIndexSetInteger(1, PLOT_LINE_STYLE, STYLE_SOLID); PlotIndexSetInteger(1, PLOT_LINE_WIDTH, UpTrend_Line_Background_Size); PlotIndexSetInteger(1, PLOT_LINE_COLOR, UpTrend_Line_Background); SetIndexBuffer(1, TrendUp); PlotIndexSetInteger(2, PLOT_LINE_STYLE, STYLE_SOLID); PlotIndexSetInteger(2, PLOT_LINE_WIDTH, DownTrend_Line_Background_Size); PlotIndexSetInteger(2, PLOT_LINE_COLOR, DownTrend_Line_Background); SetIndexBuffer(2, TrendDown); PlotIndexSetInteger(3, PLOT_LINE_WIDTH, Buy_Arrow_Size); PlotIndexSetInteger(3, PLOT_LINE_COLOR, Buy_Arrow); PlotIndexSetInteger(3, PLOT_ARROW, 246); SetIndexBuffer(3, ArrowBuy); PlotIndexSetInteger(4, PLOT_LINE_WIDTH, Sell_Arrow_Size); PlotIndexSetInteger(4, PLOT_LINE_COLOR, Sell_Arrow); PlotIndexSetInteger(4, PLOT_ARROW, 248); SetIndexBuffer(4, ArrowSell); PlotIndexSetInteger(5, PLOT_LINE_STYLE, STYLE_SOLID); PlotIndexSetInteger(5, PLOT_LINE_WIDTH, UpTrend_Line_Foreground_Size); PlotIndexSetInteger(5, PLOT_LINE_COLOR, UpTrend_Line_Foreground); SetIndexBuffer(5, TrendUpSmall); PlotIndexSetInteger(6, PLOT_LINE_STYLE, STYLE_SOLID); PlotIndexSetInteger(6, PLOT_LINE_WIDTH, DownTrend_Line_Foreground_Size); PlotIndexSetInteger(6, PLOT_LINE_COLOR, DownTrend_Line_Foreground); SetIndexBuffer(6, TrendDownSmall); PlotIndexSetInteger(7, PLOT_LINE_WIDTH, Trend_Change_Bullet_Size); PlotIndexSetInteger(7, PLOT_LINE_COLOR, Trend_Change_Bullet); PlotIndexSetInteger(7, PLOT_ARROW, 108); SetIndexBuffer(7, TrendChange); PlotIndexSetInteger(8, PLOT_LINE_WIDTH, Buy_Entry_Size); PlotIndexSetInteger(8, PLOT_LINE_COLOR, Buy_Entry); PlotIndexSetInteger(8, PLOT_ARROW, 232); SetIndexBuffer(8, Entry_Buy); PlotIndexSetInteger(9, PLOT_LINE_WIDTH, Sell_Entry_Size); PlotIndexSetInteger(9, PLOT_LINE_COLOR, Sell_Entry); PlotIndexSetInteger(9, PLOT_ARROW, 232); SetIndexBuffer(9, Entry_Sell); PlotIndexSetInteger(10, PLOT_LINE_WIDTH, Sell_TP_Size); PlotIndexSetInteger(10, PLOT_LINE_COLOR, Sell_TP); PlotIndexSetInteger(10, PLOT_ARROW, 253); SetIndexBuffer(10, TP_Sell); PlotIndexSetInteger(11, PLOT_LINE_WIDTH, Buy_TP_Size); PlotIndexSetInteger(11, PLOT_LINE_COLOR, Buy_TP); PlotIndexSetInteger(11, PLOT_ARROW, 253); SetIndexBuffer(11, TP_Buy); PlotIndexSetInteger(12, PLOT_LINE_WIDTH, TP_Reached_Size); PlotIndexSetInteger(12, PLOT_LINE_COLOR, TP_Reached); PlotIndexSetInteger(12, PLOT_ARROW, 254); SetIndexBuffer(12, TP_Hit); PlotIndexSetInteger(13, PLOT_LINE_WIDTH, SL_Reached_Size); PlotIndexSetInteger(13, PLOT_LINE_COLOR, SL_Reached); PlotIndexSetInteger(13, PLOT_ARROW, 251); SetIndexBuffer(13, SL_Hit); SetIndexBuffer(14, TrendUp_Temp, INDICATOR_CALCULATIONS); SetIndexBuffer(15, TrendDown_Temp, INDICATOR_CALCULATIONS); IndicatorRelease(CCI_Handle); IndicatorRelease(ATR_Indicator_Handle); IndicatorRelease(ATR_TP_Handle); CCI_Handle = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL); ATR_Indicator_Handle = iATR(Symbol(), Period(), Indicator_Period); ATR_TP_Handle = iATR(Symbol(), Period(), TP_Period); if (Show_MultiTF_Info) { IndicatorRelease(TF_1_Handle); IndicatorRelease(TF_2_Handle); IndicatorRelease(TF_3_Handle); IndicatorRelease(TF_4_Handle); TF_1_Handle = iCustom(Symbol(), TF_1, "::Indicators\\Avenger_Band_Indicator - Copy.ex5", "", "", Period_Multiplier, "", 1, false, false, "", false, "", 10, false, "", false, "", 1, "", false); TF_2_Handle = iCustom(Symbol(), TF_2, "::Indicators\\Avenger_Band_Indicator - Copy.ex5", "", "", Period_Multiplier, "", 1, false, false, "", false, "", 10, false, "", false, "", 1, "", false); TF_3_Handle = iCustom(Symbol(), TF_3, "::Indicators\\Avenger_Band_Indicator - Copy.ex5", "", "", Period_Multiplier, "", 1, false, false, "", false, "", 10, false, "", false, "", 1, "", false); TF_4_Handle = iCustom(Symbol(), TF_4, "::Indicators\\Avenger_Band_Indicator - Copy.ex5", "", "", Period_Multiplier, "", 1, false, false, "", false, "", 10, false, "", false, "", 1, "", false); } if (Use_MACD_Filter) MACD_Handle = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow, MACD_SMA, MACD_Apply); if (Use_MA_Filter) { Fast_MA_Handle = iMA(Symbol(), Period(), Fast_MA_Period, 0, MA_Method, MA_Apply); Slow_MA_Handle = iMA(Symbol(), Period(), Slow_MA_Period, 0, MA_Method, MA_Apply); } if (Digits() == 3 || Digits() == 5) Pipvalue = 10; if (Statistics_Corner_OK == 0) Statistics_Corner = 0; else Statistics_Corner = 3; Initialized = false; } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { if (Show_Entry_and_TP || Show_Trade_Direction_Arrows || Show_Win_Loss_Points)//if all are false, we are calling the indicator from inside itself DeleteObjects(); } void DeleteObjects() { string Name; int objects_total = ObjectsTotal(0) - 1; for (int i = objects_total; i >= 0; i--) { Name = ObjectName(0, i); if (StringFind(Name, Prefix) == 0) ObjectDelete(0, Name); } } //+------------------------------------------------------------------+ //| 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[]) { if (rates_total < 50) return(0); if (prev_calculated == 0) { ArrayInitialize(Temp, EMPTY_VALUE); ArrayInitialize(TrendUp, EMPTY_VALUE); ArrayInitialize(TrendDown, EMPTY_VALUE); ArrayInitialize(ArrowBuy, EMPTY_VALUE); ArrayInitialize(ArrowSell, EMPTY_VALUE); ArrayInitialize(TrendUpSmall, EMPTY_VALUE); ArrayInitialize(TrendDownSmall, EMPTY_VALUE); ArrayInitialize(TrendChange, EMPTY_VALUE); ArrayInitialize(Entry_Buy, EMPTY_VALUE); ArrayInitialize(Entry_Sell, EMPTY_VALUE); ArrayInitialize(TP_Sell, EMPTY_VALUE); ArrayInitialize(TP_Buy, EMPTY_VALUE); ArrayInitialize(TP_Hit, EMPTY_VALUE); ArrayInitialize(SL_Hit, EMPTY_VALUE); ArrayInitialize(TrendUp_Temp, EMPTY_VALUE); ArrayInitialize(TrendDown_Temp, EMPTY_VALUE); } if (prev_calculated != rates_total) { Temp[rates_total - 1] = EMPTY_VALUE; TrendUp[rates_total - 1] = EMPTY_VALUE; TrendDown[rates_total - 1] = EMPTY_VALUE; ArrowBuy[rates_total - 1] = EMPTY_VALUE; ArrowSell[rates_total - 1] = EMPTY_VALUE; TrendUpSmall[rates_total - 1] = EMPTY_VALUE; TrendDownSmall[rates_total - 1] = EMPTY_VALUE; TrendChange[rates_total - 1] = EMPTY_VALUE; Entry_Buy[rates_total - 1] = EMPTY_VALUE; Entry_Sell[rates_total - 1] = EMPTY_VALUE; TP_Hit[rates_total - 1] = EMPTY_VALUE; SL_Hit[rates_total - 1] = EMPTY_VALUE; TrendUp_Temp[rates_total - 1] = EMPTY_VALUE; TrendDown_Temp[rates_total - 1] = EMPTY_VALUE; CopyBuffer(CCI_Handle, 0, 0, rates_total, CCI); CopyBuffer(ATR_Indicator_Handle, 0, 0, rates_total, ATR_Indicator); CopyBuffer(ATR_TP_Handle, 0, 0, rates_total, ATR_TP); int CCI_Array_Size = ArraySize(CCI); int ATR_Array_Size = ArraySize(ATR_Indicator); int limit, counter; double cciTrendNow; limit = MathMax(2, rates_total - Bar_Count); if (prev_calculated != 0) limit = prev_calculated - 1; for (int i = limit; i < rates_total - 1; i++) { cciTrendNow = 0; if (i < CCI_Array_Size) cciTrendNow = CCI[i]; counter = i; double ATR_Value = 0; if (i < ATR_Array_Size) ATR_Value = ATR_Indicator[i]; if (cciTrendNow >= 0) { Temp[i] = low[i] - ATR_Value * Period_Multiplier; if (Temp[i] < Temp[i - 1]) { Temp[i] = Temp[i - 1]; } } else { Temp[i] = high[i] + ATR_Value * Period_Multiplier; if (Temp[i] > Temp[i - 1]) { Temp[i] = Temp[i - 1]; } } if (Temp[i] < Temp[i - 1]) { TrendDown_Temp[i] = Temp[i]; if (TrendUp_Temp[i - 1] != EMPTY_VALUE && TrendDown_Temp[i - 1] == EMPTY_VALUE) TrendUp_Temp[i] = Temp[i]; } if (Temp[i] > Temp[i - 1]) { TrendUp_Temp[i] = Temp[i]; if (TrendDown_Temp[i - 1] != EMPTY_VALUE && TrendUp_Temp[i - 1] == EMPTY_VALUE) TrendDown_Temp[i] = Temp[i]; } if (Temp[i] == Temp[i - 1] && TrendDown_Temp[i - 1] != EMPTY_VALUE && TrendUp_Temp[i - 1] != EMPTY_VALUE) { if (TrendDown_Temp[i - 2] != EMPTY_VALUE) TrendUp_Temp[i] = Temp[i]; else if (TrendUp_Temp[i - 2] != EMPTY_VALUE) TrendDown_Temp[i] = Temp[i]; } else if (Temp[i] == Temp[i - 1]) { TrendUp_Temp[i] = TrendUp_Temp[i - 1]; TrendDown_Temp[i] = TrendDown_Temp[i - 1]; } int MACD_Direction_i = -1; if (Use_MACD_Filter) { double MACD_Main_i = Indicator_Value(MACD_Handle, 0, i); if (MACD_Main_i >= 0) MACD_Direction_i = OP_BUY; else if (MACD_Main_i <= 0) MACD_Direction_i = OP_SELL; } int MAs_Direction_i = -1; if (Use_MA_Filter) { double Fast_MA_i = Indicator_Value(Fast_MA_Handle, 0, i); double Slow_MA_i = Indicator_Value(Slow_MA_Handle, 0, i); if (Fast_MA_i >= Slow_MA_i) MAs_Direction_i = OP_BUY; else if (Fast_MA_i <= Slow_MA_i) MAs_Direction_i = OP_SELL; } if (MACD_Direction_i == -1 || MACD_Direction_i == OP_BUY) if (MAs_Direction_i == -1 || MAs_Direction_i == OP_BUY) TrendUp[i] = TrendUp_Temp[i]; if (MACD_Direction_i == -1 || MACD_Direction_i == OP_SELL) if (MAs_Direction_i == -1 || MAs_Direction_i == OP_SELL) TrendDown[i] = TrendDown_Temp[i]; if (TrendDown_Temp[i] != EMPTY_VALUE && TrendUp_Temp[i] != EMPTY_VALUE && TrendDown_Temp[i - 1] != EMPTY_VALUE) { TrendChange[i] = Temp[i]; if (Show_Trade_Direction_Arrows) ArrowBuy[i] = Temp[i] - Trade_Direction_Arrow_Distance * Pipvalue * Point(); if (Show_Entry_and_TP) { Entry_Buy[i] = close[i]; TP_Buy[i] = Entry_Buy[i] + ATR_TP[i] * TP_Multiplier; } Position_Buy = i; Last_Buy = Position_Buy; } if (TrendDown_Temp[i] != EMPTY_VALUE && TrendUp_Temp[i] != EMPTY_VALUE && TrendUp_Temp[i - 1] != EMPTY_VALUE) { TrendChange[i] = Temp[i]; if (Show_Trade_Direction_Arrows) ArrowSell[i] = Temp[i] + Trade_Direction_Arrow_Distance * Pipvalue * Point(); if (Show_Entry_and_TP) { Entry_Sell[i] = close[i]; TP_Sell[i] = Entry_Sell[i] - ATR_TP[i] * TP_Multiplier; } Position_Sell = i; Last_Sell = Position_Sell; } TrendUpSmall [i] = TrendUp [i]; TrendDownSmall [i] = TrendDown [i]; if (Show_Entry_and_TP && Position_Buy != -1 && high[i] >= TP_Buy[Position_Buy]) { Hit_Number++; if (Show_Win_Loss_Points) { TP_Hit[i] = TP_Buy[Position_Buy]; ObjectCreate(0, Prefix + "Profit" + (string) (int)time[i], OBJ_TEXT, 0, time[Position_Buy - 2], TP_Buy[Position_Buy]); ObjectSetString(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_TEXT, "+" + DoubleToString((TP_Buy[Position_Buy] - Entry_Buy[Position_Buy]) / Point(), 0)); ObjectSetString(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_FONT, "Arial Black"); ObjectSetInteger(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_FONTSIZE, Profit_Points_Size); ObjectSetInteger(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_ANCHOR, ANCHOR_RIGHT); ObjectSetInteger(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_COLOR, Profit_Points); ObjectCreate(0, Prefix + "Line" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Buy], TP_Hit[i], time[i], TP_Hit[i]); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_COLOR, clrGray); ObjectCreate(0, Prefix + "LineDash" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Buy], Entry_Buy[Position_Buy], time[i], TP_Hit[i]); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_COLOR, clrBlueViolet); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_STYLE, STYLE_DOT); } Position_Buy = -1; } if (Show_Entry_and_TP && Position_Sell != -1 && Position_Buy != -1 && Position_Buy < Position_Sell && Position_Buy != i) { Loss_Number++; if (Show_Win_Loss_Points) { SL_Hit[Position_Buy] = Entry_Sell[Position_Sell]; ObjectCreate(0, Prefix + "Loss" + (string) (int)time[i], OBJ_TEXT, 0, time[Position_Buy - 2], close[Position_Sell]); ObjectSetString(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_TEXT, DoubleToString((close[Position_Sell] - close[Position_Buy]) / Point(), 0)); ObjectSetString(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_FONT, "Arial Black"); ObjectSetInteger(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_FONTSIZE, Loss_Points_Size); ObjectSetInteger(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_ANCHOR, ANCHOR_RIGHT); ObjectSetInteger(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_COLOR, Loss_Points); ObjectCreate(0, Prefix + "Line" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Buy], close[Position_Sell], time[i], close[Position_Sell]); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_COLOR, clrGray); ObjectCreate(0, Prefix + "LineDash" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Buy], Entry_Buy[Position_Buy], time[i], close[Position_Sell]); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_COLOR, clrChocolate); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_STYLE, STYLE_DOT); } Position_Buy = -1; } if (Show_Entry_and_TP && Show_Win_Loss_Points && Position_Sell != -1 && low[i] <= TP_Sell[Position_Sell] && Position_Sell != i) { Hit_Number++; if (Show_Win_Loss_Points) { TP_Hit[i] = TP_Sell[Position_Sell]; ObjectCreate(0, Prefix + "Profit" + (string) (int)time[i], OBJ_TEXT, 0, time[Position_Sell - 2], TP_Sell[Position_Sell]); ObjectSetString(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_TEXT, "+" + DoubleToString((Entry_Sell[Position_Sell] - TP_Sell[Position_Sell]) / Point(), 0)); ObjectSetString(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_FONT, "Arial Black"); ObjectSetInteger(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_FONTSIZE, Profit_Points_Size); ObjectSetInteger(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_ANCHOR, ANCHOR_RIGHT); ObjectSetInteger(0, Prefix + "Profit" + (string) (int)time[i], OBJPROP_COLOR, Profit_Points); ObjectCreate(0, Prefix + "Line" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Sell], TP_Hit[i], time[i], TP_Hit[i]); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_COLOR, clrGray); ObjectCreate(0, Prefix + "LineDash" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Sell], Entry_Sell[Position_Sell], time[i], TP_Hit[i]); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_COLOR, clrBlueViolet); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_STYLE, STYLE_DOT); } Position_Sell = -1; } if (Show_Entry_and_TP && Position_Sell != -1 && Position_Buy != -1 && Position_Buy > Position_Sell && Position_Sell != i) { Loss_Number++; if (Show_Win_Loss_Points) { SL_Hit[Position_Sell] = Entry_Buy[Position_Buy]; ObjectCreate(0, Prefix + "Loss" + (string) (int)time[i], OBJ_TEXT, 0, time[Position_Sell - 2], close[Position_Buy]); ObjectSetString(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_TEXT, DoubleToString((close[Position_Sell] - close[Position_Buy]) / Point(), 0)); ObjectSetString(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_FONT, "Arial Black"); ObjectSetInteger(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_FONTSIZE, Loss_Points_Size); ObjectSetInteger(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_ANCHOR, ANCHOR_RIGHT); ObjectSetInteger(0, Prefix + "Loss" + (string) (int)time[i], OBJPROP_COLOR, Loss_Points); ObjectCreate(0, Prefix + "Line" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Sell], close[Position_Buy], time[i], close[Position_Buy]); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "Line" + (string) (int)time[i], OBJPROP_COLOR, clrGray); ObjectCreate(0, Prefix + "LineDash" + (string) (int)time[i], OBJ_TREND, 0, time[Position_Sell], Entry_Sell[Position_Sell], time[i], close[Position_Buy]); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_RAY_RIGHT, false); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_COLOR, clrChocolate); ObjectSetInteger(0, Prefix + "LineDash" + (string) (int)time[i], OBJPROP_STYLE, STYLE_DOT); } Position_Sell = -1; } } string Chart_Period = ""; switch (Period()) { case PERIOD_M1: Chart_Period = "M1"; break; case PERIOD_M5: Chart_Period = "M5"; break; case PERIOD_M15: Chart_Period = "M15"; break; case PERIOD_M30: Chart_Period = "M30"; break; case PERIOD_H1: Chart_Period = "H1"; break; case PERIOD_H4: Chart_Period = "H4"; break; case PERIOD_D1: Chart_Period = "D1"; break; case PERIOD_W1: Chart_Period = "W1"; break; case PERIOD_MN1: Chart_Period = "MN"; break; } if (Position_Buy == rates_total - 2) { string message = Symbol()+ " " + Chart_Period + "\r\n"+ TimeToString(TimeCurrent())+ "\r\nBuy Entry at: "+ DoubleToString(iClose(Symbol(), Period(), 1), Digits()); if (Enable_Alert) Alert(message); if (Enable_Notification) SendNotification(message); } if (Position_Sell == rates_total - 2) { string message = Symbol()+ " " + Chart_Period + "\r\n"+ TimeToString(TimeCurrent())+ "\r\nSell Entry at: "+ DoubleToString(iClose(Symbol(), Period(), 1), Digits()); if (Enable_Alert) Alert(message); if (Enable_Notification) SendNotification(message); } double Close_Last_Buy = 0, Close_Last_Sell = 0; if (Last_Buy != -1) Close_Last_Buy = close[Last_Buy]; if (Last_Sell != -1) Close_Last_Sell = close[Last_Sell]; Comments(Close_Last_Buy, Close_Last_Sell); } if (Show_MultiTF_Info) MultiTF_Dashboard(); Initialized = true; return(rates_total); } void Comments(double Close_Last_Buy, double Close_Last_Sell) { string name = Prefix + "Comments"; string text = "Avenger Band"; string font = "Arial Black"; color text_color = Statistics; int font_size = 13; int x = 10, y = 20; if (Show_Entry_and_TP) CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); if (Show_Entry_and_TP && ((Last_Buy > Last_Sell && Last_Buy != -1) || (Last_Sell == -1 && Last_Buy != -1))) { name = Prefix + "CommentsTrade"; text = "Buy: " + DoubleToString(Close_Last_Buy, Digits()); text_color = Statistics_Buy; font_size = 10; y = 55; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); name = Prefix + "CommentsTP"; text = "TP: " + DoubleToString(TP_Buy[Last_Buy], Digits()); y = 75; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); name = Prefix + "CommentsTPPoints"; text = "TP Points: " + DoubleToString((TP_Buy[Last_Buy] - Close_Last_Buy) / Point(), 0); font_size = 9; y = 95; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); } if (Show_Entry_and_TP && ((Last_Buy < Last_Sell && Last_Sell != -1) || (Last_Sell != -1 && Last_Buy == -1))) { name = Prefix + "CommentsTrade"; text = "Sell: " + DoubleToString(Close_Last_Sell, Digits()); text_color = Statistics_Sell; font_size = 10; y = 55; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); name = Prefix + "CommentsTP"; text = "TP: " + DoubleToString(TP_Sell[Last_Sell], Digits()); y = 75; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); name = Prefix + "CommentsTPPoints"; text = "TP Points: " + DoubleToString((Close_Last_Sell - TP_Sell[Last_Sell]) / Point(), 0); font_size = 9; y = 95; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); } if (Show_Entry_and_TP) { name = Prefix + "CommentsSignals"; text = "Total Signals: " + (string)(Loss_Number + Hit_Number); text_color = Statistics; font = "Arial"; font_size = 9; y = 115; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); if (Show_Win_Loss_Points) { name = Prefix + "CommentsWins"; text = "Total Wins: " + (string)Hit_Number; y = 135; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); } } text_color = Statistics; font = "Arial Black"; font_size = 9; y = 155; if (Show_Entry_and_TP && Show_Win_Loss_Points && Loss_Number + Hit_Number != 0) { name = Prefix + "CommentsHitRate"; text = "Hit Rate: " + DoubleToString((double)Hit_Number / (double)(Hit_Number + Loss_Number) * 100, 2) + "%"; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); } else if (Show_Entry_and_TP && Show_Win_Loss_Points) { name = Prefix + "CommentsHitRate"; text = "Hit Rate: 0%"; CreateText(name, x, y, text, font, font_size, text_color, Statistics_Corner); } } void CreateText(string name, int x, int y, string text, string font, int font_size, color text_color, int Corner) { if (ObjectFind(0, name) == -1) { ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0, 0, 0); ObjectSetInteger(0, name, OBJPROP_CORNER, Corner); ObjectSetString(0, name, OBJPROP_FONT, font); ObjectSetInteger(0, name, OBJPROP_FONTSIZE, font_size); if (Statistics_Corner == 3) ObjectSetInteger(0, name, OBJPROP_ANCHOR, ANCHOR_RIGHT); } ObjectSetInteger(0, name, OBJPROP_XDISTANCE, x); ObjectSetInteger(0, name, OBJPROP_YDISTANCE, y); ObjectSetString(0, name, OBJPROP_TEXT, text); ObjectSetInteger(0, name, OBJPROP_COLOR, text_color); } int IndicatorDirection(int &Handle, ENUM_TIMEFRAMES TF) { double AvengerBand[]; CopyBuffer(Handle, 1, 0, 2, AvengerBand); ArraySetAsSeries(AvengerBand, true); if (AvengerBand[1] != EMPTY_VALUE) return(OP_BUY); return(OP_SELL); } string TF_To_String(ENUM_TIMEFRAMES TF) { if (TF == PERIOD_M1) return("M1"); else if (TF == PERIOD_M2) return("M2"); else if (TF == PERIOD_M3) return("M3"); else if (TF == PERIOD_M4) return("M4"); else if (TF == PERIOD_M5) return("M5"); else if (TF == PERIOD_M6) return("M6"); else if (TF == PERIOD_M10) return("M10"); else if (TF == PERIOD_M12) return("M12"); else if (TF == PERIOD_M15) return("M15"); else if (TF == PERIOD_M20) return("M20"); else if (TF == PERIOD_M30) return("M30"); else if (TF == PERIOD_H1) return("H1"); else if (TF == PERIOD_H2) return("H2"); else if (TF == PERIOD_H3) return("H3"); else if (TF == PERIOD_H4) return("H4"); else if (TF == PERIOD_H6) return("H6"); else if (TF == PERIOD_H8) return("H8"); else if (TF == PERIOD_H12) return("H12"); else if (TF == PERIOD_D1) return("D1"); else if (TF == PERIOD_W1) return("W1"); else if (TF == PERIOD_MN1) return("MN1"); else if (TF == PERIOD_CURRENT) return(TF_To_String(Period())); return(""); } void MultiTF_Dashboard() { int New_Bars_TF1 = iBars(Symbol(), TF_1); int New_Bars_TF2 = iBars(Symbol(), TF_2); int New_Bars_TF3 = iBars(Symbol(), TF_3); int New_Bars_TF4 = iBars(Symbol(), TF_4); if (New_Bars_TF1 != Last_Bars_TF1) { EntryDirection_TF1 = IndicatorDirection(TF_1_Handle, TF_1); if (Initialized) Last_Bars_TF1 = New_Bars_TF1; } if (New_Bars_TF2 != Last_Bars_TF2) { EntryDirection_TF2 = IndicatorDirection(TF_2_Handle, TF_2); if (Initialized) Last_Bars_TF2 = New_Bars_TF2; } if (New_Bars_TF3 != Last_Bars_TF3) { EntryDirection_TF3 = IndicatorDirection(TF_3_Handle, TF_3); if (Initialized) Last_Bars_TF3 = New_Bars_TF3; } if (New_Bars_TF4 != Last_Bars_TF4) { EntryDirection_TF4 = IndicatorDirection(TF_4_Handle, TF_4); if (Initialized) Last_Bars_TF4 = New_Bars_TF4; } string name = Prefix + "TF1_BuySell"; string name2 = Prefix + "TF1"; string font = "Arial"; int font_size = 10; int x = 150, y = 50, y2 = 30; string text2 = TF_To_String(TF_1); string text = "Buy"; color text_color = MultiTF_Buy_Color; if (EntryDirection_TF1 == OP_SELL) { text = "Sell"; text_color = MultiTF_Sell_Color; } CreateText(name, x, y, text, font, font_size, text_color, CORNER_RIGHT_LOWER); CreateText(name2, x, y2, text2, font, font_size, text_color, CORNER_RIGHT_LOWER); x -= 40; name = Prefix + "TF2_BuySell"; name2 = Prefix + "TF2"; text2 = TF_To_String(TF_2); text = "Buy"; text_color = MultiTF_Buy_Color; if (EntryDirection_TF2 == OP_SELL) { text = "Sell"; text_color = MultiTF_Sell_Color; } CreateText(name, x, y, text, font, font_size, text_color, CORNER_RIGHT_LOWER); CreateText(name2, x, y2, text2, font, font_size, text_color, CORNER_RIGHT_LOWER); x -= 40; name = Prefix + "TF3_BuySell"; name2 = Prefix + "TF3"; text2 = TF_To_String(TF_3); text = "Buy"; text_color = MultiTF_Buy_Color; if (EntryDirection_TF3 == OP_SELL) { text = "Sell"; text_color = MultiTF_Sell_Color; } CreateText(name, x, y, text, font, font_size, text_color, CORNER_RIGHT_LOWER); CreateText(name2, x, y2, text2, font, font_size, text_color, CORNER_RIGHT_LOWER); x -= 40; name = Prefix + "TF4_BuySell"; name2 = Prefix + "TF4"; text2 = TF_To_String(TF_4); text = "Buy"; text_color = MultiTF_Buy_Color; if (EntryDirection_TF4 == OP_SELL) { text = "Sell"; text_color = MultiTF_Sell_Color; } CreateText(name, x, y, text, font, font_size, text_color, CORNER_RIGHT_LOWER); CreateText(name2, x, y2, text2, font, font_size, text_color, CORNER_RIGHT_LOWER); } double Indicator_Value(int Handle, int Buffer, int Position) { double Value[]; int bars = Bars(Symbol(), Period()); if (CopyBuffer(Handle, Buffer, (bars - 1) - Position, 1, Value) < 0) { Print("CopyBuffer error =",GetLastError()); return(0); } if (ArraySize(Value) > 0) return(Value[0]); return(0); }