Code crashes
Author: gbullr
Creation Date: 11/24/2009 2:03 PM
profile picture

gbullr

#1
The following code crashes when the // sign is taken off of lines 60 and 61. Help.

Also can you point me the wiki or area on the sites that deals w/ trading on only certain months or within certain dates every year?

Thanks.

CODE:
Please log in to see this code.
profile picture

Cone

#2
Don't CreatePane or PlotSeries inside of loops.
profile picture

Eugene

#3
QUOTE:
Also can you point me the wiki or area on the sites that deals w/ trading on only certain months or within certain dates every year?

Scroll down to An equivalent WealthScript function can't be found, read about "Date/time".
profile picture

gbullr

#4
More problems not w/ the charting now.

I am trying to create a dataseries that stores the new 200 day high if it is 10 pct higher than the prior one.

What am I doing wrong?

Lines 41 - 44

CODE:
Please log in to see this code.
profile picture

Eugene

#5
QUOTE:
I am trying to create a dataseries that stores the new 200 day high if it is 10 pct higher than the prior one.

What's a "prior 200-day high"? I don't understand that. On the previous bar there was a new high, and then suddenly it jumped another 10%?
profile picture

gbullr

#6
This is exactly the issue.

Lets say that the most recent high is 100 and the next day the high is 102. this would NOT be a new high b/c it is not 10 pct higher than the 100. Lets say that on day 5 there is a 113 Close that would be a new High and I would like to "store" both the 100 and the 113 so that if it crosses below 100 I short.


I realize this may set me up for all sorts of problems but I can put in time defaults too so as to not get caught up in really old data.

Thanks.
profile picture

Cone

#7
1. Don't CreatePane or PlotSeries inside of loops.

2. Don't Create Series inside of loops - especially one for every bar in the chart like this statement does:
CODE:
Please log in to see this code.
Although there's only one reference do the DataSeries, diff, a different series is cached for every bar in the chart.

3. Don't PlotSeries before you actually fill it with meaningful values (you did that for both the hi and diff series).

4. You can't use the Highest.Series in your calculation to detect another high 10% higher, because that can never happen! (think about it)

5. If you're just creating a series that keeps going higher at 10% increments, the problem is very simple since you already know the values at which that will occur. You only need to find the first 200-day high, which can be done easily using the Highest.Value method.

CODE:
Please log in to see this code.

profile picture

gbullr

#8
It is not going higher all the time. when a stock goes down and makes no new high for a 200 day period I still want to know what that high is.

profile picture

Cone

#9
Then there's a big problem with the requirements. See, the problem is that you can't say "10% above the previous 200-day high" because every high before that 10% is also the 200-day high. Consequently, unless price IMMEDIATELY jumps 10% above the previous 200-day high, you can never get to 10% above it.
profile picture

gbullr

#10
I realize this and got to this problem "in my head"

Is there a way around this:

Lets say that a stock makes a 200 day high and you store this num some where. Until the next 200 day high is 10 % greater than that num then you do nothing w/ what is stored in that "storer" when a high comes along that IS 10 pct higher than the num stored in that location then you make that num the new 200dayhi and you pass the old 200day high to 200dayoldhi. W/ just two highs stored what I am trying to do would work.

Lets say that the stock falls from the 200 day high and does nothing for 250 days and then makes a new 200day high which could have no relation to the prior ones. I would need the cycle to start again.

Basically I am trying to get to a variation of a double top or a double bottom which is very easy to see in hindsight but not in real time!!
profile picture

gbullr

#11
What you sent me almost works except that if the stock goes down it does no "reset" for a 200 day high even if it is not an all time high.

profile picture

Cone

#12
Well, it's still not too clear to me, but let's say that your reset condition is when the 200-day high starts declining. Replace the gbull200 function with this one -

CODE:
Please log in to see this code.


This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).