where should the prediction line start , the following code there are two lines on the swing high ie blue line one diagonal and the other horizontal and they both start at the around the same place , but is on the m1 chart and is different on the others . is the code sound:

#property indicator_chart_window
#property indicator_plots 0

input int    SwingPeriod = 5;            // Period on each side for swing detection
input color  UpTrendLineColor = clrDodgerBlue;
input color  DownTrendLineColor = clrOrangeRed;
input int    TrendLineWidth = 2;
input int    PredictionBars = 10;        // Number of bars to predict into the future

// Arrays for swing points
int         SwingHighIdxs[];
double      SwingHighPrices[];
datetime    SwingHighTimes[];
int         SwingLowIdxs[];
double      SwingLowPrices[];
datetime    SwingLowTimes[];

// Object prefixes
string      highLinePrefix = "SwingHighTrendLine_";
string      lowLinePrefix  = "SwingLowTrendLine_";
string      predHighLinePrefix = "PredSwingHighTrendLine_";
string      predLowLinePrefix = "PredSwingLowTrendLine_";

//+------------------------------------------------------------------+
//| Check if bar at shift is swing high                              |
//+------------------------------------------------------------------+
bool IsSwingHigh(const double &high[], int shift, int size)
{
   double price = high[shift];
   for (int i = shift - SwingPeriod; i <= shift + SwingPeriod; i++)
   {
      if (i < 0 || i >= size)
         continue;
      if (high[i] > price)
         return false;
   }
   return true;
}

//+------------------------------------------------------------------+
//| Check if bar at shift is swing low                               |
//+------------------------------------------------------------------+
bool IsSwingLow(const double &low[], int shift, int size)
{
   double price = low[shift];
   for (int i = shift - SwingPeriod; i <= shift + SwingPeriod; i++)
   {
      if (i < 0 || i >= size)
         continue;
      if (low[i] < price)
         return false;
   }
   return true;
}

//+------------------------------------------------------------------+
//| Remove existing trendlines                                       |
//+------------------------------------------------------------------+
void RemoveTrendLines()
{
   for (int i = 0; i < 3; i++)
   {
      string name = highLinePrefix + IntegerToString(i);
      if (ObjectFind(0, name) >= 0)
         ObjectDelete(0, name);
   }
   for (int i = 0; i < 3; i++)
   {
      string name = lowLinePrefix + IntegerToString(i);
      if (ObjectFind(0, name) >= 0)
         ObjectDelete(0, name);
   }
   for (int i = 0; i < 3; i++)
   {
      string name = predHighLinePrefix + IntegerToString(i);
      if (ObjectFind(0, name) >= 0)
         ObjectDelete(0, name);
   }
   for (int i = 0; i < 3; i++)
   {
      string name = predLowLinePrefix + IntegerToString(i);
      if (ObjectFind(0, name) >= 0)
         ObjectDelete(0, name);
   }
}

//+------------------------------------------------------------------+
//| Calculate the slope of the trend line                            |
//+------------------------------------------------------------------+
double CalculateSlope(datetime time1, double price1, datetime time2, double price2)
{
   long timeDiff = time2 - time1;
   if (timeDiff == 0) return 0;
   return (price2 - price1) / timeDiff;
}

