cross over condition

Questions about MultiCharts and user contributed studies.
SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

cross over condition

Postby SUPER » 08 Jul 2012

I ran following code as an indicator and as a strategy and for some strange reasons the inidcator was not able to detect cross over condition with MaxBarsSet at 50:

Output for Indicator:
1 false
2 false
3 false
4 false
5 false

Output for Stragegy:
1 false
2 false
3 true
4 false
5 false


Code: Select all

variables:
x( 0 ) ;

if CurrentBar = 1 then
X = 29 ;

if CurrentBar = 2 then
X = 30 ;

if CurrentBar = 3 then
X = 31 ;

if CurrentBar <=5 then
print ( CurrentBar, X crosses over 30 ) ;

ClarkFX
Posts: 5
Joined: 06 Jul 2012
Location: Canada
Contact:

Re: cross over condition

Postby ClarkFX » 09 Jul 2012

Try "Crosses Above"

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: cross over condition

Postby SUPER » 09 Jul 2012

Try "Crosses Above"
Thanks ClarkFX,

Cross above works, since "Crosses Above " and "Crosses Over" are supposed to be transposable so they should work in similar fashion, am I missing something here.

I found some strange behaviour with "Crosses Above" in same code:

Case1: set max number of bars study refers to " Auto detect", indicator fails to detect crosses.

Case2: change set max number of bars study refers to "User-Specified" to 50, it fails to detect crosses

Case3: remove old study and insurt same study again with option change set max number of bars study refers to "User-Specified" to 50, it detects crosses (Working as expected)

Observation: Making changes from Auto detect to User specified does not work

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

Re: cross over condition

Postby JoshM » 09 Jul 2012

I ran following code as an indicator and as a strategy and for some strange reasons the inidcator was not able to detect cross over condition with MaxBarsSet at 50:

Output for Indicator:
1 false
2 false
3 false
4 false
5 false
Funny thing: it works correctly in the indicator if you reference historical values for X (with [ & ]). If that isn't done, it gives 5 times False. Otherwise it gives the same output as the strategy:

Code: Select all

variables:
x( 0 ) ;

if CurrentBar = 1 then
X = 29 ;

if CurrentBar = 2 then
X = 30 ;

if CurrentBar = 3 then
X = 31 ;

if CurrentBar <=5 then
print ( CurrentBar, " PrevValue X = ", X[1], Spaces(5), X crosses over 30 ) ;
Gives:

Code: Select all

1.00 PrevValue X = 0.00 FALSE
2.00 PrevValue X = 29.00 FALSE
3.00 PrevValue X = 30.00 TRUE
4.00 PrevValue X = 31.00 FALSE
5.00 PrevValue X = 31.00 FALSE
If you remove the "X[1]" segment from the code, the output is this:

Code: Select all

1.00 PrevValue X = FALSE
2.00 PrevValue X = FALSE
3.00 PrevValue X = FALSE
4.00 PrevValue X = FALSE
5.00 PrevValue X = FALSE
I don't think this is the correct behaviour by default. Which MultiCharts version are you using? (I'm on MultiCharts Version 8.0 Release (Build 5620)).

EDIT:
Further elaboration: there seems to be a problem with "crosses over", which is equal to: (X[1] <= 30) and (X > 30). Using that code the X variable will be serialized (becoming a numerical series), but the "crosses over" reserved word doesn't do that - meaning that isn't not equal any more to the code it should represent.

I think it's a possible bug.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: cross over condition

Postby SUPER » 09 Jul 2012

JoshM,

Thanks for your detailed explanation.

I am using same version as yours.

Regards
Super

Dru
Posts: 107
Joined: 28 Aug 2007
Has thanked: 4 times
Been thanked: 171 times

Re: cross over condition

Postby Dru » 10 Jul 2012

Observation: Making changes from Auto detect to User specified does not work
It is strange, but I can't reproduce this issue at my side :-(
May be some details exists?

Dru
Posts: 107
Joined: 28 Aug 2007
Has thanked: 4 times
Been thanked: 171 times

Re: cross over condition

Postby Dru » 10 Jul 2012

