Difference between NumericSimple and NumericSeries  [SOLVED]

Questions about MultiCharts and user contributed studies.
chi jeongki
Posts: 39
Joined: 29 Nov 2007
Has thanked: 8 times
Been thanked: 2 times

Difference between NumericSimple and NumericSeries

Postby chi jeongki » 08 Jun 2014

In function should NumericeSimple and NumericSeries parameter type be differentiated rigidly?

Output file from topic "function: local variable do not increase at the second bar" shows that NumericSimple parameter has same history data as NumericSeries parameter.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Difference between NumericSimple and NumericSeries

Postby JoshM » 13 Jun 2014

In function should NumericeSimple and NumericSeries parameter type be differentiated rigidly?
I'm not sure if I understand this sentence, but to answer the topic title:

NumericSeries are used to pass in a numeric variable (and its historical data) into a function. The function will then be able to reference historical bars of this variable series.

NumericSimple are used to pass in a numeric variable into a function. Since this has no history, it will have a constant value from bar to bar when referenced in the function.

chi jeongki
Posts: 39
Joined: 29 Nov 2007
Has thanked: 8 times
Been thanked: 2 times

Re: Difference between NumericSimple and NumericSeries

Postby chi jeongki » 13 Jun 2014

signal code is calling function as follows,

_lang_print_loop(output_file, "----begin----", count_calling, close data1, close data1);

function _lang_print_loop defined 4rd parameter as NemericSimple and 5th parameter as NumericSeries. it is printing their value as follows,

"simple = [", simple_close, simple_close[1], simple_close[2], simple_close[3], "] ",
"series = [", series_close, series_close[1], series_close[2], series_close[3], "]");

it's output is the same like this.

simple = [ 0.85 0.86 0.83 0.82] series = [ 0.85 0.86 0.83 0.82]

I find no differece between defining parameter as NumericSimple and defining it as NemericSeries from the case above.
Does Multicharts detect the usage of parameters in the function code and treat NumericSimple as NumericSeries if it refers history value? Is'nt simple_close[1] a history value? Why MC does not complain about referring history value with NumericSimple parameter? What is like the history value that NumericSimple can not refer? An example would help to understand.
In another words, what is like the case where only NumericSeries should be used to refer history value, if NumericSimple is used instead of NumericSeries then it faild or the result is different?

Code: Select all

Input: file_output(StringSimple), line_called(StringSimple), count_calling(NumericSimple), simple_close(NumericSimple), series_close(NumericSeries);
Var: count_called(0);

count_called = count_called + 1;

print(File(file_output), line_called, ": ",
FormatDate("yyyy-MM-dd ", DateTime data1), FormatTime("HH:mm:ss ", DateTime data1), BarNumber data1:6:0,
open data1:6:2, high data1:6:2, low data1:6:2, close data1:6:2, upticks data1:10:0, downticks data1:10:0,
" ",
FormatDate("yyyy-MM-dd ", DateTime data2), FormatTime("HH:mm:ss ", DateTime data2), BarNumber data2:6:0,
open data2:6:2, high data2:6:2, low data2:6:2, close data2:6:2, upticks data2:10:0, downticks data2:10:0,
" ",
count_called:6:0, count_calling:6:0, " ",
"simple = [", simple_close, simple_close[1], simple_close[2], simple_close[3], "] ",
"series = [", series_close, series_close[1], series_close[2], series_close[3], "]");

_lang_print_loop = 1;

Code: Select all

Var: count_calling(0);
Var: output_file("c:\_lang_caller_print_loop.txt");


count_calling = count_calling + 1;
_lang_print_loop(output_file, "----begin----", count_calling, close data1, close data1);


print(File(output_file), "barnumber = ", BarNumber data1:0:0, NewLine, "maxbarsback = ", maxbarsback:0:0);


count_calling = count_calling + 1;
_lang_print_loop(output_file, "-----end-----", count_calling, close data1, close data1);
Attachments
_lang_caller_print_loop.txt
print log of function
(51.83 KiB) Downloaded 341 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Difference between NumericSimple and NumericSeries

