-- More information about this indicator can be found at: --http://fxcodebase.com/code/viewtopic.php?f=17&t=63192 --+------------------------------------------------------------------+ --| 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 | --+------------------------------------------------------------------+ --| Patreon : https://goo.gl/GdXWeN | --| 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("MTF MCP Extreme TMA"); indicator:description("MTF MCP Extreme TMA"); indicator:requiredSource(core.Bar); indicator:type(core.Oscillator); indicator.parameters:addGroup("Calculation"); --indicator.parameters:addInteger("Period" , "Period", "", 14); indicator.parameters:addString("Type", "Currency pair Selector", "Currency pair Selector" , "Multiple currency pair"); indicator.parameters:addStringAlternative("Type", "Chart", "Chart" , "Chart"); indicator.parameters:addStringAlternative("Type", "Multiple currency pair", "Multiple currency pair" , "Multiple currency pair"); indicator.parameters:addStringAlternative("Type", "All currency pair", "All currency pair" , "All currency pair"); indicator.parameters:addBoolean("Sort", "Sort By Time Frame", "", true); for i= 1 ,20, 1 do indicator.parameters:addGroup(i..". Currency Pair "); Add(i); end AddTimeFrame (1 , "m1", true, 25 ); AddTimeFrame (2 , "m5" , true, 25 ); AddTimeFrame (3 , "m15", true, 25 ); AddTimeFrame (4 , "m30" , true, 25 ); AddTimeFrame (5 , "H1" , true, 25 ); AddTimeFrame (6 , "H2", true, 25 ); AddTimeFrame (7 , "H3" , true, 25 ); AddTimeFrame (8 , "H4", true, 25 ); AddTimeFrame (9 , "H6" , true, 25 ); AddTimeFrame (10 , "H8" , true, 25 ); AddTimeFrame (11 , "D1", true, 25 ); AddTimeFrame (12 , "W1" , true, 25 ); AddTimeFrame (13 , "M1", true, 25 ); indicator.parameters:addGroup("Style"); indicator.parameters:addColor("Color", "Label Color", "Label Color", core.rgb(0, 0, 0)); indicator.parameters:addColor("Up", "Up Trend Color","", core.rgb(0, 255, 0)); indicator.parameters:addColor("Down", "Down Trend Color","", core.rgb(255, 0, 0)); indicator.parameters:addColor("Neutral", "Neutral Trend Color","", core.rgb(0, 0, 255)); indicator.parameters:addInteger("transparency", "Fill Transparency", "0 - opaque, 100 - transparent", 70, 0, 100); indicator.parameters:addInteger("Size", "Font Size (As % of Cell)", "", 70 , 0, 100); end function AddTimeFrame(id , FRAME , DEFAULT ,Period1,Period2,Period3 ) indicator.parameters:addGroup(id..". Time Frame Selector"); indicator.parameters:addBoolean("Use"..id , "Show ".. FRAME , "", DEFAULT); indicator.parameters:addString("TF"..id, "Time frame", "", FRAME); indicator.parameters:setFlag("TF"..id, core.FLAG_PERIODS); indicator.parameters:addInteger("Period1"..id, "1. Period", "", Period1); indicator.parameters:addBoolean("Redraw"..id, "Redraw", "", true); indicator.parameters:addDouble("TrendThreshold"..id, "Trend Threshold", "", 0.5); end function getInstrumentList() local list={}; local point={}; local count = 0; local row, enum; enum = core.host:findTable("offers"):enumerator(); row = enum:next(); while row ~= nil do count = count + 1; list[count] = row.Instrument; point[count] = row.PointSize; row = enum:next(); end return list, count,point; end function Add(id) local Init={"EUR/USD","USD/JPY", "GBP/USD","USD/CHF", "EUR/CHF" , "AUD/USD","USD/CAD", "NZD/USD", "EUR/GBP", "EUR/JPY" , "GBP/JPY", "CHF/JPY","GBP/CHF", "EUR/AUD", "EUR/CAD" , "AUD/CAD", "AUD/JPY","CAD/JPY", "NZD/JPY", "GBP/CAD" }; if id <= 5 then indicator.parameters:addBoolean("Dodaj"..id, "Use This Slot", "", true); else indicator.parameters:addBoolean("Dodaj"..id, "Use This Slot", "", false); end indicator.parameters:addString("Pair" .. id, "Pair", "", Init[id]); indicator.parameters:setFlag("Pair" .. id, core.FLAG_INSTRUMENTS); 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 Filter; local Show; local iTF={"m1", "m5", "m15", "m30", "H1", "H2", "H3", "H4", "H6", "H8", "D1", "W1", "M1"}; local TF={}; local Period; local pauto = "(%a%a%a)/(%a%a%a)"; local Color; local Source={}; local Size; local transparency; local loading={}; local source; local Pair={}; local Count; local Type; local Dodaj={}; local Point={}; local Use={}; local Num; local ShowCells; local Up, Down, Neutral; local Indicator1={}; local Period1={}; local Redraw={}; local TrendThreshold={}; local Sort; local Index={}; local Sorted; function SortFunction() local New=Index; if not Sort then return New; end local SortFlag; for i = 1, Count, 1 do SortFlag= true while SortFlag do SortFlag=false; for j = 2, Num, 1 do p1=New[i][j]; p2=New[i][j-1]; x1=Indicator1[i][p1].DATA:size()-1 x2=Indicator1[i][p2].DATA:size()-1 if Indicator1[i][p1].DATA[x1] 250 then xGap= 250; end for i= 1, Count,1 do for j= 1, Num,1 do Calculate (context,i, j); end end end function Calculate (context,i, j ) if Sorted== nil then return; end y1=bottom -(j+1)*yGap; x1=left +(i-1)*xGap; --Index iwidth = ((xGap/14)/100)*Size ; iheight= (yGap/100)*Size; context:createFont (7, "Arial",iwidth, iheight , context.ITALIC); if j==Num then width, height = context:measureText (7, Pair[i], context.LEFT ); context:drawText (7,Pair[i], Color, -1, x1 , y1, x1+width,y1+height, context.LEFT ); end local Style=tostring(TF[ Sorted[i][j]]); SymbolColor = Indicator1[i][Sorted[i][j]].DATA:colorI(Indicator1[i][Sorted[i][j]].DATA:size()-1) ; width, height = context:measureText (7, Style , context.CENTER ); context:drawText (7, Style, SymbolColor, -1, x1 , y1+yGap, x1+width , y1+yGap+height, context.CENTER ); end