Impossible to call stored AlgoVar2 variables.

Posted By: Grant

Impossible to call stored AlgoVar2 variables. - 03/25/19 19:09

Hello,

I'm able to define AlgoVar2 variables, but unlike the AlgoVar variables, they return 0 after I call them from a .trd file. Did I made a mistake in my code? I also tried to store the AlgoVar2 variables to a second .trd file, but no luck.
Thanks for any feedback!

Code:
function run()
    {
    If(Bar >= 1) 
	{
      //Run this code only once with 1 == 1
	if(1 == 2)
	    {    
  	    AlgoVar[0] = 1;
	    AlgoVar[1] = 2;
	    AlgoVar[2] = 3;
	    AlgoVar[3] = 4;
	    AlgoVar[4] = 5;
	    AlgoVar[5] = 6;
	    AlgoVar[6] = 7;
	    AlgoVar[7] = 8;		
	    AlgoVar2[0] = 9;
	    AlgoVar2[1] = 10;
	    AlgoVar2[2] = 11;
	    AlgoVar2[3] = 12;
	    AlgoVar2[4] = 13;
	    AlgoVar2[5] = 14;
	    AlgoVar2[6] = 15;
	    AlgoVar2[7] = 16;
	    saveStatus("Log\a.trd");
	    }
		
	loadStatus("Log\a.trd");
	printf("n %.0f", AlgoVar[0]);	
	printf("n %.0f", AlgoVar[1]);	
	printf("n %.0f", AlgoVar[2]);
	printf("n %.0f", AlgoVar[3]);
	printf("n %.0f", AlgoVar[4]);
	printf("n %.0f", AlgoVar[5]);
	printf("n %.0f", AlgoVar[6]);
	printf("n %.0f", AlgoVar[7]);
	printf("n %.0f", AlgoVar2[0]);
	printf("n %.0f", AlgoVar2[1]);
	printf("n %.0f", AlgoVar2[2]);
	printf("n %.0f", AlgoVar2[3]);
	printf("n %.0f", AlgoVar2[4]);
	printf("n %.0f", AlgoVar2[5]);
	printf("n %.0f", AlgoVar2[6]);
	printf("n %.0f", AlgoVar2[7]);
		
	quit();
        }
    }

Posted By: AndrewAMD

Re: Impossible to call stored AlgoVar2 variables. - 03/25/19 19:22

if(1 == 2) automatically means if(false). This means the next code block will be ignored.
Posted By: Grant

Re: Impossible to call stored AlgoVar2 variables. - 03/25/19 19:58

Originally Posted By: AndrewAMD
if(1 == 2) automatically means if(false). This means the next code block will be ignored.


Hello Andrew,

I did that on purpose. My goal is to call these variables, once they are stored. This works fine for the AlgoVar, but not for the AlgoVar2 variables and I wonder why.
Posted By: AndrewAMD

Re: Impossible to call stored AlgoVar2 variables. - 03/25/19 20:04

OK, but it's not clear what you are trying to do. Can you split it into two separate scripts for clarity?
Posted By: Grant

Re: Impossible to call stored AlgoVar2 variables. - 03/25/19 20:14

Originally Posted By: AndrewAMD
OK, but it's not clear what you are trying to do. Can you split it into two separate scripts for clarity?


OK, first I define the AlgoVar and AlgoVar2 variables and store them to a .trd file:

Code:
function run()
          {
	  if(Bar >= 1) 
	      {
	      AlgoVar[0] = 1;
	      AlgoVar[1] = 2;
     	      AlgoVar[2] = 3;
	      AlgoVar[3] = 4;
	      AlgoVar[4] = 5;
	      AlgoVar[5] = 6;
	      AlgoVar[6] = 7;
	      AlgoVar[7] = 8;		
	      AlgoVar2[0] = 9;
	      AlgoVar2[1] = 10;
	      AlgoVar2[2] = 11;
	      AlgoVar2[3] = 12;
	      AlgoVar2[4] = 13;
	      AlgoVar2[5] = 14;
	      AlgoVar2[6] = 15;
	      AlgoVar2[7] = 16;
	      saveStatus("Log\a.trd");	
			
	      quit();
	      }
	  }



Then I call these variables and only the AlgoVar variables return their value.

Code:
function run()
    {
    if(Bar >= 1) 
        {
        loadStatus("Log\a.trd");
        printf("n %.0f", AlgoVar[0]);	
        printf("n %.0f", AlgoVar[1]);	
        printf("n %.0f", AlgoVar[2]);
        printf("n %.0f", AlgoVar[3]);
        printf("n %.0f", AlgoVar[4]);
        printf("n %.0f", AlgoVar[5]);
        printf("n %.0f", AlgoVar[6]);
        printf("n %.0f", AlgoVar[7]);
        printf("n %.0f", AlgoVar2[0]);
        printf("n %.0f", AlgoVar2[1]);
        printf("n %.0f", AlgoVar2[2]);
        printf("n %.0f", AlgoVar2[3]);
        printf("n %.0f", AlgoVar2[4]);
        printf("n %.0f", AlgoVar2[5]);
        printf("n %.0f", AlgoVar2[6]);
        printf("n %.0f", AlgoVar2[7]);

        quit();	
        }
    }