Postby TJ » 13 Jun 2014

::
I find no differece between defining parameter as NumericSimple and defining it as NemericSeries from the case above.
::
You will see a difference when a function is calling a function.

chi jeongki
Posts: 39
Joined: 29 Nov 2007
Has thanked: 8 times
Been thanked: 2 times

Re: Difference between NumericSimple and NumericSeries

Postby chi jeongki » 14 Jun 2014

I can not make an example which shows the difference.
The following example of function calling another function do not show difference.

signal code

Code: Select all

print(File("C:\simple_series.txt"),
"_signal_caller = ", close:5:2);
_called_1(close, close);

print(File("C:\simple_series.txt"), NewLine);
_called_1 code

Code: Select all

Input: simple_close(NumericSimple), series_close(NumericSeries);

print(File("C:\simple_series.txt"),
"_called_1 simple = ", simple_close:5:2, simple_close[1]:5:2, simple_close[2]:5:2, simple_close[3]:5:2, simple_close[4]:5:2, " ",
"_called_1 series = ", series_close:5:2, series_close[1]:5:2, series_close[2]:5:2, series_close[3]:5:2, series_close[4]:5:2
);

_called_2(simple_close, series_close);

_called_1 = 1;
_called_2 code

Code: Select all

Input: simple_close(NumericSimple), series_close(NumericSeries);

print(File("C:\simple_series.txt"),
"_called_2 simple = ", simple_close:5:2, simple_close[1]:5:2, simple_close[2]:5:2, simple_close[3]:5:2, simple_close[4]:5:2, " ",
"_called_2 series = ", series_close:5:2, series_close[1]:5:2, series_close[2]:5:2, series_close[3]:5:2, series_close[4]:5:2
);

_called_2 = 1;
simple_series.txt

_signal_caller = 1.19
_called_1 simple = 1.19 1.17 1.11 1.06 1.08 _called_1 series = 1.19 1.17 1.11 1.06 1.08
_called_2 simple = 1.19 1.17 1.11 1.06 1.08 _called_2 series = 1.19 1.17 1.11 1.06 1.08


_signal_caller = 1.22
_called_1 simple = 1.22 1.19 1.17 1.11 1.06 _called_1 series = 1.22 1.19 1.17 1.11 1.06
_called_2 simple = 1.22 1.19 1.17 1.11 1.06 _called_2 series = 1.22 1.19 1.17 1.11 1.06


_signal_caller = 1.15
_called_1 simple = 1.15 1.22 1.19 1.17 1.11 _called_1 series = 1.15 1.22 1.19 1.17 1.11
_called_2 simple = 1.15 1.22 1.19 1.17 1.11 _called_2 series = 1.15 1.22 1.19 1.17 1.11


_signal_caller = 1.15
_called_1 simple = 1.15 1.15 1.22 1.19 1.17 _called_1 series = 1.15 1.15 1.22 1.19 1.17
_called_2 simple = 1.15 1.15 1.22 1.19 1.17 _called_2 series = 1.15 1.15 1.22 1.19 1.17


_signal_caller = 1.11
_called_1 simple = 1.11 1.15 1.15 1.22 1.19 _called_1 series = 1.11 1.15 1.15 1.22 1.19
_called_2 simple = 1.11 1.15 1.15 1.22 1.19 _called_2 series = 1.11 1.15 1.15 1.22 1.19


_signal_caller = 1.09
_called_1 simple = 1.09 1.11 1.15 1.15 1.22 _called_1 series = 1.09 1.11 1.15 1.15 1.22
_called_2 simple = 1.09 1.11 1.15 1.15 1.22 _called_2 series = 1.09 1.11 1.15 1.15 1.22


_signal_caller = 1.06
_called_1 simple = 1.06 1.09 1.11 1.15 1.15 _called_1 series = 1.06 1.09 1.11 1.15 1.15
_called_2 simple = 1.06 1.09 1.11 1.15 1.15 _called_2 series = 1.06 1.09 1.11 1.15 1.15

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Difference between NumericSimple and NumericSeries

