|
|
Auto Zoom
Last post 04-02-2009, 23:31 by wabbit. 16 replies.
-
-
03-07-2005, 15:56 |
-
Patrick
-
-

-
Joined on 09-08-2004
-
Lyon
-
Posts 2,292
-
-
|
Hi,
I would love to try and help you, but I'm really confused as to what you are asking for.
Would it be possible for you to post a specific example I can look at?
Thank you
My Site
|
|
-
-
03-07-2005, 18:38 |
-
Patrick
-
-

-
Joined on 09-08-2004
-
Lyon
-
Posts 2,292
-
-
|
What about something like :
PivotA:={your Formula};
PivotB:={your Formula};
PivotC:={your Formula};
PivotD:={your Formula};
Min(Abs(C-PivotA),
Min(Abs(C-PivotB),
Min(Abs(C-PivotC),Abs(C-PivotD))))
It might useful to know how you calculate these pivots too, but that might work.
Let me know.
My Site
|
|
-
03-07-2005, 20:34 |
-
TheNovice
-
-
-
Joined on 03-06-2005
-
-
Posts 17
-
-
|
Hi
Here is my formula for the pivots:
Start:=DayOfWeek()<>Ref(DayOfWeek(),-1);
Hi := ValueWhen(1,Start, Ref(HighestSince(1,Start,H),-1));
Lo := ValueWhen(1,Start, Ref(LowestSince(1,Start,L),-1));
Clse := ValueWhen(1,Start, Ref(C,-1));
Pivot := (Hi+Lo+Clse)/3;
R1 := 2*Pivot -Lo;
S1 := 2*Pivot -Hi;
R2 := Pivot + (Hi-Lo);
S2 := Pivot - (Hi - Lo);
Min(Abs(C-Pivot),
Min(Abs(C-R1),
Min(Abs(C-S1),
Min(Abs(C-R2), Abs(C-S2) ))))
Your code prints the minimum difference to the close and not the actual pivot points (I suppose it can be modified to print the actual pivot). However, it is still display scale independent, I mean, if for example two pivots are within the display window (price), only the one closest to the close will print and not both of them. Also if the nearest pivot is 50 points away, the display will shrinks to show it.
Regards
|
|
-
03-07-2005, 20:51 |
-
-
03-07-2005, 21:04 |
-
03-07-2005, 21:52 |
-
TheNovice
-
-
-
Joined on 03-06-2005
-
-
Posts 17
-
-
|
Here is my code:
Period := Input("Period " ,2 ,150 ,60 );
Distance := Input("Distance " ,5 ,100 ,30 );
Start:= DayOfWeek()<>Ref(DayOfWeek(),-1);
Hi := ValueWhen(1,Start, Ref(HighestSince(1,Start,H),-1));
Lo := ValueWhen(1,Start, Ref(LowestSince(1,Start,L),-1));
Clse := ValueWhen(1,Start,Ref(C,-1));
Pivot := (Hi+Lo+Clse)/3;
R1 := 2*Pivot -Lo;
S1 := 2*Pivot -Hi;
R2 := Pivot + (Hi-Lo);
S2 := Pivot - (Hi - Lo);
HiPeriod := HHV(H,Period)+Distance;
LoPeriod := LLV(L,Period)-Distance;
Default :=
If(R1<HiPeriod AND R1>LoPeriod,R1,
If(R2<HiPeriod AND R2>LoPeriod,R2,
If(S1<HiPeriod AND S1>LoPeriod,S1,
If(S2<HiPeriod AND S2>LoPeriod,S2, Pivot
)
)
)
);
HiPeriod := HiPeriod-Distance;
LoPeriod := LoPeriod+Distance;
If(Abs(Pivot- HiPeriod)<Distance,Pivot,Default);
If(Abs(R1- HiPeriod)<Distance OR Abs(R1- LoPeriod)<Distance,R1,Default);
If(Abs(R2- HiPeriod)<Distance OR Abs(R2- LoPeriod)<Distance,R2,Default);
If(Abs(S1- HiPeriod)<Distance OR Abs(S1- LoPeriod)<Distance,S1 ,Default);
If(Abs(S2- HiPeriod)<Distance OR Abs(S2- LoPeriod)<Distance,S2 ,Default);
It is a bit more complicated. Since I do not know what is the current display price range is I ask for a loopback period (variable Period). And I try to find at least a pivot within that range to use as default, If I do not find any and since I can not turn the indicator off I have chosen Pivot as my default value.
The above code is by no means elegant. It is much better to see what is the range of prices currently being displayed and show only relevant pivots.
Disadvantages of the above code so far are:
1- The default pivot could be far off from the current price if the price has been rising or falling significantly compare to yesterday range.
2- As the price moves, the default pivot position might change and you could see lines joining the Pivots gone out of range to the default value.
3- Any other things that you might come up or I can not remember now!
|
|
-
-
03-08-2005, 17:47 |
-
Patrick
-
-

