Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Highest of past bars excluding current bar Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
john263
Posted : Wednesday, April 18, 2012 12:27:50 PM
Registered User
Joined: 10/7/2004
Posts: 26

I want to compare the current bar to the maximum (could have been minimum) of the last x bars back. The formula seemingly must exclude the current bar as the current bar is never higher than itself.

 

Can you please show me the code that would return:

(Please include any additional detailed formatting explanations that I did think to ask for, like any extra dots after RSI)

Current bar RSI14  is greater than the greatest RSI14 over the prior 4 bars (excuding the current bar).

So if the current bar RSI14 was 70, and the past 4 bars RSI14 were 68,71,66,65 then the result is false.If the current bar RSI14 was 72, then the result is true.

 

thank you

Bruce_L
Posted : Wednesday, April 18, 2012 12:44:36 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

If it is the plain RSI indicator, you could just write:

RSI14 > MAX(RSI14.1.1,4)

But if you are using the RSI - Wilder's indicator, this will not work. The MAX() function cannot accept formulas or other functions as arguments.

The Min Max PCFs topic explores how to get around this, but the formula for a 14-Period Wilder's Smoothed RSI is way too long to make that technique practical.

You can use fewer interations of RSI if you just compare the current instance to the previous four instances individually. A version of this using the plain RSI indicator would be:

RSI14 > RSI14.1.1 AND RSI14 > RSI14.1.2 AND RSI14 > RSI14.1.3 AND RSI14 > RSI14.1.4

But this ends up still be too long to be practical as the formula for a 14-Period Wilder's Smoothed RSI is quite long (this is just the RSI14 part which is duplicated four times above):

