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 |

Detrend Price Oscillator. Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
oritzbaba
Posted : Tuesday, April 16, 2013 11:51:30 AM
Registered User
Joined: 2/23/2012
Posts: 21

Dear Bruce

I am a new user of tc2000 and I would love to upgrade to stockfinder 5.0 but I need clarification on something that is very important to me; I know stockfinder can do intraday alert for an indicator like Detrend Price Oscillator crossing zero on an hourly time frame, but can the signal be conditioned to remain active for that day and/or for the next three candle bars after the condition has been met.

I have a regular job and I will only have time to do a scan maybe once or twice during the trading hours of the day.

Thanks.

Bruce_L
Posted : Tuesday, April 16, 2013 12:08:54 PM


Worden Trainer

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

You can right-click on most Conditions in StockFinder and select Edit to bring up a window where you can set X of Y bars. If you set it to 1 of 3 bars, it would return true even if the most recent time the Condition was true was 2-bars ago. Exactly how you want to set it would be up to you.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
oritzbaba
Posted : Wednesday, April 17, 2013 12:43:11 PM
Registered User
Joined: 2/23/2012
Posts: 21

Thanks, I'm sure I will find a lot of useful stuff when upgrade. 

oritzbaba
Posted : Thursday, May 2, 2013 10:36:14 AM
Registered User
Joined: 2/23/2012
Posts: 21

Hi Bruce,

Please help with adjusting a condition I created on Detrended Price Oscillator Modified crossing up through value of zero, passing 1 of last 3 bars. My challenge is that it produces stocks whose current vlaue is negative after scanning, because the condition holds true as long as 1 of the last 3 bars was positive. But I want the last value if is positive to hold true within the last 3 bars or for any of the 3 bars to be positive value.

Example: If the DPO of AAPL first  bar was positive and the next is negative, a scan for DPO crossing up through zero should not have AAPL in the result. It should report in the scan for DPO crossing down through zero.

I hope my explanation is clear enough. Please I need the code for DPO crossing UP and DOWN though zero. And also for Commodity Channel Index (CCI).

Many thanks in advance.

Bruce_L
Posted : Thursday, May 2, 2013 10:54:49 AM


Worden Trainer

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

QUOTE (oritzbaba)
If the DPO of AAPL first  bar was positive and the next is negative, a scan for DPO crossing up through zero should not have AAPL in the result. It should report in the scan for DPO crossing down through zero.

It absolutely should return true as the result if you created a condition for crossing up through zero on 1 of 3 bars. It should return true because it did cross up through zero on 1 of the 3 most recent bars. Behavior other than this would be incorrect for the condition created.

QUOTE (oritzbaba)
But I want the last value if is positive to hold true within the last 3 bars or for any of the 3 bars to be positive value.

If you just want the value to be positive, then choose Greater Than from the Condition drop-down menu when you create the condition and set the > setting to 0.0000. You would want this to be Passing 1 of last 1 bar(s).

If you also want it to have crossed up during 1 of the 3 most recent bars, then you can use your existing Crossing Up Through Value 0.0000 Condition set to Passing 1 of last 3 bar(s) as part of a Combo Condition with the Greater Than 0.0000 Condition. You can create this Combo Condition by dragging and dropping one of these two Conditions onto the other condition and selecting Create New Combo Condition. You would then need to give the Combo Condition a name and select OK.

Creating Conditions

Your other conditions can be created the same way.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
oritzbaba
Posted : Monday, May 6, 2013 9:27:08 AM
Registered User
Joined: 2/23/2012
Posts: 21

QUOTE (oritzbaba)

Dear Bruce

I am a new user of tc2000 and I would love to upgrade to stockfinder 5.0 but I need clarification on something that is very important to me; I know stockfinder can do intraday alert for an indicator like Detrend Price Oscillator crossing zero on an hourly time frame, but can the signal be conditioned to remain active for that day and/or for the next three candle bars after the condition has been met.

I have a regular job and I will only have time to do a scan maybe once or twice during the trading hours of the day.

Thanks.

 

the above quote refers; how do I include " Passing 1 of 3bars" on a Commodity Channel Index or Detrend Price Oscillator scan condition on TC2000 version 12.3. 

Please help, thanks in advance.

Bruce_L
Posted : Monday, May 6, 2013 10:53:42 AM


Worden Trainer

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

You can't. The feature is currently only available in StockFinder. It is not a generalized feature of Conditions in TC2000 version 12.3.

If you can create the Condition as a Condition Formula, you could use it in a Custom PCF % True Indicator with the Average Type set to Simple and the Period set to 3. Then you could click on the Custom PCF % True Indicator and select Create Scan Condition to check for the value being greater than 0.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
oritzbaba
Posted : Monday, May 6, 2013 3:22:12 PM
Registered User
Joined: 2/23/2012
Posts: 21

Please help me with this as I am a complete novice in it. The period parameter for the CCI and Detrend Price Oscillator is 100 and 40 respectively on the hourly time frame. Both for short/sell and long/buy scan. 

Thanks in advance.

Bruce_L
Posted : Monday, May 6, 2013 4:39:32 PM


Worden Trainer

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

A Condition Formula for a 100-Period CCI crossing up through zero:

H + L + C > AVGH100 + AVGL100 + AVGC100 AND H1 + L1 + C1 <= AVGH100.1 + AVGL100.1 + AVGC100.1

That you could just create a formula to check for this being true at least one of the three most recent bars:

(H + L + C > AVGH100 + AVGL100 + AVGC100 AND H1 + L1 + C1 <= AVGH100.1 + AVGL100.1 + AVGC100.1) OR (H1 + L1 + C1 > AVGH100.1 + AVGL100.1 + AVGC100.1 AND H2 + L2+ C2 <= AVGH100.2 + AVGL100.2 + AVGC100.2) OR (H2 + L2 + C2 > AVGH100.2 + AVGL100.2 + AVGC100.2 AND H3 + L3 + C3 <= AVGH100.3 + AVGL100.3 + AVGC100.3)