-
Joined on 09-08-2004
-
Lyon
-
Posts 2,292
-
-
|
This formula here is the same as the one you posted :
( Just less confusing and it will be easier to fix this one )
Pivot :=(Ref(H,-1)+Ref(L,-1)+Ref(C,-1))/3;
R1:=2*Pivot-Ref(L,-1);
S1:=2*Pivot-Ref(H,-1);
R2:=Pivot+(Ref(H,-1)-Ref(L,-1));
S2:=Pivot-(Ref(H,-1)-Ref(L,-1));
R1;S1;R2;S2;Pivot
I unfortunately have to go right now but I will try to give an answer on this by the end of the day.
Patrick
My Site
|
|
-
-
03-08-2005, 21:32 |
-
03-08-2005, 22:07 |
-
Patrick
-
-

-
Joined on 09-08-2004
-
Lyon
-
Posts 2,292
-
-
|
Alright, hopefully I'm not making a fool of myself again ...
I don't have realtime here at homeso I could not test it but I believe this should work or something similar.
Period:=Input("Period",2,150,60);
Distance:=Input("Distance",5,100,30);
Start:= DayOfWeek()<>Ref(DayOfWeek(),-1);
Hi:=ValueWhen(1,Start,Ref(HighestSince(1,Start,H),-1));
Lo:=ValueWhen(1,Start,Ref(LowestSince(1,Start,L),-1));
Clse:=ValueWhen(1,Start,Ref(C,-1));
Pivot:=(Hi+Lo+Clse)/3;
R1 := 2*Pivot -Lo;
S1 := 2*Pivot -Hi;
R2 := Pivot + (Hi-Lo);
S2 := Pivot - (Hi - Lo);
HiPeriod:=HHV(H,Period)+Distance;
LoPeriod:=LLV(L,Period)-Distance;
R1Fix:=ValueWhen(1,R1>=LoPeriod AND R1<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(R1));
R2Fix:=ValueWhen(1,R2>=LoPeriod AND R2<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(R2));
S1Fix:=ValueWhen(1,S1>=LoPeriod AND S1<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(S1));
S2Fix:=ValueWhen(1,S2>=LoPeriod AND S2<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(S2));
PivotFix:=ValueWhen(1,Pivot>=LoPeriod AND Pivot<=hiPeriod AND Cum(1)>=LastValue(Cum(1))-period,LastValue(Pivot));
R1Fix;
R2Fix;
S1Fix;
S2Fix;
PivotFix;
Let me know what you think.
My Site
|
|
-
-
03-31-2009, 23:15 |
-
ronaldjeremy
-
-
-
Joined on 03-19-2009
-
-
Posts 7
-
-
|
I am trying to do the exact same thing, and having the exact same problem.
How I get an indicator to behave like a trendline and not re-scale the y axis?
|
|
-
04-02-2009, 23:31 |
|
|