// // XOHCL ... void DrawCandleAsLine( XOHCL &c, // the Candle Which required to Draw ... const datetime time, // Candle Time ... string tag = "", // Draw Tag ... // bool drawOpen = true, // Draw Open ... int openWidth = 1, // Open Width ... color clrOpen = clrLime, // Open Color ... ENUM_LINE_STYLE openStyle = STYLE_SOLID, // Open Style ... // bool drawHigh = true, // Draw High ... int highWidth = 1, // High Width ... color clrHigh = clrAqua, // High Color ... ENUM_LINE_STYLE highStyle = STYLE_SOLID, // High Style ... // bool drawClose = true, // Draw Close ... int closeWidth = 1, // Close Width ... color clrClose = clrRed, // Close Color ... ENUM_LINE_STYLE closeStyle = STYLE_SOLID, // Cose Style ... // bool drawLow = true, // Draw Low ... int lowWidth = 1, // Low Width ... color clrLow = clrMagenta, // Low Color ... ENUM_LINE_STYLE lowStyle = STYLE_SOLID // Low Style ... ) { // int subWindow = 0; long chartId = ChartID(); // datetime cTime = TimeCurrent(); // // Open ... if (drawOpen) { // string openTag = tag + "|O|" + ToString(c.open); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( openTag, chartId, subWindow // ); // if (isExists) { // // Move ... } else { // // Draw ... DrawTrendLine( chartId, openTag, subWindow, time, c.open, cTime, c.open, clrOpen, openStyle, openWidth // ); } } // // High ... if (drawHigh) { // string highTag = tag + "|H|" + ToString(c.high); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( highTag, chartId, subWindow // ); // if (isExists) { // // Move ... } else { // // Draw ... DrawTrendLine( chartId, highTag, subWindow, time, c.high, cTime, c.high, clrHigh, highStyle, highWidth // ); } } // // Close ... if (drawClose) { // string closeTag = tag + "|C|" + ToString(c.close); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( closeTag, chartId, subWindow // ); // if (isExists) { // // Move ... } else { // // Draw ... DrawTrendLine( chartId, closeTag, subWindow, time, c.close, cTime, c.close, clrClose, closeStyle, closeWidth // ); } } // // Low ... if (drawLow) { // string lowTag = tag + "|L|" + ToString(c.low); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( lowTag, chartId, subWindow // ); // if (isExists) { // // Move ... } else { // // Draw ... DrawTrendLine( chartId, lowTag, subWindow, time, c.low, cTime, c.low, clrLow, lowStyle, lowWidth // ); } } } // // Define a Draw Specifications ... struct XDrawSpecifications { // // Props ... // bool draw; // Draw or Not ... // int width; // Draw Witdth ... color clr; // Draw Color ... ENUM_LINE_STYLE style; // Draw Style ... // bool back; // in the background bool fill; // fill object if supported bool selection; // highlight to move bool rayRight; // line's continuation to the right bool hidden; // hidden in the object list long zOrder; // priority for mouse click // // Constructor ... XDrawSpecifications() { Clean(); } // // Operator ... void operator=(const XDrawSpecifications &value) { // clr = value.clr; draw = value.draw; width = value.width; style = value.style; // back = value.back; hidden = value.hidden; zOrder = value.zOrder; rayRight = value.rayRight; selection = value.selection; // fill = value.fill; } // // Functions ... // void Clean() { // draw = false; width = 1; clr = CLR_NONE; style = STYLE_SOLID; // back = false; hidden = false; rayRight = false; selection = false; fill = false; // zOrder = 0; } }; // // Candle Draw Specifications ... struct XOHCLDrawSpecification { // // Props ... XDrawSpecifications openStyle; XDrawSpecifications highStyle; XDrawSpecifications closeStyle; XDrawSpecifications lowStyle; // // Constructors ... XOHCLDrawSpecification() { Clean(); } // // Operators ... void operator=(const XOHCLDrawSpecification &value) { // lowStyle = value.lowStyle; openStyle = value.openStyle; highStyle = value.highStyle; closeStyle = value.closeStyle; } // // Functions ... // void Clean() { // lowStyle.Clean(); openStyle.Clean(); highStyle.Clean(); closeStyle.Clean(); } // void Default() { // // Open ... openStyle.width = 1; openStyle.draw = true; openStyle.clr = clrLime; openStyle.style = STYLE_SOLID; // // High ... highStyle.width = 1; highStyle.draw = true; highStyle.clr = clrAqua; highStyle.style = STYLE_SOLID; // // Close ... closeStyle.width = 1; closeStyle.draw = true; closeStyle.clr = clrRed; closeStyle.style = STYLE_SOLID; // // Low ... lowStyle.width = 1; lowStyle.draw = true; lowStyle.clr = clrMagenta; lowStyle.style = STYLE_SOLID; } // void Width(int value) { // lowStyle.width = value; openStyle.width = value; highStyle.width = value; closeStyle.width = value; } // void Style(ENUM_LINE_STYLE value) { // lowStyle.style = value; openStyle.style = value; highStyle.style = value; closeStyle.style = value; } // void Color(color value) { // lowStyle.clr = value; openStyle.clr = value; highStyle.clr = value; closeStyle.clr = value; } // void RayRight(bool value) { // lowStyle.rayRight = value; openStyle.rayRight = value; highStyle.rayRight = value; closeStyle.rayRight = value; } // void Draw(bool value) { // lowStyle.draw = value; openStyle.draw = value; highStyle.draw = value; closeStyle.draw = value; } // void Back(bool value) { // lowStyle.back = value; openStyle.back = value; highStyle.back = value; closeStyle.back = value; } // void Fill(bool value) { // lowStyle.fill = value; openStyle.fill = value; highStyle.fill = value; closeStyle.fill = value; } }; // bool RemoveCandle( XOHCL &c, long chartId = 0, int subWindow = 0 // ) { // bool result = false; // string cTag = GenerateTag(c); // result = IsDrawExists( cTag, chartId, subWindow); if (!result) { return result; } // RemoveDraws( cTag, chartId, subWindow); // return result; } // // XOHCL ... void DrawCandleAsLine( long chartId, // Chart ID ... int subWindow, // SubWindow ... XOHCL &c, // the Candle Which required to Draw ... const datetime time, // Candle Time ... XOHCLDrawSpecification &config, // Draw Specifications ... string tag = "", // Draw Tag ... bool update = true, // Update Draw if Exists ... bool drawMidLine = true // Draw Open Close Middle Line ... ) { // datetime cTime = TimeCurrent(); XDrawSpecifications specs; // string baseTag = tag + GenerateTag(c); // // Open ... specs = config.openStyle; if (specs.draw) { // double value = c.open; string valueTag = "|O|"; // string mTag = baseTag + valueTag + ToString(value); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( mTag, chartId, subWindow // ); bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteTrendLine( chartId, mTag); } // if (canDraw) { // // Draw ... DrawTrendLine( chartId, mTag, subWindow, time, value, cTime, value, specs.clr, specs.style, specs.width, specs.back, specs.selection, specs.rayRight, specs.hidden, specs.zOrder // ); } } // // High ... specs = config.highStyle; if (specs.draw) { // double value = c.high; string valueTag = "|H|"; // string mTag = baseTag + valueTag + ToString(value); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( mTag, chartId, subWindow // ); bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteTrendLine( chartId, mTag); } // if (canDraw) { // // Draw ... DrawTrendLine( chartId, mTag, subWindow, time, value, cTime, value, specs.clr, specs.style, specs.width, specs.back, specs.selection, specs.rayRight, specs.hidden, specs.zOrder // ); } } // // Close ... specs = config.closeStyle; if (specs.draw) { // double value = c.close; string valueTag = "|C|"; // string mTag = baseTag + valueTag + ToString(value); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( mTag, chartId, subWindow // ); bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteTrendLine( chartId, mTag); } // if (canDraw) { // // Draw ... DrawTrendLine( chartId, mTag, subWindow, time, value, cTime, value, specs.clr, specs.style, specs.width, specs.back, specs.selection, specs.rayRight, specs.hidden, specs.zOrder // ); } } // // Low ... specs = config.lowStyle; if (specs.draw) { // double value = c.low; string valueTag = "|L|"; // string mTag = baseTag + valueTag + ToString(value); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( mTag, chartId, subWindow // ); bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteTrendLine( chartId, mTag); } // if (canDraw) { // // Draw ... DrawTrendLine( chartId, mTag, subWindow, time, value, cTime, value, specs.clr, specs.style, specs.width, specs.back, specs.selection, specs.rayRight, specs.hidden, specs.zOrder // ); } } // double midle = MathAbs(c.open + c.close) / 2; string mTag = tag + GenerateTag(c); // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( mTag, chartId, subWindow // ); bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteTrendLine( chartId, mTag); } // if (canDraw) { // // Draw ... DrawTrendLine( chartId, mTag, subWindow, time, midle, cTime, midle, clrYellow, STYLE_SOLID, 2, false, false, false, false, 0 // ); } } // void DrawCandleAsBox( long chartId, // Chart ID ... int subWindow, // SubWindow ... XOHCL &c, // the Candle Which required to Draw ... const datetime time, // Candle Time ... XOHCLDrawSpecification &config, // Draw Specifications ... string tag = "", // Draw Tag ... bool drawBody = true, // Draw Body ... bool drawShadows = true, // Draw Shadows ... bool update = true // Update Draw if Exists ... ) { // datetime cTime = TimeCurrent(); // // First Check all Styles Must Be Draw true ... bool canDraw = // config.openStyle.draw && config.highStyle.draw && config.closeStyle.draw && config.lowStyle.draw // ; // if (!canDraw) { return; } // // Next we have to determine Candle is Bullish or Bearish ... // bool isBullish = c.open < c.close; // bool isBearish = c.open > c.close; // XDrawSpecifications bodySpec; if (isBullish) { bodySpec = config.openStyle; } else if (isBearish) { bodySpec = config.closeStyle; } else { // bodySpec.clr = clrGray; } // // Now We have to Draw 3 Rectangle ... // 1- Up Shadow // 2- Candle Body // 3- Down Shadow // double upPrice = MathMax(c.open, c.close); double downPrice = MathMin(c.open, c.close); double upShadowSize = c.high - upPrice; double downShadowSize = downPrice - c.low; // string mTag = "OHCL|O" + ToString(c.open) + "|H" + ToString(c.high) + "|C" + ToString(c.close) + "|L" + ToString(c.low) + "|"; // // Draw Up Shadow ... if (drawShadows) { // string upShadowTag = mTag + "|US|"; XDrawSpecifications spec = config.highStyle; // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( upShadowTag, chartId, subWindow // ); // bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteRectangle( chartId, upShadowTag // ); } // if (canDraw) { // // New ... DrawRectangle( chartId, upShadowTag, subWindow, time, c.high, cTime, upPrice, spec.clr, spec.style, spec.width, spec.fill, spec.back, spec.selection, spec.hidden, spec.zOrder // ); } } // // Draw Body ... if (drawBody) { // string bodyTag = mTag + "|BDY|"; // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( bodyTag, chartId, subWindow // ); // bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteRectangle( chartId, bodyTag // ); } // if (canDraw) { // // New ... DrawRectangle( chartId, bodyTag, subWindow, time, upPrice, cTime, downPrice, bodySpec.clr, bodySpec.style, bodySpec.width, bodySpec.fill, bodySpec.back, bodySpec.selection, bodySpec.hidden, bodySpec.zOrder // ); } } // // Draw Down Shadow ... if (drawShadows) { // string downShadowTag = mTag + "|DS|"; XDrawSpecifications spec = config.lowStyle; // // Check if Object Exists Delete it ... bool isExists = IsDrawExists( downShadowTag, chartId, subWindow // ); // bool canDraw = !isExists || (isExists && update); // if (isExists && canDraw) { // DeleteRectangle( chartId, downShadowTag // ); } // if (canDraw) { // // New ... DrawRectangle( chartId, downShadowTag, subWindow, time, downPrice, cTime, downPrice + downShadowSize, spec.clr, spec.style, spec.width, spec.fill, spec.back, spec.selection, spec.hidden, spec.zOrder // ); } } }