And a version where CCI must still be above zero is even shorter:

H + L + C > AVGH100 + AVGL100 + AVGC100 AND (H1 + L1 + C1 <= AVGH100.1 + AVGL100.1 + AVGC100.1 OR H2 + L2+ C2 <= AVGH100.2 + AVGL100.2 + AVGC100.2 OR H3 + L3 + C3 <= AVGH100.3 + AVGL100.3 + AVGC100.3)

But doing this for values other than zero would probably create a Condition Formula which is too long and slow to be practical or post in the forums.

CCI INDICATOR

A Formula for a 40-Period DPO crossing up through zero:

C > AVGC40.21 AND C1 <= AVGC40.22

Is also short enough that you could write a relatively short formula to check for this being true at least once out of the most recent three bars:

(C > AVGC40.21 AND C1 <= AVGC40.22) OR (C1 > AVGC40.22 AND C2 <= AVGC40.23) OR (C2 > AVGC40.23 AND C3 <= AVGC40.24)

With the version where it is still above zero again being a bit shorter:

C > AVGC40.21 AND (C1 <= AVGC40.22 OR C2 <= AVGC40.23 OR C3 <= AVGC40.24)

PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
oritzbaba
Posted : Tuesday, May 7, 2013 10:09:06 AM
Registered User
Joined: 2/23/2012
Posts: 21

Thanks Bruce, you are genius. I really appreciate your help but like Oliver Twist, I will still like for you to please help with the SHORT side of CCI and DPO while I get myself familiar with PCF formulation.

Thanks in advance.

Bruce_L
Posted : Tuesday, May 7, 2013 10:14:27 AM


Worden Trainer

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

A Condition Formula for a 100-Period CCI crossing down through zero:

H + L + C < AVGH100 + AVGL100 + AVGC100 AND H1 + L1 + C1 >= AVGH100.1 + AVGL100.1 + AVGC100.1

That you could just create a formula to check for this being true at least one of the three most recent bars:

(H + L + C < AVGH100 + AVGL100 + AVGC100 AND H1 + L1 + C1 >= AVGH100.1 + AVGL100.1 + AVGC100.1) OR (H1 + L1 + C1 < AVGH100.1 + AVGL100.1 + AVGC100.1 AND H2 + L2+ C2 >= AVGH100.2 + AVGL100.2 + AVGC100.2) OR (H2 + L2 + C2 < AVGH100.2 + AVGL100.2 + AVGC100.2 AND H3 + L3 + C3 >= AVGH100.3 + AVGL100.3 + AVGC100.3)

And a version where CCI must still be below zero is even shorter:

H + L + C < AVGH100 + AVGL100 + AVGC100 AND (H1 + L1 + C1 >= AVGH100.1 + AVGL100.1 + AVGC100.1 OR H2 + L2+ C2 >= AVGH100.2 + AVGL100.2 + AVGC100.2 OR H3 + L3 + C3 >= AVGH100.3 + AVGL100.3 + AVGC100.3)

A Formula for a 40-Period DPO crossing down through zero:

C < AVGC40.21 AND C1 >= AVGC40.22

Is also short enough that you could write a relatively short formula to check for this being true at least once out of the most recent three bars:

(C < AVGC40.21 AND C1 >= AVGC40.22) OR (C1 < AVGC40.22 AND C2 >= AVGC40.23) OR (C2 < AVGC40.23 AND C3 >= AVGC40.24)

With the version where it is still below zero again being a bit shorter:

C < AVGC40.21 AND (C1 >= AVGC40.22 OR C2 >= AVGC40.23 OR C3 >= AVGC40.24)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
oritzbaba
Posted : Tuesday, May 7, 2013 11:23:26 AM
Registered User
Joined: 2/23/2012
Posts: 21

A Condition Formula for a 100-Period CCI crossing up through zero:

H + L + C > AVGH100 - AVGL100 - AVGC100 AND H1 + L1 + C1 <= AVGH100.1 - AVGL100.1 - AVGC100.1

 

I tested the formula above and it showed a value = false. And, when I also tried it as a scan condition it did not generate any signal. I used the normal CCI in the tc2000 and it generated 6 stocks of 100-Period CCI crossing up through zero. 

Please help check for correction.

Thanks.

oritzbaba
Posted : Tuesday, May 7, 2013 11:39:14 AM
Registered User
Joined: 2/23/2012
Posts: 21

QUOTE (oritzbaba)

A Condition Formula for a 100-Period CCI crossing up through zero:

H + L + C > AVGH100 - AVGL100 - AVGC100 AND H1 + L1 + C1 <= AVGH100.1 - AVGL100.1 - AVGC100.1

 

I tested the formula above and it showed a value = false. And, when I also tried it as a scan condition it did not generate any signal. I used the normal CCI in the tc2000 and it generated 6 stocks of 100-Period CCI crossing up through zero. 

Please help check for correction.

Thanks.

Same error for CCI crossing down. Please help amend.

Many thanks.

Bruce_L
Posted : Tuesday, May 7, 2013 11:58:36 AM


Worden Trainer

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

False is not an error message. It just means the formula isn't true for the test symbol.

That said, you need to change all of the - signs in the formulas you have mentioned to + signs.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
oritzbaba
Posted : Wednesday, May 8, 2013 12:12:50 PM
Registered User
Joined: 2/23/2012
Posts: 21

You are a great help. It seems you went back to correct the formulas on your post.

Many thanks Bruce.