Posted By: AndrewAMD

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 02:17

It looks like the AlgoVar2 variables don't get saved or loaded at all.

Zorro feature not yet implemented?
Posted By: jcl

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 06:46

Yes, according to the manual only the AlgoVars are saved.
Posted By: MatPed

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 09:11

What do you mean with AlgoVars? Only AlgoVar[] or AlgoVar[] + AlgoVar2[]?
Posted By: Grant

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 11:56

Originally Posted By: AndrewAMD
It looks like the AlgoVar2 variables don't get saved or loaded at all.

Zorro feature not yet implemented?


I thought that there might be a limit to the number of variables a .trd file can store, so I saved the AlgoVar2 vars to a second file, but no luck.

Originally Posted By: jcl
Yes, according to the manual only the AlgoVars are saved.


Ah interesting, but then what's the use of AlgoVar2 in this context?

Originally Posted By: MatPed
What do you mean with AlgoVars? Only AlgoVar[] or AlgoVar[] + AlgoVar2[]?


My bad, I meant multiple AlgoVar variables.
Posted By: jcl

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 12:57

I meant only AlgoVars, not AlgoVars2. Saving them too could of course be implemented, but I believe the orginal intention was to leave AlgoVars2 initialized to zero so that they can be used as counters or similar.
Posted By: AndrewAMD

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 13:11

Why not have a separate SaveMode flag, like SV_ALGOVARS2?
Posted By: Grant

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 13:24

[b][/b]
Originally Posted By: AndrewAMD
Why not have a separate SaveMode flag, like SV_ALGOVARS2?


Or increase the number of AlgoVar variables. 8 is pretty limited for a multi-portfolio model. Anyway, it's not a big deal since there are multiple ways to store values.
Posted By: AndrewAMD

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 13:25

Originally Posted By: AndrewAMD
Why not have a separate SaveMode flag, like SV_ALGOVARS2?

This would address this:
Quote:
I believe the orginal intention was to leave AlgoVars2 initialized to zero so that they can be used as counters or similar.
Posted By: Zheka

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 14:01

A Zorro version in use exactly one year ago saved/loaded all AlgoVars.
My script relied on this for state recovery, so I spent enough time to verify it does work.

It would be great if this came back and worked as expected.
Posted By: MatPed

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 14:52

nooooooooooo I can only store 7 trade for each Algo/Aset. In testing obviously this fact did not emerged...
frown
Posted By: AndrewAMD

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 19:32

Originally Posted By: Grant
I thought that there might be a limit to the number of variables a .trd file can store, so I saved the AlgoVar2 vars to a second file, but no luck.
You can save any kind of binary data to disk, by the way. It's not terribly difficult.
Posted By: Grant

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 19:38

Originally Posted By: AndrewAMD
You can save any kind of binary data to disk, by the way. It's not terribly difficult.


Agreed and I already found a solution in the meantime. The AlgoVar feature however is a very simple way to store and call values between Zorro sessions.
Posted By: MatPed

Re: Impossible to call stored AlgoVar2 variables. - 03/26/19 22:50

Originally Posted By: Grant
Originally Posted By: AndrewAMD
You can save any kind of binary data to disk, by the way. It's not terribly difficult.


Agreed and I already found a solution in the meantime. The AlgoVar feature however is a very simple way to store and call values between Zorro sessions.


Same situation for me. Misunderstood what reported in the manual. Now I have to switch to save data on file and is not trivial...
Posted By: jcl

Re: Impossible to call stored AlgoVar2 variables. - 03/27/19 10:21

Saving the Algovars2 together with the Algovars would break systems that are using them, so we can't do that directly. But a flag SV_ALGOVARS2 is no problem. Even better would be a future feature to save certain series or memory areas.
Posted By: MatPed

Re: Impossible to call stored AlgoVar2 variables. - 03/27/19 13:57

Originally Posted By: jcl
Saving the Algovars2 together with the Algovars would break systems that are using them, so we can't do that directly. But a flag SV_ALGOVARS2 is no problem. Even better would be a future feature to save certain series or memory areas.


Good news.
I am using Algovar& Algovar2 to store and save closed trades results for each Algo/Asset combinations when I have to stop the system for maintenance or improvements.

Ciao
© 2024 lite-C Forums