//+------------------------------------------------------------------+
//| Draw trend lines connecting last 3 swings                        |
//+------------------------------------------------------------------+
void DrawTrendLines()
{
   RemoveTrendLines();

   // Draw High trend lines if have at least 2 swings
   if (ArraySize(SwingHighIdxs) >= 2)
   {
      for (int i = 0; i < ArraySize(SwingHighIdxs) - 1; i++)
      {
         string name = highLinePrefix + IntegerToString(i);
         datetime time1 = SwingHighTimes[i];
         datetime time2 = SwingHighTimes[i + 1];
         double price1 = SwingHighPrices[i];
         double price2 = SwingHighPrices[i + 1];

         ObjectCreate(0, name, OBJ_TREND, 0, time1, price1, time2, price2);
         ObjectSetInteger(0, name, OBJPROP_COLOR, UpTrendLineColor);
         ObjectSetInteger(0, name, OBJPROP_WIDTH, TrendLineWidth);
         ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, false);
         ObjectSetInteger(0, name, OBJPROP_BACK, true);

         // Predictive trend line
         double slope = CalculateSlope(time1, price1, time2, price2);
         datetime futureTime = time2 + PredictionBars * PeriodSeconds();
         double futurePrice = price2 + slope * (futureTime - time2);

         string predName = predHighLinePrefix + IntegerToString(i);
         ObjectCreate(0, predName, OBJ_TREND, 0, time2, price2, futureTime, futurePrice);
         ObjectSetInteger(0, predName, OBJPROP_COLOR, UpTrendLineColor);
         ObjectSetInteger(0, predName, OBJPROP_STYLE, STYLE_DOT);
         ObjectSetInteger(0, predName, OBJPROP_WIDTH, TrendLineWidth);
      }
   }

   // Draw Low trend lines if have at least 2 swings
   if (ArraySize(SwingLowIdxs) >= 2)
   {
      for (int i = 0; i < ArraySize(SwingLowIdxs) - 1; i++)
      {
         string name = lowLinePrefix + IntegerToString(i);
         datetime time1 = SwingLowTimes[i];
         datetime time2 = SwingLowTimes[i + 1];
         double price1 = SwingLowPrices[i];
         double price2 = SwingLowPrices[i + 1];

         ObjectCreate(0, name, OBJ_TREND, 0, time1, price1, time2, price2);
         ObjectSetInteger(0, name, OBJPROP_COLOR, DownTrendLineColor);
         ObjectSetInteger(0, name, OBJPROP_WIDTH, TrendLineWidth);
         ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, false);
         ObjectSetInteger(0, name, OBJPROP_BACK, true);

         // Predictive trend line
         double slope = CalculateSlope(time1, price1, time2, price2);
         datetime futureTime = time2 + PredictionBars * PeriodSeconds();
         double futurePrice = price2 + slope * (futureTime - time2);

         string predName = predLowLinePrefix + IntegerToString(i);
         ObjectCreate(0, predName, OBJ_TREND, 0, time2, price2, futureTime, futurePrice);
         ObjectSetInteger(0, predName, OBJPROP_COLOR, DownTrendLineColor);
         ObjectSetInteger(0, predName, OBJPROP_STYLE, STYLE_DOT);
         ObjectSetInteger(0, predName, OBJPROP_WIDTH, TrendLineWidth);
      }
   }
}

//+------------------------------------------------------------------+
//| Insert swing point at the beginning of the array                 |
//+------------------------------------------------------------------+
void InsertSwingPoint(int &idxs[], double &prices[], datetime &times[], int idx, double price, datetime time)
{
   int size = ArraySize(idxs);
   ArrayResize(idxs, size + 1);
   ArrayResize(prices, size + 1);
   ArrayResize(times, size + 1);

   for (int k = size; k > 0; k--)
   {
      idxs[k] = idxs[k - 1];
      prices[k] = prices[k - 1];
      times[k] = times[k - 1];
   }
   idxs[0] = idx;
   prices[0] = price;
   times[0] = time;
}

//+------------------------------------------------------------------+
//| Main calculation function                                        |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
{
   if (rates_total < SwingPeriod * 2 + 1)
      return rates_total;

   // Declare series arrays and copy data
   double high[], low[];
   datetime time[];

   ArraySetAsSeries(high, true);
   ArraySetAsSeries(low, true);
   ArraySetAsSeries(time, true);

   if (CopyHigh(_Symbol, _Period, 0, rates_total, high) <= 0)
      return prev_calculated;
   if (CopyLow(_Symbol, _Period, 0, rates_total, low) <= 0)
      return prev_calculated;
   if (CopyTime(_Symbol, _Period, 0, rates_total, time) <= 0)
      return prev_calculated;

   // Clear arrays
   ArrayResize(SwingHighIdxs, 0);
   ArrayResize(SwingHighPrices, 0);
   ArrayResize(SwingHighTimes, 0);
   ArrayResize(SwingLowIdxs, 0);
   ArrayResize(SwingLowPrices, 0);
   ArrayResize(SwingLowTimes, 0);

   int start = rates_total - SwingPeriod - 1;
   int end = SwingPeriod;

   for (int i = start; i >= end; i--)
   {
      if (IsSwingHigh(high, i, rates_total))
      {
         InsertSwingPoint(SwingHighIdxs, SwingHighPrices, SwingHighTimes, i, high[i], time[i]);
      }

      if (IsSwingLow(low, i, rates_total))
      {
         InsertSwingPoint(SwingLowIdxs, SwingLowPrices, SwingLowTimes, i, low[i], time[i]);
      }
   }

   // Keep only latest 3 swings
   if (ArraySize(SwingHighIdxs) > 3)
   {
      ArrayResize(SwingHighIdxs, 3);
      ArrayResize(SwingHighPrices, 3);
      ArrayResize(SwingHighTimes, 3);
   }
   if (ArraySize(SwingLowIdxs) > 3)
   {
      ArrayResize(SwingLowIdxs, 3);
      ArrayResize(SwingLowPrices, 3);
      ArrayResize(SwingLowTimes, 3);
   }

   DrawTrendLines();

   return rates_total;
}