Postby bowlesj3 » 15 Jun 2014

Does Multicharts detect the usage of parameters in the function code and treat NumericSimple as NumericSeries if it refers history value? Is'nt simple_close[1] a history value? Why MC does not complain about referring history value with NumericSimple parameter?
I just did a series of tests with variables (not functions). For those who do not know, you determine if a variable is numericsimple or numericseries by hovering your mouse pointer over the variable definition.

Test #1 with no print statement and Test #2 with a print statement. MyClose is numericsimple without the print statement and after I put the print statement in with the [1] then MyClose becomes NumericSeries. So what is happening is your definition of NumericSimple is being overriden by the compiler as soon as you try to test it with your print statements which have the [1], [2], [3] attempts to see if there is any historic data associated with the input.

Code: Select all

Variables: MyClose(0);

MyClose = close;

Print(File("C:\test.txt"),
MyClose[1],
" ");
I just did another test shown below. Even with reference to MyClose with [0] on the end it still forces the variable to be numericseries. So any reference to the square brackets will force a NumericSeries definition by the compiler. Your print statements are proof this is happening of course.

Code: Select all

Variables: MyClose(0);

MyClose = close;

Print(File("C:\test.txt"),
MyClose[0],
" ");
In the following test MyClose is NumericSimple.

Code: Select all

Variables: MyClose(0);
MyClose = close[0];

In the following test MyClose is also NumericSimple.

Code: Select all

Variables: MyClose(0);

MyClose = close[1];
Okay, so that confirms it. It is the placement of brackets at the end of MyClose only that causes the compiler to force the varaible (or the input) to be a NumericSeries item.
Last edited by bowlesj3 on 15 Jun 2014, edited 1 time in total.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Difference between NumericSimple and NumericSeries

Postby bowlesj3 » 15 Jun 2014

I just did another test with a function as shown below. I defined the function as simple rather than series.

Function:

Code: Select all

A_DeleteThis = Close;
However I returned the function to MyClose with [1] at the end of the function. The very fact that it compiled without any problems tells me that the square brackets at the end of the function has caused it to override the defintion of simple I chose.

Indicator:

Code: Select all

Variables: MyClose(0);

Myclose = A_DeleteThis[1];

Okay one last test to be really sure about the function. In this test I defined two numericsimple variables MyClose1 and MyClose2. I kept them simple by not putting any square brackets at the end of either of them. I then did a print on lastbaronchart by feeding them different square bracket references from the function and the values placed in the variables are different. So for sure the function is now a series function even though I defined it as simple.

Code: Select all

Variables:
MyClose1(0),
MyClose2(0);

if lastbaronchart then
begin
Myclose1 = A_DeleteThis[1];
Myclose2 = A_DeleteThis[2];
Print(File("C:\test.txt"),
MyClose1,
" ",
MyClose2,
" ");
end;

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Difference between NumericSimple and NumericSeries

Postby bowlesj3 » 15 Jun 2014

Back to the questions.
"Is'nt simple_close[1] a history value? "
Yes it is.
"Does Multicharts detect the usage of parameters in the function code and treat NumericSimple as NumericSeries if it refers history value?"
Yes it seems that when it finds the square brackets it does.
Why MC does not complain about referring history value with NumericSimple parameter?
The person or people who wrote the compiler appear to have decided to take the square brackets as the most important part of the puzzle and just continue on with the numericseries assumption without having the compiler complain. Some programming languages have an option explicit which means you must define a variable and the type of variable must match the usage. In this case the MC people did not require it to be so strict. It is what it is. It is neither good nor bad. You just get use to it and work with what you have.

chi jeongki
Posts: 39
Joined: 29 Nov 2007
Has thanked: 8 times
Been thanked: 2 times

Re: Difference between NumericSimple and NumericSeries  [SOLVED]

Postby chi jeongki » 20 Jun 2014

Thank you very much for detailed test and clear explanation, bowlesj3.

I hope MC team to document NumericSimple and NumericSeries more detailed and explicilty in MC manaul.


Return to “MultiCharts”