Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 6/23/2006 Posts: 30
|
Dear Worden support team,
I'm currently using TC2007 and I would like to create a custom indicator such like the following.
Plot custom indicator "PivotHigh" and "PivotLow" along price bar under condition: Toggle=1 ( one time only)
1) If H2<H1 AND H1<H and toggle = -1 Then PivotHigh=H, toggle=toggle*-1 else PivotHigh=PivotHigh.1 2) If L2>L1 AND L1<L and toggle = 1 Then PivotLow=L , toggle=toggle*-1 else PivotLow=PivotLow.1
It's kind of condition if-then-else indicator and I look at sample PCF but can't not find things that give some ideas how to write it. May be you could give some advise.
|
|
Registered User Joined: 1/28/2005 Posts: 6,049
|
If I understand what you are asking. (the second set of indicators is probably what you are looking for)
I am making the assumption there was an error in your post (the high configuration, I believe you wanted H<H1 and H1>H2) ------------------------------------------------------------------------------------------- Try this:
Create a custom indicator:
ABS(H<H1ANDH1>H2)*L
place in top window select plot using price scale smoothing average 1 color red
-----------------------------------------------------------------------------------------
Create a second custom indicator:
ABS(L>L1ANDL1<L2)*L
place in top window select plot using price scale smoothing average 1 color green
-----------------------------------------------------------------------------------------
These indicators will plot a green line at the low when yesterdays low is the lowest of the last 3 lows and a green line at the low when yesterdays high is the highest of the last 3 highs.
--------------------------------------------------------------------------------------------
You can also try this in the middle or bottom window: (if you don't like the low plot)
Create a custom indicator:
ABS(H<H1ANDH1>H2)*-1
place in middle or bottom select center zero line smoothing average 1 color red
------------------------------------------------------------------------------------------------
Create a second custom indicator: (put in same window as other)
ABS(L>L1ANDL1<L2)*1
place in middle or bottom window select center zero line smoothing average 1 color green -------------------------------------------------------------------------------------------------- Thanks diceman
|
|
Registered User Joined: 1/1/2005 Posts: 2,645
|
diceman,
1) Your PCF:
ABS(H<H1ANDH1>H2)*L
should be:
ABS(H<H1ANDH1>H2)*H
2) If PivotHigh is ever determined by this PCF, it stays at that value until first, a True for:
L>L1ANDL1<L2
occurs and next, a True for:
H<H1ANDH1>H2
occurs. At this bar, the new value of PivotHigh beomes:
ABS(H<H1ANDH1>H2)*H
3) Please notice that togle is always set to -1 when:
(L>L1ANDL1<L2)AND NOT(H<H1ANDH1>H2)
returns True. Thus, at the next True for:
H<H1ANDH1>H2
the value of PivotHigh is reset and togle set to 1.
___________________________
Mupa,
As you can see by the above, the If ... Then ... Else is not a problem. The absense of a Loop to construct the solution of the difference equation causes the PCFs for the solution to be so long that no one will write them.
Thanks, Jim Murphy
|
|
Registered User Joined: 1/28/2005 Posts: 6,049
|
Quote:"diceman,
1) Your PCF:
ABS(H<H1ANDH1>H2)*L
should be:
ABS(H<H1ANDH1>H2)*H" -----------------------------------------------------------------------------------
bustermu
I was not attempting to plot the high. I was just "marking" the chart to indicate it happened. I have found when I've show this technique to others. Some do not like the price bars covered. (for example: those who use candlestick analysis) So to avoid covering price bars I mark indicators at the lows. (I consider this a better looking version on the % true indicator)
Thanks diceman
|
|
Registered User Joined: 6/23/2006 Posts: 30
|
Thank you to both of you, diceman and bustermu, for your experience sharing.
Actually, I found a little bit mistype in my first post. What i'm trying to create is a channel that draw recent PIVOT HIGH and PIVOT LOW , above and below price bar. The channel line is remain the same until a new PIVOT is found. And to make sure PivotHigh always draws above PivotLow, I add a toggle condition.
Plot custom indicator "PivotHigh" and "PivotLow" channel line above and below price bar under condition: Toggle=1 ( one time only)
1) If H2<H1 AND H1>H and toggle = -1 Then PivotHigh=H1, toggle=toggle*-1 else PivotHigh=PivotHigh.1 ( draw old pivot high until new pivot high found ) 2) If L2>L1 AND L1<L and toggle = 1 Then PivotLow=L1 , toggle=toggle*-1 else PivotLow=PivotLow.1 ( draw old pivot low until new pivot low found )
Note that the PivotLow will draw first and then everything start back and forth.
When I come to write this on TC2007, I found problems (or it may because lack of my deep understanding on TC) that worths to raise in discussion board about building custom indicator with :
i) If-then-else ii) self-reference variable or loop back (draw old value until new value be assigned) iii) sharing 1 variable across 2 indicator. (toggle)
If this can't be happen in current TC, I hope it would be considered in future version of TC.( even though Snapsheet has been released).
Does anyone know this i),ii),iii) type of indicator can be created in Snapsheet?
------ mupa
|
|
Registered User Joined: 1/1/2005 Posts: 2,645
|
diceman,
I now understand your intent. Thanks.
I also marked the chart but from the top with the possible values of PivotHigh using:
ABS(H<H1ANDH1>H2)*H+(1-ABS(H<H1ANDH1>H2))*100000
and from the bottom with the possible values of PivotLow using:
ABS(L>L1ANDL1<L2)*L
This makes it easy to visualize PivotHigh and PivotLow without actually drawing them or one can actually draw them on a particular chart with the drawing tools.
Note: In light of the changes made by mupa, the factors H and L in the above PCFs should be changed to H1 and L1. respectively.
Thanks, Jim Murphy
|
|
Registered User Joined: 1/1/2005 Posts: 2,645
|
QUOTE (Mupa) Plot custom indicator "PivotHigh" and "PivotLow" channel line above and below price bar under condition: Toggle=1 ( one time only)
1) If H2<H1 AND H1>H and toggle = -1 Then PivotHigh=H1, toggle=toggle*-1 else PivotHigh=PivotHigh.1 ( draw old pivot high until new pivot high found ) 2) If L2>L1 AND L1<L and toggle = 1 Then PivotLow=L1 , toggle=toggle*-1 else PivotLow=PivotLow.1 ( draw old pivot low until new pivot low found )
Mupa,
You have given difference equations for the three variables, PiviotHigh, toggle, PiviotLow. In order to construct a solution, you must also specify the initial values and the start time. It is true that in most cases the initial conditions will not matter if the start time is well before you begin to plot the two Indicators PivotHigh and PivotLow.
Some comments:
1) There are two different values at each bar, PivotHigh and PivotLow, not a single value. 2) It is not true that PivotHigh is always above PivotLow. Nor is it true that PivotHigh is always above the price bar and PivotLow is always below the price bar. 3) If...Then...Else is never a problem to impliment in the PCF Language. Loops and Variables do not exist in the PCF Language. 4) Any computation which could be done on a Symbol's data sequence with the addition of If..Then...Else, Loops with a user specified finite number of iterations, and Variables, can also be done with the present PCF Language. 5) Very trivial codes using the additions to the Language in 4), can be so long without them as to become impractical.
I might write the code for your Indicators if the initialization was say 5 days ago but not for 10 days ago. Even then, the code would have to be modified for each Symbol.
Thanks, Jim Murphy
|
|
Registered User Joined: 1/28/2005 Posts: 6,049
|
Quote:"I also marked the chart but from the top with the possible values of PivotHigh using:
ABS(H<H1ANDH1>H2)*H+(1-ABS(H<H1ANDH1>H2))*100000"
---------------------------------------------------------------------------------------------------------------------
A nice idea bustermu. I thought it might be possible to draw from the top down but never fully looked into it. This is a good solution to drawing over price bars.
Thanks diceman
|
|
Guest-1 |