AssetFloat not work?

Posted By: Grat

AssetFloat not work? - 05/08/21 09:41

Be carefull, with the version Zorro not work
Zorro S 2.37.4b
(c) oP group Germany 2021


Code
function run()
{
    asset("EUR/USD");
    AssetFloat[0]=1234.56;
    printf("\n%s = %f",Asset,AssetFloat[0]);
    quit("ok!");
}


have output:
Code

testIN compiling...........
EUR/USD = 0.000000
Test: testIN EUR/USD 2016..2021
Assets Assets4

ok!

Posted By: Grat

Re: AssetFloat not work? - 05/08/21 09:47

Other problem - must be know

Code

function run()
{

    asset("EUR/USD");
    AssetVar[0]=33.99;
    printf("\n%s = %f",Asset,AssetVar[0]);
    AssetFloat[0]=1234.56;
    printf("\n%s = %f",Asset,AssetVar[0]);
    quit("ok!");
}



have this output:
Code

testIN compiling...........
EUR/USD = 33.990002
EUR/USD = 33.989998
Test: testIN EUR/USD 2016..2021
Assets Assets4

ok!



This is correct - from manual:
32 general purpose int or float variables for internally storing integers or floats specific to the current asset. They are shared with AssetVar/AssetStr at twice the index, i.e. AssetVar[N] is shared with AssetInt[2*N] and AssetInt[2*N+1]. They cannot be read from the asset list. AssetInt can also be used to store asset-specific series or pointers for using them in a tmf or tick function.
Posted By: AndrewAMD

Re: AssetFloat not work? - 05/08/21 13:51

You need to cast float to var in order for printf to work.

Yes, var(double) is double the width of float. This has implications for pointer arithmetic / array positions.

You can read var and strings up to seven characters in length in your asset list for AssetVar and AssetStr, respectively.
© 2024 lite-C Forums