Plotted lines distorted when teminal disconnect and reconnected. New comment Paul 2025.02.27 08:39 I don't why the lines are distorted when there is re-connection of the terminal, can someone please help me out. //+------------------------------------------------------------------+ //| 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 r = rates_total; // Check if maxLookBack has changed if (maxLookBack != previousMaxLookBack) { previousMaxLookBack = maxLookBack; ArrayResize(buyS1, maxLookBack + 1); ArrayResize(buyS2, maxLookBack + 1); ArrayResize(buyS3, maxLookBack + 1); ArrayResize(buyS4, maxLookBack + 1); ArrayResize(buyS5, maxLookBack + 1); ArrayResize(buyS6, maxLookBack + 1); ArrayResize(sellS1, maxLookBack + 1); ArrayResize(sellS2, maxLookBack + 1); ArrayResize(sellS3, maxLookBack + 1); ArrayResize(sellS4, maxLookBack + 1); ArrayResize(sellS5, maxLookBack + 1); ArrayResize(sellS6, maxLookBack + 1); ArrayInitialize(buyS1, 4.5); ArrayInitialize(sellS1, 4.5); ArrayInitialize(buyS2, 4.5); ArrayInitialize(sellS2, 4.5); ArrayInitialize(buyS3, 4.5); ArrayInitialize(sellS3, 4.5); ArrayInitialize(buyS4, 4.5); ArrayInitialize(sellS4, 4.5); ArrayInitialize(buyS5, 4.5); ArrayInitialize(sellS5, 4.5); ArrayInitialize(buyS6, 4.5); ArrayInitialize(sellS6, 4.5); fullRecalculationNeeded = true; } if (!m_created) { for (int i = 0; i < totalSymbols; i++) { string symb = symbolArray[i]; TextCreate(0, "Hof" + symb + "HoFbuy", ChartWindowFind(0, indicatorName), TimeCurrent(), close[r - 1], symb + "buy", font_Style, font_Size, txtColor); TextCreate(0, "Hof" + symb + "HoFsell", ChartWindowFind(0, indicatorName), TimeCurrent(), close[r - 1], symb + "sell", font_Style, font_Size, txtColor); } m_created = true; } r--; for (int i = 0; i < totalSymbols; i++) { string symb = symbolArray[i]; double prceb = (i == 0 ? buyS1[r] : i == 1 ? buyS2[r] : i == 2 ? buyS3[r] : i == 3 ? buyS4[r] : i == 4 ? buyS5[r] : buyS6[r]); double prces = (i == 0 ? sellS1[r] : i == 1 ? sellS2[r] : i == 2 ? sellS3[r] : i == 3 ? sellS4[r] : i == 4 ? sellS5[r] : sellS6[r]); TextMove(0, "Hof" + symb + "HoFbuy", time[r] + PeriodSeconds(PERIOD_CURRENT) * 0, prceb); TextMove(0, "Hof" + symb + "HoFsell", time[r] + PeriodSeconds(PERIOD_CURRENT) * 0, prces); } // Recalculate positions horizontal_space_cal = horizontal_space; vertical_space_cal = vertical_space; if (horizontal_space <= 0) horizontal_space_cal = (uint)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS, 0) / MaxSymbol_V; if (vertical_space <= 0) vertical_space_cal = (uint)ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0) / MaxSymbol_H; // Update trend lines and text labels verticalPosition = 35; horizontalPosition = horizontal_space_cal; for (int index = 0; index < totalSymbols; index++) { if (symbolArray[index] != "") { if (DrawObjects) { // Call CheckAllTimeframes for visualization CheckAllTimeframes(symbolArray[index], verticalPosition); DrawText(symbolArray[index], verticalPosition, 1); verticalPosition += horizontalPosition; } } } if (isNewBar()) { int maxback = MathMax(0, rates_total - maxLookBack); int start = MathMax(0, prev_calculated == 0 ? maxback : prev_calculated - 1); for (int redo = 0; redo < 4; redo++) { for (int i = start; i < r && !IsStopped(); i++) { if (i >= 0 && i < rates_total) // Ensure i is within the bounds of the arrays { buyS1[i] = EMPTY_VALUE; buyS2[i] = EMPTY_VALUE; buyS3[i] = EMPTY_VALUE; buyS4[i] = EMPTY_VALUE; buyS5[i] = EMPTY_VALUE; buyS6[i] = EMPTY_VALUE; sellS1[i] = EMPTY_VALUE; sellS2[i] = EMPTY_VALUE; sellS3[i] = EMPTY_VALUE; sellS4[i] = EMPTY_VALUE; sellS5[i] = EMPTY_VALUE; sellS6[i] = EMPTY_VALUE; for (int index = 0; index < totalSymbols; index++) { if (symbolArray[index] != "") CheckAllTimeframes2(symbolArray[index], i, time[i]); } } } } if (useFullRecalculation) { // Case 1: Full Recalculation // Iterate through each symbol for (int index = 0; index < totalSymbols; index++) { if (symbolArray[index] != "") // Ensure the symbol is valid { // Iterate through the required bars int start_bar = MathMax(0, rates_total - maxLookBack); // Start from 500 bars back for (int bar_indx = start_bar; bar_indx < rates_total; bar_indx++) { // Update each pair's buy and sell strength CheckAllTimeframes2(symbolArray[index], bar_indx, time[bar_indx]); } } } } else { // Case 2: Incremental Update // Determine the range of bars to process int start_bar = MathMax(0, fullRecalculationNeeded ? rates_total - maxLookBack : rates_total - 1); int end_bar = rates_total - 1; // Iterate through each symbol for (int index = 0; index < totalSymbols; index++) { if (symbolArray[index] != "") // Ensure the symbol is valid { // Process the determined range of bars for (int bar_indx = start_bar; bar_indx <= end_bar; bar_indx++) { // Update each pair's buy and sell strength CheckAllTimeframes2(symbolArray[index], bar_indx, time[bar_indx]); } } } // Reset the flag to indicate that only incremental updates are needed fullRecalculationNeeded = false; } if (XoverAlert) // Some function to check for crossover and alert checkAlertFunc_1(rates_total - 1); if (XoverAlert2) checkAlertFunc(rates_total - 1); if (StrenghtAlert2) checkAlertFunc4(rates_total - 1); if (StrenghtAlert) checkAlertFunc_2(rates_total - 1); } // Optional: Call checkAlertFunc for alert checks (if needed) return (rates_total); } This is before disconnection. The normal working if the indicator. When the terminal disconnect and connect again, the lines are distorted. Errors, bugs, questions Questions: to start with MetaTrader and forex Stop working for offline internet connection New comment
I don't why the lines are distorted when there is re-connection of the terminal, can someone please help me out.
This is before disconnection. The normal working if the indicator.
When the terminal disconnect and connect again, the lines are distorted.