samantha.laduc
Posted : Thursday, May 16, 2013 4:22:39 PM
Platinum Customer Platinum Customer

Joined: 4/27/2012
Posts: 106

Hi again Bruce,

I use a 21 period Detrended Price Oscillator (DPO)  histogram w/pos and neg valuesw/an RSI 5 indicator overlayed on a daily chart. I am wanting to create the following conditions for scanning/alert purposes:

1. RSI is <30 OR >70 (there is a way to create either or but I want to filter for the combined)

2. RSI is crossing up through 0 of the DPO

3. RSI is crossing down through 0 of the DPO

4. RSI is crossing up/down through 0 of the DPO

This would be VERY helpful to me.

Thank you!!

Bruce_L
Posted : Thursday, May 16, 2013 4:30:46 PM


Worden Trainer

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

Is this a StockFinder question (it is in a StockFinder forum)?

DPO and RSI are not on the same scale. Is your DPO centered on zero?

Is the RSI a plain RSI indicator without Wilder's Smoothing or a Wilder's Smoothed RSI?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
samantha.laduc
Posted : Thursday, May 16, 2013 5:17:46 PM
Platinum Customer Platinum Customer

Joined: 4/27/2012
Posts: 106

I use version 12.3. I simply found the thread on DPO. Forgive me.

Correct, DPO and RSI are not scaled together, which is how I want it.

Yes, DPO is centered on 0. And RSI is plain--no smoothing. 

I vary the period of RSI, however, but if you need a static period, please use 5.

 

Bruce_L
Posted : Thursday, May 16, 2013 5:24:47 PM


Worden Trainer

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

There is nothing to forgive, I just didn't know if I needed to create a solution for StockFinder or TC2000.

QUOTE (samantha.laduc)
RSI is <30 OR >70 (there is a way to create either or but I want to filter for the combined)

You could write this as:

RSI5 < 30 OR RSI5 > 70

Or as:

ABS(RSI5 - 50) > 20

QUOTE (samantha.laduc)
RSI is crossing up through 0 of the DPO

RSI5 > 50 AND RSI5.1.1 <= 50

QUOTE (samantha.laduc)
RSI is crossing down through 0 of the DPO

RSI5 < 50 AND RSI5.1.1 >= 50

QUOTE (samantha.laduc)
RSI is crossing up/down through 0 of the DPO

SGN(RSI5 - 50) <> SGN(RSI5.1.1 - 50)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
samantha.laduc
Posted : Thursday, May 16, 2013 6:16:13 PM
Platinum Customer Platinum Customer

Joined: 4/27/2012
Posts: 106

So great.

Bruce, you make trading fun. 

samantha.laduc
Posted : Thursday, May 16, 2013 10:04:40 PM
Platinum Customer Platinum Customer

Joined: 4/27/2012
Posts: 106

At some point, maybe you could check the RSI settings crossing through DPO. I want it to cross through 0, and there are a bunch getting included in the scan that don't qualify: ARUN, IBM, MUR to name a few. Thank you for checking!

Bruce_L
Posted : Friday, May 17, 2013 7:57:42 AM


Worden Trainer

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

It should be crossing through zero if DPO is centered on zero, because the zero line of the DPO would be plotted at the same place as the 50 line of the RSI.

If the DPO is not centered on zero (the zero line actually moves relative to the center of the pane), there there is no way to do this in TC2000. In fact, in such cases, the crossovers are completely and totally meaningless. They will actually change with scroll and zoom.

To check if DPO is centered on zero (and change it if it isn't), click on DPO and select Scaling.... The Scale Method needs to be Center on 0.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
samantha.laduc
Posted : Thursday, May 23, 2013 11:17:29 PM
Platinum Customer Platinum Customer

Joined: 4/27/2012
Posts: 106

I have the DPO overlayed w/RSI 5 and like when both are automatically scaled as it shows the overbought/oversold  areas as well as 0 crossovers which forecast price direction/divergences. But even if centered on 0, the results come back incorrect from the scan: many do not have the RSI 5 crossing up/down through 0 of DPO. For one, the 50 line of RSI is not lined up w/0, regardless of scaling. 

What next...?

--
Samantha

Bruce_L
Posted : Friday, May 24, 2013 8:18:08 AM


Worden Trainer

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

It did not occur to me that you would have changed the Scale Method of RSI from its default setting of 0 to 100 to something else. It is only when the Scale Method of RSI is set to 0 to 100 and the Scale Method of DPO is set to Center on Zero (or -100 to 100) that the 50 line of RSI and the 0 line of DPO will line up.

The same caveats about the crossovers being completely meaningless applies when the scaling used changes for either indicator. Scroll and zoom will affect the crossovers as will simple things like new data coming in throughout the day.

In fact, even having a 0 to 100 Scale Method for RSI and a Center on Zero Scale Method for DPO does not prevent the crossovers of the indicators from being meaningless as the Center on Zero scaling will change based on scroll and zoom. The only reason that these specific scalings allow the creation of the Condition for crossing through 50 is the special relationship between 50 and 0 in this scalings. Crossovers of the indicators themselves or for any other values cannot be calculated and remain meaningless.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ppod
Posted : Wednesday, July 3, 2013 3:29:38 PM
Registered User
Joined: 7/2/2013
Posts: 5

Hey Bruce,Beginner - where do I start? I want to backtest SPY, 15 minute, to see what my results are .I use a price pattern &  2 simple MA crossovers. my SimpleMA ARE as follows: first one is a 3MA uses the close, blue & the second is 2MA of the 3MA, red. Which I have plotted on my chart.And my price pattern setup - if bar(1) open is > bar (1) close and if bar (2) open< bar (2) close AND 3MA blue is on TOP of 2MA red, then buy the breakout of the high of bar(2) +.01. Exit trade either bar(2) high entry +.25(win) or bar (2) high - .25 (stopped out). Now thats english - but how do I now write that? I am confused as to where to begin.1) this setup can occur at any point in the day.2) I do not use yesterdays closing bar and todays opening bar as a setup.3) once pattern occurs I only take that setup and go flat,  I do not take any others during the day.just want to backtest bu teasy language etc... see nothing maybe too adavnced for me?

