--+------------------------------------------------------------------+ --| How to draw circle.lua | --| Copyright © 2015, Gehtsoft USA LLC | --| http://fxcodebase.com | --+------------------------------------------------------------------+ --| Developed by : Mario Jemic | --| mario.jemic@gmail.com | --+------------------------------------------------------------------+ --| Support our efforts by donating | --| Paypal: http://goo.gl/cEP5h5 | --| BitCoin : 1MfUHS3h86MBTeonJzWdszdzF2iuKESCKU | --+------------------------------------------------------------------+ -- Indicator profile initialization routine -- Defines indicator profile properties and indicator parameters -- TODO: Add minimal and maximal value of numeric parameters and default color of the streams function Init() indicator:name("How to draw circle"); indicator:description("How to draw circle"); indicator:requiredSource(core.Bar); indicator:type(core.Indicator); indicator.parameters:addGroup("Calculation"); indicator.parameters:addInteger("Period", "Period", "Period", 10); indicator.parameters:addGroup("Style"); indicator.parameters:addColor("color", "Color of S1", "Color of S1", core.rgb(255, 0, 0)); indicator.parameters:addInteger("width", "Line width", "", 1, 1, 5); indicator.parameters:addInteger("style", "Line style", "", core.LINE_SOLID); indicator.parameters:setFlag("style", core.FLAG_LINE_STYLE); indicator.parameters:addInteger("transparency", "Transparency", "Transparency", 50); end -- Indicator instance initialization routine -- Processes indicator parameters and creates output streams -- TODO: Refine the first period calculation for each of the output streams. -- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries -- Parameters block local Period; local first; local source = nil; local color, style, width; local transparency; -- Streams block -- Routine function Prepare(nameOnly) Period = instance.parameters.Period; transparency= instance.parameters.transparency; source = instance.source; first = source:first(); color = instance.parameters.color; style = instance.parameters.style; width = instance.parameters.width; local name = profile:id() .. "(" .. source:name() .. ", " .. tostring(Period) .. ")"; instance:name(name); if (not (nameOnly)) then instance:ownerDrawn(true); end end -- Indicator calculation routine -- TODO: Add your code for calculation output values function Update(period) end local init = false; function Draw(stage, context) if stage~= 0 then return; end if not init then context:createPen (1, context:convertPenStyle (style), width, color); context:createSolidBrush (2, color); context:convertTransparency (transparency); init= true; end local Last=source:size()-1; x1, x, x = context:positionOfBar (Last-Period+1); x2, x, x = context:positionOfBar (Last); visible, y1 = context:pointOfPrice (source.close[Last-Period+1]); visible, y2 = context:pointOfPrice (source.close[Last]); context:drawEllipse (1, 2, x1, y1, x2, y2); end