Registered User Joined: 6/12/2012 Posts: 8
|
Can you give me the code for calculating yesterdays %b and yesterday's Average True Range?
Thanks.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
We would need to know all of the settings of the %b and ATR to be able to help you create an Indicator Formula for the value of the previous bar.
That said, you can add a 1-Period Simple Moving Average with an Offset of 1 to either indicator and then click on the Moving Average and select Show Values in WatchList to display the value for the previous bar as a WatchList Column without knowing the settings.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 6/12/2012 Posts: 8
|
QUOTE (Bruce_L)
We would need to know all of the settings of the %b and ATR to be able to help you create an Indicator Formula for the value of the previous bar.
That said, you can add a 1-Period Simple Moving Average with an Offset of 1 to either indicator and then click on the Moving Average and select Show Values in WatchList to display the value for the previous bar as a WatchList Column without knowing the settings.
I would like to have them configuratable. Once I have the basic script, I can modify and create 3-4 version of it for different periods. To keep it simple, let try 12,2 for %b and 12 for ATR.
Thanks.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Adding a 1-Period Simple Moving Average with an Offset of 1 to the indicators as mentioned in my first response would allow you to adjust the indicators.
Both of the Indicator Formulas you have requested need to be completely re-written to adjust the settings.
An Indicator Formula for the Simple Bollinger %b 20,2.00 of 1-bar ago could be written as:
Modelling Bollinger Bands (& Standard Deviation) in a TC PCF
(C1 - AVGC20.1) / 4 / SQR(ABS(C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 + C20 ^ 2 - 20 * AVGC20.1 ^ 2) / 20) + .5
An Indicator Formula for the 12-Period ATR of 1-bar ago could be written as:
Please provide a description and PCF for calculating an ATR value to be used as a stop loss value
(AVGH12.1 - AVGL12.1) / 2 + (ABS(H1 - C2) + ABS(C2 - L1) + ABS(H2 - C3) + ABS(C3 - L2) + ABS(H3 - C4) + ABS(C4 - L3) + ABS(H4 - C5) + ABS(C5 - L4) + ABS(H5 - C6) + ABS(C6 - L5) + ABS(H6 - C7) + ABS(C7 - L6) + ABS(H7 - C8) + ABS(C8 - L7) + ABS(H8 - C9) + ABS(C9 - L8) + ABS(H9 - C10) + ABS(C10 - L9) + ABS(H10 - C11) + ABS(C11 - L10) + ABS(H11 - C12) + ABS(C12 - L11) + ABS(H12 - C13) + ABS(C13 - L12)) / 24
PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!
-Bruce Personal Criteria Formulas TC2000 Support Articles
|