ScreenBarsBack.pla

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 13 times
Contact:

ScreenBarsBack.pla

Postby RobotMan » 27 Dec 2008

Hi folks,

Usually, when plotting one oscillator on top of another the "zero lines" don't match up unless you go in and manually dink around with the scaling. You might remember this post:
http://forum.tssupport.com/viewtopic.ph ... ght=#20394

Well, I kept thinking about it and during the Christmas break wrote a function that seems to find how many bars back to the left edge of your chart. Then it is merely a question of finding the max absolute hi/low of your indicator and plot a + and - invisible plot. Now the zero line will always be in the center.

Code: Select all

// Bob Perry 12/2008
Inputs: MBB(Numeric) ; // set 100 to 500 for intraday
Vars: LeftDateTime(0) ;

Value1 = Close[MBB] ; // sets MaxBarsBack to a minimum number
LeftDateTime = getappinfo(aiLeftDispDateTime);
Value2 = FindBar(JulianToDate(LeftDateTime), DateTime2ELTime(LeftDateTime));

If Value2 > -1 then bpScreenBarsBak = value2
Else bpScreenBarsBak = MBB ;
Lets say you have an oscillator variable named "OSC1", a MA of OSC1 named "OSC2", and 2 variables named "ScaleLen" and "ScaleLevel"

Code: Select all

ScaleLen = bpScreenBarsBak(200) ;
ScaleLevel = Maxlist(AbsValue(highest(OSC1,ScaleLen)), AbsValue(Lowest(OSC1,ScaleLen)), AbsValue(highest(OSC2,ScaleLen)), AbsValue(highest(OSC2,ScaleLen)) );

Plot1(OSC1,"OSC1") ;
Plot2(OSC2,"OSC2") ;
Plot3(0,"ZERO") ;
Plot4(+ScaleLevel,"+SclLvl") ; // Properties: Invisible
Plot5(-ScaleLevel,"-SclLvl") ; // Properties: Invisible
Of course, if you use NT, they already thought of this and it does it for you automatically. I like software that does that.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 27 Dec 2008

this solution is soooo elegant.

Good work.
Thanks !

Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 53 times

Re: ScreenBarsBack.pla

Postby Tresor » 27 Dec 2008

Of course, if you use NT, they already thought of this and it does it for you automatically. I like software that does that.
This feature should be considered for MC Gold.


Return to “User Contributed Studies and Indicator Library”