Bruce_L
Posted : Wednesday, July 3, 2013 4:36:20 PM


Worden Trainer

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

Assuming bar (1) comes chronologically before bar (2), we can detect your two bar pattern using the following Condition Formula:

O1 > C1 AND O < C AND AVGC3 > AVG(AVGC3,2)

That said, TC2000 does not have any built in backtesting features (StockFinder uses BackScanner for this). There is no way to buy when price is first at .01 above the high of the bar where the Condition Formula was true or exit after price goes up or down .25 from the entry.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ppod
Posted : Friday, July 5, 2013 10:10:26 AM
Registered User
Joined: 7/2/2013
Posts: 5

Bruce - thanks - 1) Ok I hav estockfinder  becasuse they said TC 2000 not the right one.2) How to write that formula into Stockfinder as you wrote above BUTTTT are you saying I will not be able to backtest because I cannot add a entry formula line in? All I want to do is test my idea - backtest it, bu thave the entry as stated and then upon entry exit after .25 profit. SO in a nutshell - stockfinder cannot perform this for me? Thanks so much.

Bruce_L
Posted : Friday, July 5, 2013 10:43:26 AM


Worden Trainer

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

You can backtest in StockFinder using BackScanner. You could create a RealCode Condition for the Entry Condition as:

Writing Conditions in RealCode
RealCode Reference
RealCode API

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Entry Condition
'|******************************************************************
Static Setup As Single
Static Valid As Boolean
If isFirstBar Then
	Setup = Single.NaN
	Valid = False
End If
If Price.AVGC(3) > Price.MovingAverage(3).AVGC(2) AndAlso _
	Price.Open(1) > Price.Last(1) AndAlso _
	Price.Open < Price.Last Then
	Setup = Price.High
	Valid = True
End If
If Valid = True Then
	If Price.High > Setup Then
		Pass
		Setup = Single.NaN
	End If
Else
	SetIndexInvalid
End If

Once you have created the Condition, you can click on Open New BackScan (the icon looks like flames) to bring up BackScanner. You can drag and drop the Condition from the chart into the Rules tab of BackScanner and select Buy to use it as a long entry condition.

It is at this point that we should run into our first problem. You can only enter on the open, high, low, close or mid-point of the bar specified in the Buy Rule. So we could enter at the high of the current bar by entering at the high 0 bars from now, but not the high of setup bar + .01.

For the Exits, we can select Add Trade-Based Rule in the Rules tab of BackScanner and choose a Stop Loss Rule and a Profit Target Rule, but this is where we will run into our second problem. We can specify a percent gain or loss, but we cannot specify a net gain or loss in dollars. In addition, these Exit rules will have the same problem mentioned before in that you can only exit on the open, high, low, close or mid point of the bar specified in the Exit Rule.

So we can kind of create your strategy in BackScanner, but only if we enter at something other than the high of the setup bar + .01 and exit based on percentages from the entry instead of net changes from the entry with both the entry and exits happening on the open, high, low, close or mid point of a bar.

BackScanner Video Tour
BackScanner PDF Workbook



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ppod
Posted : Friday, July 5, 2013 11:18:48 AM
Registered User
Joined: 7/2/2013
Posts: 5

Thanks Bruce. So- I understand what you are saying, is there any way for the program to recognize the high of bar 1 or the high of the last bar and enter that into memory and then do an addition equation of high + .01 to come up with a value and then set a trigger if that value is hit as my entry.

Bruce_L
Posted : Friday, July 5, 2013 11:23:15 AM


Worden Trainer

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

No, there is no way to do so. BackScanner can only execute trades on the open, high, low, close or mid point of the bar specified in the BackScanner Rule.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ppod
Posted : Friday, July 5, 2013 11:29:02 AM
Registered User
Joined: 7/2/2013
Posts: 5

Ok. Thanks. I am happy that we gave it a try. Do you think by any chance easy language with tradestation might be able to do something like this? It appears that stockfinder can identify my pattern but does not have the capability of giving me my entry and exit for an accurate backtest. If you have any other thoughts let me know, I'd much appreciate it.

Bruce_L
Posted : Friday, July 5, 2013 11:34:03 AM


Worden Trainer

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

It may be able to do so, but I have not worked with Tradestation's Easy Language beyond converting it for use in TC2000 or StockFinder. It is a third party product for which I do not have enough knowledge to give you useful information.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
ppod
Posted : Friday, July 5, 2013 11:41:20 AM
Registered User
Joined: 7/2/2013
Posts: 5

Thanks again Bruce.

caution
Posted : Monday, July 22, 2013 1:01:02 PM
Registered User
Joined: 5/5/2010
Posts: 185

Bruce,

This is a tradestation easy language code, can you translate to RealCode?  Or is there a thread that might be helpful.

thanks...

 

Better Volume Indicator

 

Inputs:  LowVol(True), ClimaxUp(True), ClimaxDown(True), Churn(True), ClimaxChurn(False), LowVolColor(Yellow), ClimaxUpColor(Red), ClimaxDownColor(White), ChurnColor(Green), ClimaxChurnColor(Magenta), Color(Cyan), UseUpTicks(True), Use2Bars(True), ShowAvg(False), AvgColor(Red);

Variables:  BarColor(Cyan), Lookback(20);

 

BarColor = Color;

 

