Page 1 of 1

ChangeParameters() not changing instance.parameters

PostPosted: Mon Jul 06, 2020 2:51 pm
by OQTradeTech
Hello,

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");

Re: ChangeParameters() not changing instance.parameters

PostPosted: Sat Jul 25, 2020 4:26 am
by Apprentice
Capture.PNG

test.lua
(1.08 KiB) Downloaded 284 times

Re: ChangeParameters() not changing instance.parameters

PostPosted: Tue Jul 28, 2020 5:15 am
by OQTradeTech
Thank you, but removing ChangeParameters() from the program results in data loss, and does not really solve the issue of documentation describing the function inaccurately.

Re: ChangeParameters() not changing instance.parameters

PostPosted: Mon Aug 17, 2020 3:40 am
by Apprentice
Your request is added to the development list.
Development reference 1892.

Re: ChangeParameters() not changing instance.parameters

PostPosted: Tue Sep 01, 2020 3:17 am
by Apprentice
Can not do much, it looks line an FXTS2 bug.