Moderator: admin
function Init()
strategy:name("Play Sound when new candle appears");
strategy:description("");
strategy.parameters:addGroup("Price");
strategy.parameters:addString("Period", "Time frame", "", "m1");
strategy.parameters:setFlag("Period", core.FLAG_PERIODS);
strategy.parameters:addGroup("Alert");
strategy.parameters:addBoolean("PlaySound", "Play Sound", "", true);
strategy.parameters:addFile("SoundFile", "Sound file", "", "");
end
local gSource;
local SoundFile;
function Prepare()
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");
assert(instance.parameters.Period ~= "t1", "Can't be applied on ticks!");
gSource = ExtSubscribe(1, nil, instance.parameters.Period, true, "bar");
local name = profile:id() .. "(" .. gSource:name() .. ")";
instance:name(name);
end
function ExtUpdate(id, source, period)
if id == 1 then
terminal:alertSound(SoundFile, false);
end
end
dofile(core.app_path() .. "\\strategies\\standard\\include\\helper.lua");
Return to Indicator Development
Users browsing this forum: No registered users and 11 guests