If BarType > 1 then begin

          If C > O and Range <> 0 then Value1 = (Range/(2*Range+O-C))*V;

          If C < O and Range <> 0 then Value1 = ((Range+C-O)/(2*Range+C-O))*V;

          If C = O then Value1 = 0.5*V;

          Value2 = V-Value1;

End;

If BarType <= 1 and UseUpTicks = False then begin

          If C > O and Range <> 0 then Value1 = (Range/(2*Range+O-C))*Ticks;

          If C < O and Range <> 0 then Value1 = ((Range+C-O)/(2*Range+C-O))*Ticks;

          If C = O then Value1 = 0.5*Ticks;

          Value2 = Ticks-Value1;

End;

If BarType <= 1 and UseUpTicks then begin

          Value1 = UpTicks;

          Value2 = DownTicks;

End;

 

Value3 = AbsValue(Value1+Value2);

Value4 = Value1*Range;

Value5 = (Value1-Value2)*Range;

Value6 = Value2*Range;

Value7 = (Value2-Value1)*Range;

If Range <> 0 then begin

          Value8 = Value1/Range;

          Value9 = (Value1-Value2)/Range;

          Value10 = Value2/Range;

          Value11 = (Value2-Value1)/Range;

          Value12 = Value3/Range;

End;

If Use2Bars then begin

          Value13 = Value3+Value3[1];

          Value14 = (Value1+Value1[1])*(Highest(H,2)-Lowest(L,2));

          Value15 = (Value1+Value1[1]-Value2-Value2[1])*(Highest(H,2)-Lowest(L,2));

          Value16 = (Value2+Value2[1])*(Highest(H,2)-Lowest(L,2));

          Value17 = (Value2+Value2[1]-Value1-Value1[1])*(Highest(H,2)-Lowest(L,2));

          If Highest(H,2) <> Lowest(L,2) then begin

                   Value18 = (Value1+Value1[1])/(Highest(H,2)-Lowest(L,2));

                   Value19 = (Value1+Value1[1]-Value2-Value2[1])/(Highest(H,2)-Lowest(L,2));

                   Value20 = (Value2+Value2[1])/(Highest(H,2)-Lowest(L,2));

                   Value21 = (Value2+Value2[1]-Value1-Value1[1])/(Highest(H,2)-Lowest(L,2));

                   Value22 = Value13/(Highest(H,2)-Lowest(L,2));

          End;

End;

 

Condition1 = Value3 = Lowest(Value3,Lookback);

Condition2 = Value4 = Highest(Value4,Lookback) and C > O;

Condition3 = Value5 = Highest(Value5,Lookback) and C > O;

Condition4 = Value6 = Highest(Value6,Lookback) and C < O;

Condition5 = Value7 = Highest(Value7,Lookback) and C < O;

Condition6 = Value8 = Lowest(Value8,Lookback) and C < O;

Condition7 = Value9 = Lowest(Value9,Lookback) and C < O;

Condition8 = Value10 = Lowest(Value10,Lookback) and C > O;

Condition9 = Value11 = Lowest(Value11,Lookback) and C > O;

Condition10 = Value12 = Highest(Value12,Lookback);

If Use2Bars then begin

          Condition11 = Value13 = Lowest(Value13,Lookback);

          Condition12 = Value14 = Highest(Value14,Lookback) and C > O and C[1] > O[1];

          Condition13 = Value15 = Highest(Value15,Lookback) and C > O and C[1] > O[1];

          Condition14 = Value16 = Highest(Value16,Lookback) and C < O and C[1] < O[1];

          Condition15 = Value17 = Highest(Value17,Lookback) and C < O and C[1] < O[1];

          Condition16 = Value18 = Lowest(Value18,Lookback) and C < O and C[1] < O[1];

          Condition17 = Value19 = Lowest(Value19,Lookback) and C < O and C[1] < O[1];

          Condition18 = Value20 = Lowest(Value20,Lookback) and C > O and C[1] > O[1];

          Condition19 = Value21 = Lowest(Value21,Lookback) and C > O and C[1] > O[1];

          Condition20 = Value22 = Highest(Value22,Lookback);

End;

 

If BarType > 1 then begin

          If LowVol and (Condition1 or Condition11) then BarColor = LowVolColor;

          If ClimaxUp and (Condition2 or Condition3 or Condition8 or Condition9 or Condition12 or Condition13 or Condition18 or Condition19) then BarColor = ClimaxUpColor;

          If ClimaxDown and (Condition4 or Condition5 or Condition6 or Condition7 or Condition14 or Condition15 or Condition16 or Condition17) then BarColor = ClimaxDownColor;

          If Churn and (Condition10 or Condition20) then BarColor = ChurnColor;

          If ClimaxChurn and (Condition10 or Condition20) and (Condition2 or Condition3 or Condition4 or Condition5 or Condition6 or Condition7 or Condition8 or Condition9 or

                   Condition12 or Condition13 or Condition14 or Condition15 or Condition16 or Condition17 or Condition18 or Condition19) then BarColor = ClimaxChurnColor;

End;

 

If BarType <= 1 then begin

          If LowVol and (Condition1 or (Condition11 and D=D[1])) then BarColor = LowVolColor;

          If ClimaxUp and (Condition2 or Condition3 or Condition8 or Condition9 or ((Condition12 or Condition13 or Condition18 or Condition19) and D=D[1])) then BarColor = ClimaxUpColor;

          If ClimaxDown and (Condition4 or Condition5 or Condition6 or Condition7 or ((Condition14 or Condition15 or Condition16 or Condition17) and D=D[1])) then BarColor = ClimaxDownColor;

          If Churn and (Condition10 or (Condition20 and D=D[1])) then BarColor = ChurnColor;

          If ClimaxChurn and (Condition10 or (Condition20 and D=D[1])) and (Condition2 or Condition3 or Condition4 or Condition5 or Condition6 or Condition7 or Condition8 or Condition9 or

                   ((Condition12 or Condition13 or Condition14 or Condition15 or Condition16 or Condition17 or Condition18 or Condition19) and D=D[1])) then BarColor = ClimaxChurnColor;

