Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Plotting a Value over a Week with Hindsight Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
RZR
Posted : Thursday, August 28, 2014 6:44:51 PM
Platinum Customer Platinum Customer

Joined: 3/19/2008
Posts: 64

Bruce I have an interesting problem I hope you can help me solve.

I am trying to plot the max value for when a particular daily condition occured, with hindsight, over a larger time period like a week. I also need help with cancellation as I will explain below.  

So for example, take something like price.close > price.maxclose(1,1) and volume.value > volume.value(1) as our condition.

If this condition passes on Monday, Wednesday and Friday on week #1, and Wednesday's close was the max of the three passes, then would like to plot a value at that close, on Week #1, inclusive of the prior days that are under the value.  Preferably using a line style set to a shape to plot over the week as opposed to an "addtooutput" script.

Said another way, this week, the value should plot Wednesday's close, but prints above Monday(2), Tuesday(1), Wednesday is pass day, Thursday(-1) and Friday(-2).  Then the reset is the next time there is a new max high.    

Not, let's say the following week, week #2, Monday is the new max value, it will plot at Monday's max value, but then if Tuesday is the new max value over Monday, Monday's signal will retroactively disappear and Tuesdays max value will plot, indicating a plotshape now for both Monday and Tuesday, at the value of Tuesday's close.  If for the duration of the week there is no max value > Tuesday's, then the Tuesday max will plot above every day that week, Monday - Friday.  

One of the challenges is I've been able to code this, mostly, but NOT so that it works in real time.  For example, if I load a chart, then the values plot correctly, but live, it will pick any high since it isn't correctly evaluating the max high among the range and not cancel previous values.

My method is to call the same symbol on a larger timeframe (weekly), then request the condition using the close parameter so it's measured daily, and then plot it against the price.high value for the larger timeframe, after it passes the daily.  This is the workaround such that I get a pass on a weekly timeframe for all bars, but only on the max value that the daily condition is passed.  As I said however, this doesn't correctly work for realtime bars.  

I appreciate any assistance and am happy to provide more detail if the above request is convulted (which I admit it is, somewhat).  Thanks again.  

 

 

 

 

RZR
Posted : Thursday, August 28, 2014 6:47:21 PM
Platinum Customer Platinum Customer

Joined: 3/19/2008
Posts: 64

"Then the reset is the next time there is a new max high"

 

Should read, "new max close, after the condition has passed"

Users browsing this topic
Guest-1

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.