Convert vars to var

Posted By: Finstratech

Convert vars to var - 02/21/15 01:38

Quick question,
How can I efficiently convert output type, for example from

vars MAslope = series(movingAvg[1]/movingAvg[20]);

to a variable type "double" (or var)?

Your input is much appreciated.
Posted By: GPEngine

Re: Convert vars to var - 02/21/15 03:09

The most recent value is in MAslope[0].
Posted By: GPEngine

Re: Convert vars to var - 02/21/15 03:10

http://zorro-trader.com/manual/en/series.htm
Posted By: Finstratech

Re: Convert vars to var - 02/21/15 10:33

Originally Posted By: GPEngine
The most recent value is in MAslope[0].


This is absolutely correct.

However, I insist on knowing how to convert (or transform) a series (given above) which returns a "pointer" type, into a "double" type.

Otherwise, for my application, POINTER::DOUBLE error persists.

Thank you
Posted By: GPEngine

Re: Convert vars to var - 02/21/15 16:23

If the values of your vars variable are, for example
[1.1, 1.2, 1.3]
what do you expect the scalar float value to be after conversion?
Posted By: Finstratech

Re: Convert vars to var - 02/21/15 21:29

I want them to remain in a decimal form. The series returns a pointer and thus cannot be used as a mere double type used in comparison "if" statements with other double type variables.

So I need that 1.1, 1.2 etc. to be of a "double" type, aka simply a var.
Do I sound confusing, or is it something that should be looked at in a completely different way?

thanks
Posted By: GPEngine

Re: Convert vars to var - 02/21/15 21:56

var is just an alias for double.
See
include/trading.h:typedef double var;

vars is an pointer to an array of var. The way to make it not an array is to dereference it, like MAslope[0]. I guess you could use *MAslope if you prefer. It's the same thing as MAslope[0].
Posted By: Ch40zzC0d3r

Re: Convert vars to var - 02/21/15 23:31

Thats wrong. Double is actually 8 byte in size (var is 4 byte) and can contain a MUCH bigger numbers (or much smaller, or more precise).
Its an array of vars, nothing else
Posted By: Finstratech

Re: Convert vars to var - 02/22/15 00:11

Originally Posted By: GPEngine
The way to make it not an array is to dereference it, like MAslope[0].

Thank you GP. I misunderstood at first, but now I get what you mean.
MAslope[0] selects the current VAR value. Awesome laugh

@Ch40zzC0d3r Thanks. This information is out of my scope (kind of new to this), but I'll keep that in mind.

Thanks all, great work
Posted By: Finstratech

Re: Convert vars to var - 02/22/15 00:37

Here is a thought, we should implement a reward system where an answered question gets rewarded with, for example, an X amount of em-bit (0.001 Bitcoin) or bitcent (0.01 Bitcoin). Small fee for a questioning party, but can quickly add up for the active answering party. laugh
Posted By: jcl

Re: Convert vars to var - 02/22/15 09:16

Originally Posted By: Ch40zzC0d3r
Thats wrong. Double is actually 8 byte in size (var is 4 byte) and can contain a MUCH bigger numbers (or much smaller, or more precise).
Its an array of vars, nothing else

In Zorro lite-C, var is 8 bytes and is indeed a synonym for double. This is different to Gamestudio lite-C, where var is 4 bytes and a synonym for 22.10 fixed. "var" is just the standard variable type used for the specific application.
© 2024 lite-C Forums