EDIT:
Further elaboration: there seems to be a problem with "crosses over", which is equal to: (X[1] <= 30) and (X > 30). Using that code the X variable will be serialized (becoming a numerical series), but the "crosses over" reserved word doesn't do that - meaning that isn't not equal any more to the code it should represent.
I think it's a possible bug.
Let's imagine how the algorithm crosses works. At first glance, everything is simple - X[1] <= 30) and (X > 30).
But what about "touching"? Two, three bars duration ... ? It is when X[3]=31, X[2]=30, X[1]=30, X[0] = 31. Is this the "crossover" or not? ;-)
I think that is not crossover. The "crosses over" algorithm checks all available "history window" (MaxBB) of study for detecting "touches" and "crosses". There for MaxBB of study affects on algorithm's results.
When you have accessed to X with barsback, you have activated auto-MaxBB mechanism and your study was have calculated with MaxBB = 6. That was enough for "crosses over" proper works.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: cross over condition

Postby SUPER » 10 Jul 2012

Observation: Making changes from Auto detect to User specified does not work
It is strange, but I can't reproduce this issue at my side :-(
May be some details exists?

Code: Select all

variables:
x( 0 ) ;

if CurrentBar = 1 then
X = 29 ;

if CurrentBar = 2 then
X = 30 ;

if CurrentBar = 3 then
X = 31 ;

if CurrentBar <=5 then
print ( CurrentBar, X crosses above 30 ) ;

Please try this setps on above code and let me know.

Step 1: Try this code on any chart as it is without changing anything in indicator properties-observe print results.( by default the Max Number of bars the study will refer is set to Auto)

Step 2: Now open format indicator dialogue > Properties > change max number of bars study will refer from Auto to User Specified > OK -observe print results.

The results of both these steps will be identical

Step 3: Create a new chart and apply same indicator, format > Properties > change max numbr of bars study refer to user specified to with 50 bars > OK - observe print results

The results of Step3 are correct and different from Step1 and Step2.

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: cross over condition

Postby SP » 10 Jul 2012

Years ago there was a discussion about cross in the TS forum. The recommendation was to avoid the use of cross because it gives false results in loops and to use hard coding with
if x[1]<=y and x>y instead. Maybe "Auto detect" Maxbarsback acts as loop here.

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

Re: cross over condition

Postby JoshM » 10 Jul 2012

EDIT:
Further elaboration: there seems to be a problem with "crosses over", which is equal to: (X[1] <= 30) and (X > 30). Using that code the X variable will be serialized (becoming a numerical series), but the "crosses over" reserved word doesn't do that - meaning that isn't not equal any more to the code it should represent.
I think it's a possible bug.
Let's imagine how the algorithm crosses works. At first glance, everything is simple - X[1] <= 30) and (X > 30).
But what about "touching"? Two, three bars duration ... ? It is when X[3]=31, X[2]=30, X[1]=30, X[0] = 31. Is this the "crossover" or not? ;-)
I think that is not crossover. The "crosses over" algorithm checks all available "history window" (MaxBB) of study for detecting "touches" and "crosses". There for MaxBB of study affects on algorithm's results.
When you have accessed to X with barsback, you have activated auto-MaxBB mechanism and your study was have calculated with MaxBB = 6. That was enough for "crosses over" proper works.
I think the cross-over is limited to two bars - comparing the current bar with the previous. So the "touching" will (I assume) happen between bar 1 and 2, with the first bar lower than the second (for cross over, vice versa for cross under).

However, I don't know how the algorithm works, but the manual says (EasyLanguage Getting Started, pdf page 21):

Image

However, if this is the way it's implemented in MC8, I don't know. :)
Attachments
scr.10-07-2012 15.13.15.png
(16.88 KiB) Downloaded 3040 times

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: cross over condition

Postby SUPER » 18 Jul 2012

Please, can someone from Support provide clarification.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: cross over condition

Postby Henry MultiСharts » 19 Jul 2012

I found some strange behaviour with "Crosses Above" in same code:

Case1: set max number of bars study refers to " Auto detect", indicator fails to detect crosses.

Case2: change set max number of bars study refers to "User-Specified" to 50, it fails to detect crosses

Case3: remove old study and insurt same study again with option change set max number of bars study refers to "User-Specified" to 50, it detects crosses (Working as expected)

Observation: Making changes from Auto detect to User specified does not work
Your observation is correct. This issue will be fixed in the next version of MultiCharts.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: cross over condition

Postby Henry MultiСharts » 19 Jul 2012

However, I don't know how the algorithm works, but the manual says (EasyLanguage Getting Started, pdf page 21):
However, if this is the way it's implemented in MC8, I don't know. :)
The information in the guide was wrong. Please check the attachment to learn how it works in MultiCharts and TS.

Image

When X[3]=31, X[2]=30, X[1]=30, X[0] = 31 it is a "touch". It is not a "crossover".
Attachments
mod_scr.10-07-2012 15.13.15.png
(33.41 KiB) Downloaded 3161 times


Return to “MultiCharts”