-- More information about this indicator can be found at: -- http://fxcodebase.com/code/viewtopic.php?f=28&t=61403&start=30 --+------------------------------------------------------------------+ --| Copyright © 2018, Gehtsoft USA LLC | --| http://fxcodebase.com | --+------------------------------------------------------------------+ --| Developed by : Mario Jemic | --| mario.jemic@gmail.com | --+------------------------------------------------------------------+ --| Support our efforts by donating | --| Paypal: https://goo.gl/9Rj74e | --| BitCoin : 15VCJTLaz12Amr7adHSBtL9v8XomURo9RF | --| BitCoin Cash: 1BEtS465S3Su438Kc58h2sqvVvHK9Mijtg | --| Ethereum : 0x8C110cD61538fb6d7A2B47858F0c0AaBd663068D | --| LiteCoin : LLU8PSY2vsq7B9kRELLZQcKf5nJQrdeqwD | --+------------------------------------------------------------------+ -- 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("View Template"); indicator:description("View Template"); indicator:requiredSource(core.Bar); indicator:type(core.View); indicator.parameters:addGroup("Calculation"); indicator.parameters:addInteger("CountX", "Count X", "", 10 ); indicator.parameters:addInteger("CountY", "Count Y", "", 10 ); indicator.parameters:addGroup("Style"); indicator.parameters:addColor("Color", "Label Color", "Label Color", core.COLOR_LABEL ); indicator.parameters:addInteger("transparency", "Fill Transparency", "0 - opaque, 100 - transparent", 0, 0, 100); indicator.parameters:addInteger("Size", "Font Size (As % of Cell)", "", 70 , 0, 100); 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 Size; local transparency; local CountX,CountY; local Color ; local Height; local HISTORY_LOADING_ID = 1000; local loading, Source; local xLabel={}; local yLabel={}; local open; local Label={}; -- Routine function Prepare(nameOnly) local name = profile:id() .. "(" .. instance.source:name() .. ")"; instance:name(name); if (nameOnly) then return; end Color= instance.parameters.Color; Size= instance.parameters.Size; CountX= instance.parameters.CountX; CountY= instance.parameters.CountY; instance:ownerDrawn(true); instance:initView("Dashboard", 0, 1, false, true); local ID=1; Source = core.host:execute("getHistory", HISTORY_LOADING_ID + ID, "EUR/USD", "m1", 0, 0, false); loading = true; open = instance:addStream("open", core.Dot, "open", "open", 0, 0, 0); open:setVisible(false); for i= 1 , CountX, 1 do xLabel[i]=tostring(i); end for j= 1 , CountY, 1 do yLabel[j]=tostring(j); end for i= 1 , CountX, 1 do Label[i]={}; for j= 1 , CountY, 1 do Label[i][j] = i.. " : " .. j end end end -- the function is called when the async operation is finished function AsyncOperationFinished(cookie) if cookie == (HISTORY_LOADING_ID + 1) then loading = false; for i = 0, Source:size() - 1 do instance:addViewBar(Source:date(i)); end end end local top, bottom; local left, right; local xGap; local yGap; -- Indicator calculation routine -- TODO: Add your code for calculation output values function Update(period, mode) --shoudn't be called end local init = false; function Draw(stage, context) if stage ~= 2 then return; end if not init then transparency = context:convertTransparency(instance.parameters.transparency); init = true; end top, bottom = context:top(), context:bottom(); left, right = context:left(), context:right(); xGap= (right-left)/(CountY+1); yGap= (bottom-top)/(CountX+1); for i= 1, CountX,1 do for j= 1, CountY,1 do Calculate (context,i, j); end end end function Calculate (context,i, j ) y1=top +(i)*yGap; x1=left +(j+1)*xGap; x2=left +(j )*xGap; iwidth = ((xGap/9)/100)*Size ; iheight= (yGap/100)*Size; context:createFont (7, "Arial",iwidth, iheight , 0); if j== 1 then width, height = context:measureText (7, xLabel[i], context.CENTER ); context:drawText (7, xLabel[i], Color, -1, x1-xGap*2, y1 , x1-xGap*2+width, y1+height, context.CENTER, 0); end if i== 1 then width, height = context:measureText (7, yLabel[j], 0); context:drawText (7, yLabel[j], Color, -1, x1-xGap/2 , y1-yGap ,x1-xGap/2+width , y1-yGap+height , context.CENTER ); end width, height = context:measureText (7, Label[i][j], context.CENTER ); context:drawText (7, Label[i][j], Color, -1, x1-xGap/2, y1 , x1-xGap/2+width, y1+height, context.CENTER, 0); end