End;

 

Plot1(Value3,"Volume",BarColor);

If ShowAvg then Plot2(Average(Value3,200),"Avg",AvgColor);

 

{ Change Log: }

{23 November 2007 - Added LowChurn colored volume bars                      }

{19 April 2008 - Got rid of LowChurn and replaced with ClimaxDown           }

{19 April 2008 - Added open & close conditions with ClimaxUp and ClimaxDown }

{19 April 2008 - Added different calculations for tick/intra-day charts     }

{26 June 2008 - Added ability to turn average volume line on and off        }

{5 July 2008 - Changed Lookback from a variable to an input                 }

{13 July 2008 - Added 2 bar climax, churn and low volume conditions         }

{4 September 2008 - Changed daily bars calculation to match tick/intra-day  }

{25 January 2009 - Added condition total volume (Value3) could not be -ve   }

{19 August 2012 - Changed calculation for Intra-day + UseUpTicks = False    }

 

 

 

Better Volume PaintBar

 

Inputs:  LowVol(True), ClimaxUp(True), ClimaxDown(True), Churn(True), ClimaxChurn(False), LowVolColor(Yellow), ClimaxUpColor(Red), ClimaxDownColor(White), ChurnColor(Blue), ClimaxChurnColor(Magenta), Color(Green), UseUpTicks(True), Use2Bars(True);

Variables:  BarColor(Green), Lookback(20);

 

BarColor = Color;

 

If BarType > 1 then begin

          If C > O and Range <> 0 then Value1 = (Range/(2*Range+O-C))*V;

          If C < O and Range <> 0 then Value1 = ((Range+C-O)/(2*Range+C-O))*V;

          If C = O then Value1 = 0.5*V;

          Value2 = V-Value1;

End;

If BarType <= 1 and UseUpTicks = False then begin

          If C > O and Range <> 0 then Value1 = (Range/(2*Range+O-C))*Ticks;

          If C < O and Range <> 0 then Value1 = ((Range+C-O)/(2*Range+C-O))*Ticks;

          If C = O then Value1 = 0.5*Ticks;

          Value2 = Ticks-Value1;

End;

If BarType <= 1 and UseUpTicks then begin

          Value1 = UpTicks;

          Value2 = DownTicks;

End;

 

Value3 = AbsValue(Value1+Value2);

Value4 = Value1*Range;

Value5 = (Value1-Value2)*Range;

Value6 = Value2*Range;

Value7 = (Value2-Value1)*Range;

If Range <> 0 then begin

          Value8 = Value1/Range;

          Value9 = (Value1-Value2)/Range;

          Value10 = Value2/Range;

          Value11 = (Value2-Value1)/Range;

          Value12 = Value3/Range;

End;

If Use2Bars then begin

          Value13 = Value3+Value3[1];

          Value14 = (Value1+Value1[1])*(Highest(H,2)-Lowest(L,2));

          Value15 = (Value1+Value1[1]-Value2-Value2[1])*(Highest(H,2)-Lowest(L,2));

          Value16 = (Value2+Value2[1])*(Highest(H,2)-Lowest(L,2));

          Value17 = (Value2+Value2[1]-Value1-Value1[1])*(Highest(H,2)-Lowest(L,2));

          If Highest(H,2) <> Lowest(L,2) then begin

                   Value18 = (Value1+Value1[1])/(Highest(H,2)-Lowest(L,2));

                   Value19 = (Value1+Value1[1]-Value2-Value2[1])/(Highest(H,2)-Lowest(L,2));

                   Value20 = (Value2+Value2[1])/(Highest(H,2)-Lowest(L,2));

                   Value21 = (Value2+Value2[1]-Value1-Value1[1])/(Highest(H,2)-Lowest(L,2));

                   Value22 = Value13/(Highest(H,2)-Lowest(L,2));

          End;

End;

 

Condition1 = Value3 = Lowest(Value3,Lookback);

Condition2 = Value4 = Highest(Value4,Lookback) and C > O;

Condition3 = Value5 = Highest(Value5,Lookback) and C > O;

Condition4 = Value6 = Highest(Value6,Lookback) and C < O;

Condition5 = Value7 = Highest(Value7,Lookback) and C < O;

Condition6 = Value8 = Lowest(Value8,Lookback) and C < O;

Condition7 = Value9 = Lowest(Value9,Lookback) and C < O;

Condition8 = Value10 = Lowest(Value10,Lookback) and C > O;

Condition9 = Value11 = Lowest(Value11,Lookback) and C > O;

Condition10 = Value12 = Highest(Value12,Lookback);

If Use2Bars then begin

          Condition11 = Value13 = Lowest(Value13,Lookback);

          Condition12 = Value14 = Highest(Value14,Lookback) and C > O and C[1] > O[1];

          Condition13 = Value15 = Highest(Value15,Lookback) and C > O and C[1] > O[1];

          Condition14 = Value16 = Highest(Value16,Lookback) and C < O and C[1] < O[1];

          Condition15 = Value17 = Highest(Value17,Lookback) and C < O and C[1] < O[1];

          Condition16 = Value18 = Lowest(Value18,Lookback) and C < O and C[1] < O[1];

          Condition17 = Value19 = Lowest(Value19,Lookback) and C < O and C[1] < O[1];

          Condition18 = Value20 = Lowest(Value20,Lookback) and C > O and C[1] > O[1];

          Condition19 = Value21 = Lowest(Value21,Lookback) and C > O and C[1] > O[1];

          Condition20 = Value22 = Highest(Value22,Lookback);

