-- Id: 8386 -- More information about this indicator can be found at: -- http://fxcodebase.com/code/viewtopic.php?f=29&t=31337 --+------------------------------------------------------------------+ --| 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 | --+------------------------------------------------------------------+ function Init() strategy:name("Indicator alert"); strategy:setTag("NonOptimizableParameters", "Email,SendEmail,SoundFile,RecurrentSound,PlaySound,ShowAlert"); strategy:description("Alerts when a Renko indicator/oscillator crosses a certain level"); strategy.parameters:addGroup("Renko3 Parameters"); strategy.parameters:addString("Period", "Period size", "", "m1"); strategy.parameters:setFlag("Period", core.FLAG_PERIODS); strategy.parameters:addString("Type", "Price type", "", "Bid"); strategy.parameters:addStringAlternative("Type", "Bid", "", "Bid"); strategy.parameters:addStringAlternative("Type", "Ask", "", "Ask"); strategy.parameters:addInteger("Step", "Step in pips", "", 100); strategy.parameters:addGroup("Notification"); strategy.parameters:addBoolean("ShowAlert", "Show Alert", "", true); strategy.parameters:addBoolean("PlaySound", "Play Sound", "", false); strategy.parameters:addFile("SoundFile", "Sound File", "", ""); strategy.parameters:setFlag("SoundFile", core.FLAG_SOUND); strategy.parameters:addBoolean("SendEmail", "Send Email", "", false); strategy.parameters:addString("Email", "E-mail address", "Note that to recieve e-mails, SMTP settings must be defined (see Signals Options).", ""); strategy.parameters:setFlag("Email", core.FLAG_EMAIL); end local SoundFile; local gSource = nil; -- the source stream local ZigAndZag local SendEmail, Email; local lastSignal = nil function Prepare(nameOnly) local name = profile:id() .. "(" .. instance.bid:instrument() .. "(" .. instance.parameters.Period .. ")" .. ", Renko3)"; instance:name(name); if (nameOnly) then return; end assert(core.indicators:findIndicator("RENKO3") ~= nil, "Please, download and install RENKO3.LUA indicator"); gSource = ExtSubscribe(1, nil, instance.parameters.Period, instance.parameters.Type == "Bid", "bar"); I = core.indicators:create("RENKO3", gSource, instance.parameters.Step) tickSource = ExtSubscribe(2, nil, "t1", instance.parameters.Type == "Bid", "bar"); ShowAlert = instance.parameters.ShowAlert; if instance.parameters.PlaySound then SoundFile = instance.parameters.SoundFile; else SoundFile = nil; end assert(not(PlaySound) or (PlaySound and SoundFile ~= ""), "Sound file must be specified"); SendEmail = instance.parameters.SendEmail; if SendEmail then Email = instance.parameters.Email; else Email = nil; end assert(not(SendEmail) or (SendEmail and Email ~= ""), "E-mail address must be specified"); ExtSetupSignal("Renko3 Alert: ", ShowAlert); ExtSetupSignalMail(name); end -- when tick source is updated function ExtUpdate(id, source, period) -- update indicator if I ~= nil then I:update(core.UpdateLast); end if I.DATA:size() < 2 then return; end local sz = I.open:size() - 1 if I.open[sz] >= I.close[sz] and I.open[sz - 1] < I.close[sz - 1] and lastSignal ~= "Sell" then lastSignal = "Sell" ExtSignal(gSource, sz, "Sell", SoundFile, Email); elseif I.open[sz] < I.close[sz] and I.open[sz - 1] >= I.close[sz - 1] and lastSignal ~= "Buy" then lastSignal = "Buy" ExtSignal(gSource, sz, "Buy", SoundFile, Email); end end dofile(core.app_path() .. "\\strategies\\standard\\include\\helper.lua");