logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
OrsonCarte  
#1 Posted : Saturday, April 15, 2017 6:27:51 PM(UTC)
OrsonCarte

Rank: Newbie

Groups: Registered Users, Subscribers
Joined: 3/20/2016(UTC)
Posts: 6

Thanks: 2 times

I have created a binary indicator and I want to create an exploration that will analyse the number of the various sequences of the indicator. For example, colA will display how many times the indicator fires three times in a row, colB will display how many times it fires four times in a row, etc. 

In a case where it fires four times in a row, the count of how any times it fires three times in a row should NOT be incremented.

I have used Roy's excellent Count routine to generate the indicator. When plotted on the chart, the indicator is displayed like a rising sequence of steps before being reset to zero and starting over.

In order to generate the sequence count, I have created another indicator:

Count code...... (Z=4 AND Ref(Z,+1)=0)

When I plot this indicator on my chart, it works exactly as intended and displays a +1 for each sequence of 4 in a row.

However, when I enter in the following in the Explorer colB:

Count code...... Cum((Z=4 AND Ref(Z,+1)=0))

I get N/A returned by the Explorer.

I've been gazing at this for hours. Any ideas really appreciated.

mstt  
#2 Posted : Saturday, April 15, 2017 8:29:23 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi I suggest that you check the Explorer Options number of bars setting. If Load Minimum records is set then you will get N/A results if your code does not specify a set number of periods. As an example Mov(C,10,S will ensure that at least 10 data bars will be loaded. If you were to use Mov(C,10,E) then you would get a result, but a rather inaccurate one. That's because an EMA requires up to 5 times the number of Periods used (that's the nature of an EMA, and Wilders() too). Hope this helps. Roy
thanks 1 user thanked mstt for this useful post.
OrsonCarte on 4/16/2017(UTC)
OrsonCarte  
#3 Posted : Sunday, April 16, 2017 1:07:29 PM(UTC)
OrsonCarte

Rank: Newbie

Groups: Registered Users, Subscribers
Joined: 3/20/2016(UTC)
Posts: 6

Thanks: 2 times

Hello Roy,

Many thanks for your reply. 

My test dataset consists of 20233 1-min bars. I did have the periodicity set to intraday and the Load Minimum parameter set to 20000.

However, I have found a solution.

Instead of Cum((Z=4 AND Ref(Z,+1)=0)), I tried Cum((Z=0 AND Ref(Z,-1)=4)) and it works as expected.

I am a little surprised that the Reference function with a + parameter didn't work in this case but you live and learn.

Thank you once again for your Count code and help.

wabbit  
#4 Posted : Monday, April 17, 2017 8:41:01 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
In the Explorer, you go the N/A because you used a forward reference; the Explorer returns in its results the value of the code on the last bar. Had you used something like Ref(Cum(Z=4 AND Ref(Z,+1)=0),-1) then you probably would have got the values you were looking for?? Anyway... yet another good lesson to avoid forward Ref() and to re-jig the logic to always look into the past.
OrsonCarte  
#5 Posted : Monday, April 17, 2017 11:00:10 AM(UTC)
OrsonCarte

Rank: Newbie

Groups: Registered Users, Subscribers
Joined: 3/20/2016(UTC)
Posts: 6

Thanks: 2 times

Thanks, Wabbit, that's a very good point to bear in mind.

It has also highlighted another flaw in my logic inasmuch as if a sequence is in progress on the last bar of the dataset it won't be counted because there will be no next indicator value of zero.

So, it will be necessary to amend the code to read:

LastBar:=LastValue(Cum(1))=Cum(1);* Cum(((Z=0 OR LastBar) AND Ref(Z,-1)=4))

*Thanks to Roy for that.

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.