End;

 

If BarType > 1 then begin

          If LowVol and (Condition1 or Condition11) then BarColor = LowVolColor;

          If ClimaxUp and (Condition2 or Condition3 or Condition8 or Condition9 or Condition12 or Condition13 or Condition18 or Condition19) then BarColor = ClimaxUpColor;

          If ClimaxDown and (Condition4 or Condition5 or Condition6 or Condition7 or Condition14 or Condition15 or Condition16 or Condition17) then BarColor = ClimaxDownColor;

          If Churn and (Condition10 or Condition20) then BarColor = ChurnColor;

          If ClimaxChurn and (Condition10 or Condition20) and (Condition2 or Condition3 or Condition4 or Condition5 or Condition6 or Condition7 or Condition8 or Condition9 or

                   Condition12 or Condition13 or Condition14 or Condition15 or Condition16 or Condition17 or Condition18 or Condition19) then BarColor = ClimaxChurnColor;

End;

 

If BarType <= 1 then begin

          If LowVol and (Condition1 or (Condition11 and D=D[1])) then BarColor = LowVolColor;

          If ClimaxUp and (Condition2 or Condition3 or Condition8 or Condition9 or ((Condition12 or Condition13 or Condition18 or Condition19) and D=D[1])) then BarColor = ClimaxUpColor;

          If ClimaxDown and (Condition4 or Condition5 or Condition6 or Condition7 or ((Condition14 or Condition15 or Condition16 or Condition17) and D=D[1])) then BarColor = ClimaxDownColor;

          If Churn and (Condition10 or (Condition20 and D=D[1])) then BarColor = ChurnColor;

          If ClimaxChurn and (Condition10 or (Condition20 and D=D[1])) and (Condition2 or Condition3 or Condition4 or Condition5 or Condition6 or Condition7 or Condition8 or Condition9 or

                   ((Condition12 or Condition13 or Condition14 or Condition15 or Condition16 or Condition17 or Condition18 or Condition19) and D=D[1])) then BarColor = ClimaxChurnColor;

End;

 

If BarColor <> Color then PlotPaintBar(H,L,O,C,"BetterVol",BarColor);

 

{ Change Log: }

{23 November 2007 - Added LowChurn colored volume bars                      }

{28 March 2008 - Added ability to turn on and off different colored bars    }

{28 March 2008 - Got rid of redundant code calculations                     }

{19 April 2008 - Got rid of LowChurn and replaced with ClimaxDown           }

{19 April 2008 - Added open & close conditions with ClimaxUp and ClimaxDown }

{19 April 2008 - Added different calculations for tick/intra-day charts     }

{13 July 2008 - Added 2 bar climax, churn and low volume conditions         }

{4 September 2008 - Changed daily bars calculation to match tick/intra-day  }

{25 January 2009 - Added condition total volume (Value3) could not be -ve   }

{3 July 2009 - Allowed the default bar coloring to be changed               }

{19 August 2012 - Changed calculation for Intra-day + UseUpTicks = False    }

 

Bruce_L
Posted : Tuesday, July 23, 2013 11:50:42 AM


Worden Trainer

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

Please keep in mind I am not a programmer. I am not familiar with EasyLanguage. The RealCode provided is just a guess at the intent of the code provided.

The attached RealCode Indicator with RealCode Paint Scheme assumes LowVol = True, ClimaxUp = True, ClimaxDown = True, Churn = True, ClimaxChurn = True, LowVolColor = Yellow, ClimaxUpColor = Red, ClimaxDownColor = White, ChurnColor = Blue, ClimaxChurnColo = Magenta, Color = Green, Use2Bars = False and Lookback = 20. Since there isn't enough tick data available for these calculations, no tick based data is used and no tick based calculations are attempted.

