I have one strategy, the name is "EMAIL.lua".Sometimes, it will automatically suspend the operation because of the interruption of the network.So I want to check and restart it by "A1.lua"....
But I have tried many times not to be successful, how should I write this strategy?
Thank you for your help me...
- Code: Select all
---------------------------------------------------------------------------------
"EMAIL.lua":
function Init()
strategy:name("EMAIL");
strategy.parameters:addString("TF","time","","m30");
strategy.parameters:setFlag("TF",core.FLAG_PERIODS);
strategy.parameters:addString("Email","Email","","abc@gmail.com");
end
local TF;
local Email;
local Source;
local first;
function Prepare()
TF=instance.parameters.TF;
Email=instance.parameters.Email;
local name=""..TF.."Email,"..instance.bid:instrument();
instance:name(name);
Source=ExtSubscribe(1,nil,TF,true,"bar");
first=Source:first();
end
function ExtUpdate(id,source,period)
if period>=first then terminal:alertEmail(Email,"Email",""..instance.bid:instrument()..",bid"..instance.bid[NOW]) end
end
dofile(core.app_path().."\\strategies\\standard\\include\\helper.lua");
----------------------------------------------------------------------------------------
"A1.lua":
function Init()
strategy:name("Demonstration of the pausing strategy/alert");
strategy:description("");
strategy.parameters:addBoolean("Active", "Active", "", true);
end
local active = false;
function Prepare(onlyName)
instance:name(CheckParameters(instance.parameters));
if onlyName then return end
ChangeParameters();
end
function CheckParameters(params)
local mode;
if params.Active then mode = "Active" else mode = "Paused" end
return "EMAIL" .. "(" .. mode .. ")";
end
function ChangeParameters()
active = instance.parameters.Active;
end
function Update()
if not active then return end
end