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.
Difference between NumericSimple and NumericSeries [SOLVED]
-
- Posts: 39
- Joined: 29 Nov 2007
- Has thanked: 8 times
- Been thanked: 2 times
- 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
I'm not sure if I understand this sentence, but to answer the topic title:In function should NumericeSimple and NumericSeries parameter type be differentiated rigidly?
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.
-
- Posts: 39
- Joined: 29 Nov 2007
- Has thanked: 8 times
- Been thanked: 2 times
Re: Difference between NumericSimple and NumericSeries
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?
_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 345 times
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Difference between NumericSimple and NumericSeries
You will see a difference when a function is calling a function.::
I find no differece between defining parameter as NumericSimple and defining it as NemericSeries from the case above.
::
-
- Posts: 39
- Joined: 29 Nov 2007
- Has thanked: 8 times
- Been thanked: 2 times
Re: Difference between NumericSimple and NumericSeries
I can not make an example which shows the difference.
The following example of function calling another function do not show difference.
signal code
_called_1 code
_called_2 code
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
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);
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;
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;
_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
Re: Difference between NumericSimple and NumericSeries
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.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?
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],
" ");
Code: Select all
Variables: MyClose(0);
MyClose = close;
Print(File("C:\test.txt"),
MyClose[0],
" ");
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];
Last edited by bowlesj3 on 15 Jun 2014, edited 1 time in total.
Re: Difference between NumericSimple and NumericSeries
I just did another test with a function as shown below. I defined the function as simple rather than series.
Function:
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:
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.
Function:
Code: Select all
A_DeleteThis = Close;
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;
Re: Difference between NumericSimple and NumericSeries
Back to the questions.
Yes it is."Is'nt simple_close[1] a history value? "
Yes it seems that when it finds the square brackets it does."Does Multicharts detect the usage of parameters in the function code and treat NumericSimple as NumericSeries if it refers history value?"
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.Why MC does not complain about referring history value with NumericSimple parameter?
-
- Posts: 39
- Joined: 29 Nov 2007
- Has thanked: 8 times
- Been thanked: 2 times
Re: Difference between NumericSimple and NumericSeries [SOLVED]
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.
I hope MC team to document NumericSimple and NumericSeries more detailed and explicilty in MC manaul.