You should be able to Open an attached Indicator directly into a running copy of StockFinder 5 (and save it from within StockFinder 5 if desired). You could also Save it to the \My Documents\StockFinder5\(Your Username)\My Indicators\ folder and then load it like you would any other Indicator (or Copy and Paste it there from wherever it Saves if you can't specify the destination directory when Saving).

Attachments:
Better Volume.sfIndRC - 14 KB, downloaded 943 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
caution
Posted : Tuesday, July 23, 2013 1:51:47 PM
Registered User
Joined: 5/5/2010
Posts: 185

works great,

Thanks

caution
Posted : Tuesday, November 26, 2013 11:21:17 AM
Registered User
Joined: 5/5/2010
Posts: 185

Bruce,

Is it possible to write a condition based on the above real code paint scheme?

thanks.

Bruce_L
Posted : Tuesday, November 26, 2013 11:59:21 AM


Worden Trainer

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

The following RealCode Condition should return true when Better Volume is painted green.

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Better Volume Green
'|******************************************************************
'# Cumulative
Dim Color As Integer = 0
'0 = Green
'1 = Yellow
'2 = Red
'3 = White
'4 = Blue
'5 = Magenta
Static Value3 As New List(Of Single)
Static Value4 As New List(Of Single)
Static Value5 As New List(Of Single)
Static Value6 As New List(Of Single)
Static Value7 As New List(Of Single)
Static Value8 As New List(Of Single)
Static Value9 As New List(Of Single)
Static Value10 As New List(Of Single)
Static Value11 As New List(Of Single)
Static Value12 As New List(Of Single)
If isFirstBar Then
	Value3.Clear
	Value4.Clear
	Value5.Clear
	Value6.Clear
	Value7.Clear
	Value8.Clear
	Value9.Clear
	Value10.Clear
	Value11.Clear
	Value12.Clear
End If
Dim Value1 As Single = Volume.Value / 2
If Price.Last > Price.Open Then
	Value1 = (Price.TradeRange / (2 * Price.TradeRange + Price.Open - Price.Last)) * Volume.Value
Else If Price.Last < Price.Open Then
	Value1 = ((Price.TradeRange + Price.Last - Price.Open) / (2 * Price.TradeRange + Price.Last - Price.Open)) * Volume.Value
End If
Dim Value2 As Single = Volume.Value - Value1
Value3.Insert(0, System.Math.Abs(Value1 + Value2))
Value4.Insert(0, Value1 * Price.TradeRange)
Value5.Insert(0, (Value1 - Value2) * Price.TradeRange)
Value6.Insert(0, Value2 * Price.TradeRange)
Value7.Insert(0, (Value2 - Value1) * Price.TradeRange)
If Price.TradeRange <> 0 Then
	Value8.Insert(0, Value1 / Price.TradeRange)
	Value9.Insert(0, (Value1 - Value2) / Price.TradeRange)
	Value10.Insert(0, Value2 / Price.TradeRange)
	Value11.Insert(0, (Value2 - Value1) / Price.TradeRange)
	Value12.Insert(0, Value3(0) / Price.TradeRange)
Else
	Value8.Insert(0, Single.MaxValue)
	Value9.Insert(0, Single.MaxValue)
	Value10.Insert(0, Single.MaxValue)
	Value11.Insert(0, Single.MaxValue)
	Value12.Insert(0, Single.MaxValue)
End If
If CurrentIndex > 0 Then
	Dim Condition1 As Boolean = True
	Dim Condition2 As Boolean = True
	Dim Condition3 As Boolean = True
	Dim Condition4 As Boolean = True
	Dim Condition5 As Boolean = True
	Dim Condition6 As Boolean = True
	Dim Condition7 As Boolean = True
	Dim Condition8 As Boolean = True
	Dim Condition9 As Boolean = True
	Dim Condition10 As Boolean = True
	For i As Integer = 1 To System.Math.Min(20, Value3.Count - 1)
		If Value3(0) > Value3(i) Then
			Condition1 = False
			Exit For
		End If
	Next
	For i As Integer = 1 To System.Math.Min(20, Value12.Count - 1)
		If Value10(0) < Value10(i) Then
			Condition10 = False
			Exit For
		End If
	Next
	If Price.Last > Price.Open Then
		For i As Integer = 1 To System.Math.Min(20, Value4.Count - 1)
			If Value4(0) < Value4(i) Then
				Condition2 = False
				Exit For
			End If
		Next
		For i As Integer = 1 To System.Math.Min(20, Value5.Count - 1)
			If Value5(0) < Value5(i) Then
				Condition3 = False
				Exit For
			End If
		Next
		For i As Integer = 1 To System.Math.Min(20, Value10.Count - 1)
			If Value10(0) > Value10(i) Then
				Condition8 = False
				Exit For
			End If
		Next
		For i As Integer = 1 To System.Math.Min(20, Value11.Count - 1)
			If Value11(0) > Value11(i) Then
				Condition9 = False
				Exit For
			End If
		Next
	Else
		Condition2 = False
		Condition3 = False
		Condition8 = False
		Condition9 = False
	End If
	If Price.Last < Price.Open Then
		For i As Integer = 1 To System.Math.Min(20, Value6.Count - 1)
			If Value6(0) < Value6(i) Then
				Condition4 = False
				Exit For
			End If
		Next
		For i As Integer = 1 To System.Math.Min(20, Value7.Count - 1)
			If Value7(0) < Value7(i) Then
				Condition5 = False
				Exit For
			End If
		Next
		For i As Integer = 1 To System.Math.Min(20, Value8.Count - 1)
			If Value8(0) > Value8(i) Then
				Condition6 = False
				Exit For
			End If
		Next
		For i As Integer = 1 To System.Math.Min(20, Value9.Count - 1)
			If Value9(0) > Value9(i) Then
				Condition7 = False
				Exit For
			End If
		Next
	Else
		Condition4 = False
		Condition5 = False
		Condition6 = False
		Condition7 = False
	End If
	If Condition1 OrElse Condition2 Then Color = 1
	If Condition2 OrElse Condition3 OrElse Condition8 OrElse Condition9 Then Color = 2
	If Condition4 OrElse Condition5 OrElse Condition6 OrElse Condition7 Then Color = 3
	If Condition10 Then Color = 4
	If Condition10 AndAlso (Condition2 OrElse Condition3 OrElse Condition4 OrElse Condition5 OrElse _
		Condition6 OrElse Condition7 OrElse Condition8 OrElse Condition9) Then Color = 5
	If Color = 0 Then Pass
	'0 = Green
	'1 = Yellow
	'2 = Red
	'3 = White
	'4 = Blue
	'5 = Magenta
End If
If isLastBar Then
	Value3.Clear
	Value4.Clear
	Value5.Clear
	Value6.Clear
	Value7.Clear
	Value8.Clear
	Value9.Clear
	Value10.Clear
	Value11.Clear
	Value12.Clear
End If

You can change the following line:

	If Color = 0 Then Pass

To change what color is being checked in the RealCode Condition. The comments right below this line outline what number corresponds to what color.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
caution
Posted : Tuesday, November 26, 2013 12:48:33 PM
Registered User
Joined: 5/5/2010
Posts: 185

Thanks.

caution
Posted : Wednesday, December 23, 2015 1:34:30 PM
Registered User
Joined: 5/5/2010
Posts: 185

Bruce,

The above condition does not show a signal for red bars at 4pm on hourly chart.

reference:  $VLO, 12/3/15 and 12/10/15 also $GS, 12/3/15 and 12/10/15....

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.