-- More information about this indicator can be found at: -- http://fxcodebase.com/code/viewtopic.php?f=28&t=61403 --+------------------------------------------------------------------+ --| 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 function Init() indicator:name("Shift Template"); indicator:description(""); indicator:requiredSource(core.Tick); indicator:type(core.Indicator); indicator.parameters:addGroup("Shift Period"); indicator.parameters:addInteger("Shift", "Shift period", "", 0); indicator.parameters:addGroup("Style"); indicator.parameters:addColor("color", "Line Color","", 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_LEVEL_STYLE); end local Shift; local first; local source; local Shifted; local Initial; local FIRST; -- Routine function Prepare(nameOnly) local name = profile:id() .. "(" .. instance.source:name() .. ")"; instance:name(name); if (nameOnly) then return; end Shift = instance.parameters.Shift; source = instance.source; first = source:first(); Initial = instance:addInternalStream(first, 0); if Shift > 0 then FIRST= first + Shift; else FIRST= first; end Shifted = instance:addStream("Shifted", core.Line, name .. ".Shifted", "Shifted", instance.parameters.color, FIRST, Shift) Shifted:setWidth(instance.parameters.width); Shifted:setStyle(instance.parameters.style); end -- Indicator calculation routine function Update(period) if (period < first) then return; end Initial[period]=source[period]; local p= period+Shift; if Shift < 0 then if period+Shift < FIRST then return; end end Shifted[p]= Initial[period]; end