Unable to Draw ZigZag Indicator on Chart using MQL5

Unable to Draw ZigZag Indicator on Chart using MQL5

Manage alerts

Loading saved threads...

youssef fray · External communityPost link
External question — Stack Overflow Stack Exchange Author: youssef fray Original post: https://stackoverflow.com/questions/76630273 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I am trying to create a ZigZag indicator and draw it on the chart using MQL5. However, I'm facing difficulties in getting the indicator to appear on the chart. Here's my code void TrendLineCreator::TrendLineCreatorDrawer() { double ZigZagBufferHigh[]; double ZigZagBufferLow[]; double ZigZagHandler = iCustom(_Symbol, _Period, "Examples/ZigZag"); int ZigZagCountHigh = CopyBuffer(ZigZagHandler, 1, 0, 100, ZigZagBufferHigh); int ZigZagCountLow = CopyBuffer(ZigZagHandler, 2, 0, 100, ZigZagBufferLow); ArraySetAsSeries(ZigZagBufferLow,true); string trendlineName ="ZigZag_"; datetime time1; datetime time2; for(int i = 1; i < ArraySize(ZigZagBufferLow)-2 ; i++) { if(ZigZagBufferLow[i] != ZigZagBufferLow[i+1]) { if(iLow(_Symbol,_Period,i)!=ZigZagBufferLow[i]) { time1 = iTime(_Symbol, _Period, i); time2 = iTime(_Symbol, _Period, i+1); trendlineName = "ZigZag_" + IntegerToString(i); ObjectCreate(0, trendlineName, OBJ_TREND, 0, time1, ZigZagBufferLow[i], time2, ZigZagBufferLow[i+1]); ObjectSetInteger(0, trendlineName, OBJPROP_STYLE, STYLE_SOLID); ObjectSetInteger(0, trendlineName, OBJPROP_WIDTH, 3); ObjectSetInteger(0, trendlineName, OBJPROP_COLOR, clrRed); } } } }
Quote
Report
Mark SdS · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Mark SdS Original post: https://stackoverflow.com/a/76632234 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. welcome. I would check the ZigZagBufferLow[i] by adding a line to print out its content: for(int i = 1; i < ArraySize(ZigZagBufferLow)-2 ; i++) Print("ZigZagBufferLow[i]: ",ZigZagBufferLow[i]); { if(ZigZagBufferLow[i] != ZigZagBufferLow[i+1]) {... You could print the other element ZigZagBufferLow[i+1] as well. Hope this helps.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: youssef fray Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/76630273 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I am trying to create a ZigZag indicator and draw it on the chart using MQL5. However, I'm facing difficulties in getting the indicator to appear on the chart. Here's my code void TrendLineCreator::TrendLineCreatorDrawer() { double ZigZagBufferHigh[]; double ZigZagBufferLow[]; double ZigZagHandler = iCustom(_Symbol, _Period, "Examples/ZigZag"); int ZigZagCountHigh = CopyBuffer(ZigZagHandler, 1, 0, 100, ZigZagBufferHigh); int ZigZagCountLow = CopyBuffer(ZigZagHandler, 2, 0, 100, ZigZagBufferLow); ArraySetAsSeries(ZigZagBufferLow,true); string trendlineName ="ZigZag_"; datetime time1; datetime time2; for(int i = 1; i < ArraySize(ZigZagBufferLow)-2 ; i++) { if(ZigZagBufferLow[i] != ZigZagBufferLow[i+1]) { if(iLow(_Symbol,_Period,i)!=ZigZagBufferLow[i]) { time1 = iTime(_Symbol, _Period, i); time2 = iTime(_Symbol, _Period, i+1); trendlineName = "ZigZag_" + IntegerToString(i); ObjectCreate(0, trendlineName, OBJ_TREND, 0, time1, ZigZagBufferLow[i], time2, ZigZagBufferLow[i+1]); ObjectSetInteger(0, trendlineName, OBJPROP_STYLE, STYLE_SOLID); ObjectSetInteger(0, trendlineName, OBJPROP_WIDTH, 3); ObjectSetInteger(0, trendlineName, OBJPROP_COLOR, clrRed); } } } }

Cancel quote

Checking account access…