Trying to get the yesterday high and low drawn on today chart along with percentages

Trying to get the yesterday high and low drawn on today chart along with percentages

Manage alerts

Loading saved threads...

Kobs · External communityPost link
External question — Stack Overflow Stack Exchange Author: Kobs Original post: https://stackoverflow.com/questions/78909716 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Im having issues with my mql5 script to get the previous days high and low and display it on the next day along with the 25%, 50% and 75%. The high and low sometimes don't cover the entire day and the percentages dont display at all. Also i would like a vertical line to connect all together like a box. i'm unsure how to do this. void OnStart() { // Define variables double high, low; datetime startTime, endTime; int range; int i = 1; // Start from the previous day // Loop through the previous days while (true) { // Get the high and low of the previous day high = iHigh(NULL, PERIOD_D1, i); low = iLow(NULL, PERIOD_D1, i); range = int(high - low); //Calculate the percentile double P_25, P_50, P_75; P_25 = NormalizeDoubleFunction((low + (range * 25/100))); P_50 = NormalizeDoubleFunction((low + (range * 50/100))); P_75 = NormalizeDoubleFunction((low + (range * 75/100))); double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT); startTime = iTime(NULL, PERIOD_D1, i) + 24 * 60 * 60; // Start time is the next day endTime = startTime + 24 * 60 * 60; // End time is the end of the next day // Break the loop if no more data if (startTime == 0) break; // Draw lines on the chart string highLineName = "PrevDayHigh_" + IntegerToString(i); string lowLineName = "PrevDayLow_" + IntegerToString(i); string P_25_Name = "25%" + IntegerToString(i); string P_50_Name = "50%" + IntegerToString(i); string P_75_Name = "75%" + IntegerToString(i); string startVertical = "Start vertical"; string endVertical = "End Vertical"; ObjectCreate(0, highLineName, OBJ_TREND, 0, startTime, high, endTime, high); ObjectSetInteger(0, highLineName, OBJPROP_COLOR, clrRed); ObjectSetInteger(0, highLineName, OBJPROP_WIDTH, 1); ObjectSetInteger(0, highLineName, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, P_25_Name, OBJ_TREND, 0, startTime, P_25, endTime, P_25); ObjectSetInteger(0, P_25_Name, OBJPROP_COLOR, clrBlue); ObjectSetInteger(0, P_25_Name, OBJPROP_WIDTH, 1); ObjectSetInteger(0, P_25_Name, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, P_50_Name, OBJ_TREND, 0, startTime, P_50, endTime, P_50); ObjectSetInteger(0, P_50_Name, OBJPROP_COLOR, clrYellow); ObjectSetInteger(0, P_50_Name, OBJPROP_WIDTH, 1); ObjectSetInteger(0, P_50_Name, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, P_75_Name, OBJ_TREND, 0, startTime, P_75, endTime, P_75); ObjectSetInteger(0, P_75_Name, OBJPROP_COLOR, clrOrange); ObjectSetInteger(0, P_75_Name, OBJPROP_WIDTH, 1); ObjectSetInteger(0, P_75_Name, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, lowLineName, OBJ_TREND, 0, startTime, low, endTime, low); ObjectSetInteger(0, lowLineName, OBJPROP_COLOR, clrGreen); ObjectSetInteger(0, lowLineName, OBJPROP_WIDTH, 1); ObjectSetInteger(0, lowLineName, OBJPROP_STYLE, STYLE_SOLID); i++; } } //+------------------------------------------------------------------+ double NormalizeDoubleFunction(double value){ double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT); return NormalizeDouble(value/point, 0) * point; }
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Kobs Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/78909716 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Im having issues with my mql5 script to get the previous days high and low and display it on the next day along with the 25%, 50% and 75%. The high and low sometimes don't cover the entire day and the percentages dont display at all. Also i would like a vertical line to connect all together like a box. i'm unsure how to do this. void OnStart() { // Define variables double high, low; datetime startTime, endTime; int range; int i = 1; // Start from the previous day // Loop through the previous days while (true) { // Get the high and low of the previous day high = iHigh(NULL, PERIOD_D1, i); low = iLow(NULL, PERIOD_D1, i); range = int(high - low); //Calculate the percentile double P_25, P_50, P_75; P_25 = NormalizeDoubleFunction((low + (range * 25/100))); P_50 = NormalizeDoubleFunction((low + (range * 50/100))); P_75 = NormalizeDoubleFunction((low + (range * 75/100))); double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT); startTime = iTime(NULL, PERIOD_D1, i) + 24 * 60 * 60; // Start time is the next day endTime = startTime + 24 * 60 * 60; // End time is the end of the next day // Break the loop if no more data if (startTime == 0) break; // Draw lines on the chart string highLineName = "PrevDayHigh_" + IntegerToString(i); string lowLineName = "PrevDayLow_" + IntegerToString(i); string P_25_Name = "25%" + IntegerToString(i); string P_50_Name = "50%" + IntegerToString(i); string P_75_Name = "75%" + IntegerToString(i); string startVertical = "Start vertical"; string endVertical = "End Vertical"; ObjectCreate(0, highLineName, OBJ_TREND, 0, startTime, high, endTime, high); ObjectSetInteger(0, highLineName, OBJPROP_COLOR, clrRed); ObjectSetInteger(0, highLineName, OBJPROP_WIDTH, 1); ObjectSetInteger(0, highLineName, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, P_25_Name, OBJ_TREND, 0, startTime, P_25, endTime, P_25); ObjectSetInteger(0, P_25_Name, OBJPROP_COLOR, clrBlue); ObjectSetInteger(0, P_25_Name, OBJPROP_WIDTH, 1); ObjectSetInteger(0, P_25_Name, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, P_50_Name, OBJ_TREND, 0, startTime, P_50, endTime, P_50); ObjectSetInteger(0, P_50_Name, OBJPROP_COLOR, clrYellow); ObjectSetInteger(0, P_50_Name, OBJPROP_WIDTH, 1); ObjectSetInteger(0, P_50_Name, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, P_75_Name, OBJ_TREND, 0, startTime, P_75, endTime, P_75); ObjectSetInteger(0, P_75_Name, OBJPROP_COLOR, clrOrange); ObjectSetInteger(0, P_75_Name, OBJPROP_WIDTH, 1); ObjectSetInteger(0, P_75_Name, OBJPROP_STYLE, STYLE_SOLID); ObjectCreate(0, lowLineName, OBJ_TREND, 0, startTime, low, endTime, low); ObjectSetInteger(0, lowLineName, OBJPROP_COLOR, clrGreen); ObjectSetInteger(0, lowLineName, OBJPROP_WIDTH, 1); ObjectSetInteger(0, lowLineName, OBJPROP_STYLE, STYLE_SOLID); i++; } } //+------------------------------------------------------------------+ double NormalizeDoubleFunction(double value){ double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT); return NormalizeDouble(value/point, 0) * point; }

Cancel quote

Checking account access…