According to to the documentation, instance.parameters should change when ChangeParameters() is called. In my tests, I do not see this happening. In the following test code output, final line (top) should have parameters changed to m15, 10, but the values are not changed. It seems example code in documentation has the same issue.
Am I doing something wrong, or is it a bug in Trading Station?
TS version: 01.15.081619
- Code: Select all
Symbol Strategy/Indicator Message Time
EUR/USD TEST m15 10 Trace: 'Current parameters: m1; 1'. 2020-07-06 12:12:31
EUR/USD TEST m15 10 Trace: 'ExtAsyncOperationFinished called.'. 2020-07-06 12:12:31
EUR/USD TEST m15 10 Trace: 'Current parameters: m1; 1'. 2020-07-06 12:12:26
EUR/USD TEST m15 10 Trace: 'ExtAsyncOperationFinished called.'. 2020-07-06 12:12:26
EUR/USD TEST m15 10 Trace: 'Current parameters: m1; 1'. 2020-07-06 12:12:12
EUR/USD TEST m15 10 Trace: 'ChangeParameters called.'. 2020-07-06 12:12:12
EUR/USD TEST m15 10 Trace: 'New parameters: m15; 10'. 2020-07-06 12:12:12
EUR/USD TEST m15 10 Trace: 'Current parameters: m1; 1'. 2020-07-06 12:12:12
EUR/USD TEST m15 10 Trace: 'CheckParameters called.'. 2020-07-06 12:12:12
EUR/USD TEST m15 10 TEST m1 1 is started. 2020-07-06 12:12:00
TEST m15 10 Trace: 'Current parameters: m1; 1'. 2020-07-06 12:12:00
TEST m15 10 Trace: 'Prepare called.'. 2020-07-06 12:12:00
Test code (opening/closing trade prints current parameters):
- Code: Select all
function Init()
strategy:name("Test");
strategy:description("");
strategy:type(core.Strategy);
strategy.parameters:addString("t", "t", "", "m1");
strategy.parameters:setFlag("t", core.FLAG_PERIODS);
strategy.parameters:addInteger("i", "i", "", 1);
end
function Prepare(name_only)
instance:name(string.format("%s %s %i",profile:id(),instance.parameters.t,instance.parameters.i));
if not name_only then
log("Prepare called.");
printParameters();
core.host:execute("subscribeTradeEvents", 1000, "trades");
end
end
function ReleaseInstance()
log("ReleaseInstance called.");
printParameters();
end
function CheckParameters(params)
log("CheckParameters called.");
printParameters();
log("New parameters: %s; %i",params.t, params.i);
return string.format("%s %s %i",profile:id(),params.t,params.i);
end
function ChangeParameters()
log("ChangeParameters called.")
printParameters();
end
function ExtUpdate(id, source, period)
log("ExtUpdate called.");
printParameters();
end
function ExtAsyncOperationFinished(cookie, success, message, message1, message2)
log("ExtAsyncOperationFinished called.");
printParameters();
end
function log(text, ...)
core.host:trace(string.format(text, unpack(arg)));
end
function printParameters()
log("Current parameters: %s; %i",instance.parameters.t, instance.parameters.i);
end
dofile(core.app_path() .. "\\strategies\\standard\\include\\helper.lua");