50 * (C - XAVGC27.1) / 14 / (.071435345156143 * (ABS(C - C1) + 13 / 14 * (ABS(C1 - C2) + 13 / 14 * (ABS(C2 - C3) + 13 / 14 * (ABS(C3 - C4) + 13 / 14 * (ABS(C4 - C5) + 13 / 14 * (ABS(C5 - C6) + 13 / 14 * (ABS(C6 - C7) + 13 / 14 * (ABS(C7 - C8) + 13 / 14 * (ABS(C8 - C9) + 13 / 14 * (ABS(C9 - C10) + 13 / 14 * (ABS(C10 - C11) + 13 / 14 * (ABS(C11 - C12) + 13 / 14 * (ABS(C12 - C13) + 13 / 14 * (ABS(C13 - C14) + 13 / 14 * (ABS(C14 - C15) + 13 / 14 * (ABS(C15 - C16) + 13 / 14 * (ABS(C16 - C17) + 13 / 14 * (ABS(C17 - C18) + 13 / 14 * (ABS(C18 - C19) + 13 / 14 * (ABS(C19 - C20) + 13 / 14 * (ABS(C20 - C21) + 13 / 14 * (ABS(C21 - C22) + 13 / 14 * (ABS(C22 - C23) + 13 / 14 * (ABS(C23 - C24) + 13 / 14 * (ABS(C24 - C25) + 13 / 14 * (ABS(C25 - C26) + 13 / 14 * (ABS(C26 - C27) + 13 / 14 * (ABS(C27 - C28) + 13 / 14 * (ABS(C28 - C29) + 13 / 14 * (ABS(C29 - C30) + 13 / 14 * (ABS(C30 - C31) + 13 / 14 * (ABS(C31 - C32) + 13 / 14 * (ABS(C32 - C33) + 13 / 14 * (ABS(C33 - C34) + 13 / 14 * (ABS(C34 - C35) + 13 / 14 * (ABS(C35 - C36) + 13 / 14 * (ABS(C36 - C37) + 13 / 14 * (ABS(C37 - C38) + 13 / 14 * (ABS(C38 - C39) + 13 / 14 * (ABS(C39 - C40) + 13 / 14 * (ABS(C40 - C41) + 13 / 14 * (ABS(C41 - C42) + 13 / 14 * (ABS(C42 - C43) + 13 / 14 * (ABS(C43 - C44) + 13 / 14 * (ABS(C44 - C45) + 13 / 14 * (ABS(C45 - C46) + 13 / 14 * (ABS(C46 - C47) + 13 / 14 * (ABS(C47 - C48) + 13 / 14 * (ABS(C48 - C49) + 13 / 14 * (ABS(C49 - C50) + 13 / 14 * (ABS(C50 - C51) + 13 / 14 * (ABS(C51 - C52) + 13 / 14 * (ABS(C52 - C53) + 13 / 14 * (ABS(C53 - C54) + 13 / 14 * (ABS(C54 - C55) + 13 / 14 * (ABS(C55 - C56) + 13 / 14 * (ABS(C56 - C57) + 13 / 14 * (ABS(C57 - C58) + 13 / 14 * (ABS(C58 - C59) + 13 / 14 * (ABS(C59 - C60) + 13 / 14 * (ABS(C60 - C61) + 13 / 14 * (ABS(C61 - C62) + 13 / 14 * (ABS(C62 - C63) + 13 / 14 * (ABS(C63 - C64) + 13 / 14 * (ABS(C64 - C65) + 13 / 14 * (ABS(C65 - C66) + 13 / 14 * (ABS(C66 - C67) + 13 / 14 * (ABS(C67 - C68) + 13 / 14 * (ABS(C68 - C69) + 13 / 14 * (ABS(C69 - C70) + 13 / 14 * (ABS(C70 - C71) + 13 / 14 * (ABS(C71 - C72) + 13 / 14 * (ABS(C72 - C73) + 13 / 14 * (ABS(C73 - C74) + 13 / 14 * (ABS(C74 - C75) + 13 / 14 * (ABS(C75 - C76) + 13 / 14 * (ABS(C76 - C77) + 13 / 14 * (ABS(C77 - C78) + 13 / 14 * (ABS(C78 - C79) + 13 / 14 * (ABS(C79 - C80) + 13 / 14 * (ABS(C80 - C81) + 13 / 14 * (ABS(C81 - C82) + 13 / 14 * (ABS(C82 - C83) + 13 / 14 * (ABS(C83 - C84) + 13 / 14 * (ABS(C84 - C85) + 13 / 14 * (ABS(C85 - C86) + 13 / 14 * (ABS(C86 - C87) + 13 / 14 * (ABS(C87 - C88) + 13 / 14 * (ABS(C88 - C89) + 13 / 14 * (ABS(C89 - C90) + 13 / 14 * (ABS(C90 - C91) + 13 / 14 * (ABS(C91 - C92) + 13 / 14 * (ABS(C92 - C93) + 13 / 14 * (ABS(C93 - C94) + 13 / 14 * (ABS(C94 - C95) + 13 / 14 * (ABS(C95 - C96) + 13 / 14 * (ABS(C96 - C97) + 13 / 14 * (ABS(C97 - C98) + 13 / 14 * (ABS(C98 - C99) + 13 / 14 * (ABS(C99 - C100) + 13 / 14 * (ABS(C100 - C101) + 13 / 14 * (ABS(C101 - C102) + 13 / 14 * (ABS(C102 - C103) + 13 / 14 * (ABS(C103 - C104) + 13 / 14 * (ABS(C104 - C105) + 13 / 14 * (ABS(C105 - C106) + 13 / 14 * (ABS(C106 - C107) + 13 / 14 * (ABS(C107 - C108) + 13 / 14 * (ABS(C108 - C109) + 13 / 14 * (ABS(C109 - C110) + 13 / 14 * (ABS(C110 - C111) + 13 / 14 * (ABS(C111 - C112) + 13 / 14 * (ABS(C112 - C113) + 13 / 14 * (ABS(C113 - C114) + 13 / 14 * (ABS(C114 - C115) + 13 / 14 * (ABS(C115 - C116) + 13 / 14 * (ABS(C116 - C117) + 13 / 14 * (ABS(C117 - C118) + 13 / 14 * (ABS(C118 - C119) + 13 / 14 * (ABS(C119 - C120) + 13 / 14 * (ABS(C120 - C121) + 13 / 14 * (ABS(C121 - C122) + 13 / 14 * (ABS(C122 - C123) + 13 / 14 * (ABS(C123 - C124) + 13 / 14



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
john263
Posted : Wednesday, April 18, 2012 4:56:40 PM
Registered User
Joined: 10/7/2004
Posts: 26

Bruce,

I DID really want and use Wilders Smoothed RSI (as that is what I use on my charts that works for me) so I really needed your clarification of my question.

The formula you gave seemed to answer a different question that I asked.

I want to know if the current bar is greater than ANY of the past x bars, and the formula you wrote for me seemed to say AND so my result question would not be correctly answered as your formula would require the current bar higher than ALL the past X bars rather than ANY one of them. I was also not clear about whether your formula referred to Wilders smoothed or the other RSI's that are in telechart but graph far differently.

So let me re state: Is it possible that the Wilders smoothed RSI that is available on the charts cannot be used in the conditions or easy scans users make if they try to refer back to prior values?

Or again, even using your individual day example, just so I don't miss something, can you please write for me again your specific code version that would give a T-F answer to my original question

Current bar Wilders smoothed 14 bar RSI is greater than the greatest Wilders smoothed 14 bar RSI over the prior 4 bars (excuding the current bar).

So if the current bar Wilders smoothed 14 bar RSI was 70, and the past 4 bars of Wilders smoothed 14 bar RSI were 68,71,66,65 then the result is false.If the current bar Wilders smoothed RSI was 72, then the result is true.

 

thank you again for your prior fast response

 

Bruce_L
Posted : Wednesday, April 18, 2012 5:31:52 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

QUOTE (john263)
The formula you gave seemed to answer a different question that I asked.

I want to know if the current bar is greater than ANY of the past x bars, and the formula you wrote for me seemed to say AND so my result question would not be correctly answered as your formula would require the current bar higher than ALL the past X bars rather than ANY one of them.

Your original post seems pretty clear in being exactly the opposite of what you are saying here. It even has an example which would run counter your most recent assertion as to the nature of the original request.

QUOTE (john263)
Current bar RSI14  is greater than the greatest RSI14 over the prior 4 bars (excuding the current bar).

So if the current bar RSI14 was 70, and the past 4 bars RSI14 were 68,71,66,65 then the result is false.If the current bar RSI14 was 72, then the result is true.

You are correct that that if you want it to be greater than ANY of rather than ALL of the bars you would need to change every instance of AND in the formulas to use OR instead. You would also need to change the MAX in the first formula to a MIN instead.

QUOTE (john263)
I was also not clear about whether your formula referred to Wilders smoothed or the other RSI's that are in telechart but graph far differently.

I am sorry it was not clear, but my post is explicit in pointing out that both:

RSI14 > MAX(RSI14.1.1,4)

And:

RSI14 > RSI14.1.1 AND RSI14 > RSI14.1.2 AND RSI14 > RSI14.1.3 AND RSI14 > RSI14.1.4

Are for the plain RSI indicator which is not Wilder's smoothed and not for the RSI - Wilder's indicator which is Wilder's smoothed. They will not work for the RSI - Wilder's indicator.

QUOTE (john263)
So let me re state: Is it possible that the Wilders smoothed RSI that is available on the charts cannot be used in the conditions or easy scans users make if they try to refer back to prior values?

The Personal Criteria Formula Language does not have built in syntax for most of the indicators in TC2000 version 12.1 as its syntax has not undergone any updates since its release. The language has most (but not all) of the indicators in TC2000 version 7.

The RSI which is built into the language is not Wilder's Smoothed.

The last formula in my original response is an approximation of the current value of the 14-Period Wilder's Smoothed RSI. It is possible to increment all of the bars ago parameters in the formula to get past values. But this formula is both long and slow.

QUOTE (john263)
Or again, even using your individual day example, just so I don't miss something, can you please write for me again your specific code version that would give a T-F answer to my original question

No, I can't. I do not know of a way to convert either form to work for the RSI - Wilder's indicator instead. The results are too long and slow to be practical or for me to post in the forums.

The first comparison comparison can be shortened to just:

C > C1

Because a 14-Period Wilder's Smoothed RSI will go up when price goes up and go down when price goes down.

But that would still leave three comparisons using full size 14-Period Wilder's RSI formulas. Since it takes two 14-Period Wilder's RSI formulas per comparison, we end up with a formula which is more than six times as long as the last formula given in my previous response. Such a formula is too long and slow for me to post in the forums.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
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.