ChangeParameters() not changing instance.parameters

All posts which do not fit into any other sections of the forum.

Moderator: admin

ChangeParameters() not changing instance.parameters

Postby OQTradeTech » Mon Jul 06, 2020 2:51 pm

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");
OQTradeTech
 
Posts: 2
Joined: Mon Jul 06, 2020 12:23 pm


Re: ChangeParameters() not changing instance.parameters

Postby OQTradeTech » Tue Jul 28, 2020 5:15 am

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.
Attachments
test.jpg
test.lua
(1.17 KiB) Downloaded 282 times
OQTradeTech
 
Posts: 2
Joined: Mon Jul 06, 2020 12:23 pm

Re: ChangeParameters() not changing instance.parameters

Postby Apprentice » Mon Aug 17, 2020 3:40 am

Your request is added to the development list.
Development reference 1892.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: ChangeParameters() not changing instance.parameters

Postby Apprentice » Tue Sep 01, 2020 3:17 am

Can not do much, it looks line an FXTS2 bug.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 4 guests