Search | User Listing Vidsite | Calendars | Quotes
Home Page ->  OLang, OScript & OPilot -> Writing OLang Plot-Indicators -> View ThreadLogon (or Register, or Join TradeTight)

You are logged in as a limited-access Guest.To join TradeTight, first read the info in the Organization & Content room, then click the link above. 

1 Tim 6:18-19 (ESV) … (the rich) are to do good, to be rich in good works, to be generous and ready to share, thus storing up treasure for themselves as a good foundation for the future, so that they may take hold of that which is truly life.


Sticky Plotting Techniques
Jump to page : 1
Now viewing page 1 [50 msgs/pg]
Jump to room :
JimDean
Posted 8/10/2018 5:35 PM (#9116)
Subject: Plotting Techniques



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
Scattered around the TT forum, there is code that uses a variety of plotting methods which help create visual output that is easy to interpret, even when more than just one value is being plotted. Intelligent application of the various OLang plot commands can create single-pane plots that show the relationship between multiple factors, without getting too "messy". Even though there are only a few plot commands available, when they are used creatively, it's pretty amazing how the resulting outputs can appear.

So, periodically, I'll be adding examples to this thread that illustrate some of these techniques. Enjoy!
Top of the page Bottom of the page
JimDean
Posted 8/10/2018 5:53 PM (#9117 - in reply to #9116)
Subject: Plotting Techniques



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
Recently there was a request on the N forum for an enhancement to Color Charts, to make it possible for the vertical background color strips to have top and bottom limits, so that more than one formula's result could be shown for a given bar. I agree that would be a useful addition to OT's bag of tricks (even though Color Charts are fairly "fragile" components of OT that can get "broken" and are hard to fix).

However, there is already a way to "stack" different "background color bars" on top of one another, using OmniLanguage (which is not as "fragile" as Color Charts, and easier to modify). These techniques are shown for Indicator panes ... they are less useful for the PricePane, since its y-axis scaling is dynamic, purely a function of the High and Low candle prices for the displayed timeframe.

Here's a snapshot showing two different methods ... note that the two indicators are identical (other than the color of the superimposed plotted RSI line) ... the two snapshots below it illustrate the code used to create those indicators. Hopefully, their comments and structure are self explanatory ... but questions are welcome. The code for those two is attached.

The top green portion of the background represents the percentage of the candle's H-L range from the High down to the top of the Body (I call this the "Wick"). The middle blue portion is the percentage of the candles H-L range represented by the O-C Body. The bottom red portion is the percentage of the H-L range represented by the bottom of the Body down to the Low (I call this the "shadow). The yellow/white line is the RSI(14), plotted in the foreground.

This "visually normalizes" the components of the candle in a way that really jumps out at you.


(TwoBackgroundExamples.png)



(aJDndHistoOverlay.png)



(aJDndLineStack.png)



Attachments
Attachments TwoBackgroundExamples.png (20KB - 2 downloads)
Attachments aJDndHistoOverlay.png (32KB - 2 downloads)
Attachments aJDndLineStack.png (30KB - 2 downloads)
Attachments aJDndHistoOverlay.txt (0KB - 13 downloads)
Attachments aJDndLineStack.txt (0KB - 13 downloads)
Top of the page Bottom of the page
JimDean
Posted 8/10/2018 7:48 PM (#9118 - in reply to #9117)
Subject: Plotting Techniques



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
Here's another nifty technique that I've used in some DLL's (including MTV). Sometimes it's helpful to indicate the "state" of a "rule" that just has a few exclusive alternatives (such as bull, flat, bear, etc). In that case, there is no need to take up the full Indicator Pane with that plot, nor even devote a full-vertical background color for the purpose. Instead, you can create a horizontal colored "strip" (top, bottom, &/or middle) that shows the rule-states, yet still leave the middle of the pane free for other purposes.

The example below shows two Bollinger Bands (yellow=20,1 and cyan=10,1) plotted on the price pane using standard OT methods. The Indicator pane shows several things:

1. Top strip color indicates whether the Close is above, inside or below the BB(20,1)
2. Bottom strip color indicates whether the Close is above, inside or below the BB(10,1)
3. Middle white line is RSI(14) shifted down by 50 so that the zero line is in the middle (for illustration)
4. Half-height and full-height verticals in the middle indicate possible Long/Short Entry/Exit points

Since this thread is not really intended for discussions of Entry/Exit, please don't read a lot into the "signals" that this example provides. I chose the BB periods arbitrarily, to illustrate the plotting method. So I'm not trying to recommend this as a trading method (but, with some noise-filtering, it might not be so bad as a starting point ;~)

The code (txt file attached) is hopefully fairly self-explanator ... note the comments in green. The "key" to this technique is using the SetScales command to provide an "extended canvas" (ie beyond the min-max of the RSI) to make room for the top and bottom strips. If you don't follow all the Vclr, etc logic, don't fret about it ... the purpose of this example is to illustrate plotting techniques.


(aJDndStateStrips chartplot.png)



(aJDndStateStrips codesnap.png)



Attachments
Attachments aJDndStateStrips chartplot.png (34KB - 2 downloads)
Attachments aJDndStateStrips codesnap.png (67KB - 3 downloads)
Attachments aJDndStateStrips.txt (2KB - 13 downloads)
Top of the page Bottom of the page
VinayJain
Posted 8/14/2018 3:58 AM (#9119 - in reply to #9116)
Subject: Plotting Techniques


Regular

Posts: 59
2525
Location:
India: , Bangalore
Thanks Jim. You never cease to amaze us with your seemingly never ending supply of fresh imaginative coding ideas.

In the above example you have used a bounded indicator (RSI) in the middle portion and accordingly you have "setscales" (-60,60). Is it possible to use any unbounded indicator like CCI or Volume instead of RSI? If yes then how to configure the "setscales"?

Again in the code what is "firebrick"?

Thanks once again.


Edited by VinayJain 8/14/2018 7:03 AM
Top of the page Bottom of the page
JimDean
Posted 8/14/2018 7:17 AM (#9120 - in reply to #9119)
Subject: Plotting Techniques



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
As to “firebrick” - check out this link for all you ever wanted to know about color plotting options within OLang (“tan” is the only one that doesn’t work since it’s a reserved word for tangent). I use a wide variety of these colors very often …
http://tradetight.org/forums/thread-view.asp?tid=258#M1107
(I highly recommend the “CCS3” table - I have a copy of it stored in my phone photo folder so I can easily refer to it when coding).

Regarding bounded vs unbounded indicators. Bounded ones “naturally” vary between a known max and a known min - RSI in the example above is bounded. As the example demonstrates, it’s easy to shift them up or down vertically (+/-) or to compress/expand them (multiply) - and they remain bounded. SetScales with fixed min & max values works just great in this case.

But many indicators are unbounded, such as CCI or MACD … these have min/max values that vary over time and from symbol to symbol. So, if you use SetScales with them, you may “chop off” the top or bottom or even shift the viewing window so far from their range that they seem to disappear. In those cases, normally don’t use SetScales - just let OT’s native dynamic y-axis scaling handle things for you.

Its sometimes feasible to include a horizontal strip on the same pane as unbounded dynamic-scale indicators, if they naturally oscillate around some “rest” value such as zero. That is, sometimes positive and sometimes negative but the zero line usually is part of the picture (unless the x-axis is very tightly zoomed in). In that case, use the techniques above but make the strip appear ON the zero line (instead of 55 or -55 in the example). If you do this, keep the strip fairly thin (use width = 3 not 10) so that it’s still easy to tell where “0” is.

If you want two zero-line strips in this scenario, then overlay them - make the background one fairly thick (say, 7) and the mid-ground one thin (3-ish). It’s *very* important in this case to pick much different color sets for the two strips so they can be distinguished - use dark colors for the thick background strip and brighter ones for the mid-ground (your unbounded MACD or whatever is plotted on top of these, in the foreground). Colors are fun to mess around with - experiment till you find discernible and pleasant combinations.

In case it’s not clear in the examples above, back/mid/foreground is determined simply by the order of the plot commands (although sometimes the vagaries of the parser might do odd things and force you to play around to get it to work as you intend - particularly if you mix different plot command types). So - first plotted is background and last plotted is foreground.

Sometimes, you can use math tricks to convert an unbounded indicator into a bounded one (but this usually changes the “nature” and maybe the the “usability” of the indicator), so I don’t recommend doing that. What CAN be very helpful, though, is to “normalize” an unbounded indicator based on the share price (or sometimes the ATR) of each symbol - that makes the indicator more universally useful and also tends to “corral” the min/max swings to a tighter range. To do that, just divide by Avg(C,30) - of course that will change the scaling.

Finally, regarding the use of vertical hash marks for unbounded indicators - since the min/max yaxis values vary, if you try to do a vertical “dash” line segment then it likely will look funny since sometimes the same-size dashes will appear tall and sometimes short - and they will appear to shift up and down in the window (if you give them fixed upper/lower values). Sort of a mess.

Two solutions for that: simplest is to make the vertical hashmark segments into “infinite” vertical lines - just assign a max value of 1e8 and a min value of -1e8 … no matter how OT dynamically scales the yaxis, the line will go from top to bottom (best to use very thin lines for this).

Another method, especially useful if the hashmarks are related somehow to the behavior of the foreground plotted indicator (ie CCI), is to simply center them on the indicator’s value for that bar, making the top a bit above (add an offset) and the bottom a bit below (subtract an offset). The offset amount can be guesstimated, or can be roughly estimated using something like: (HHV(indic,30)-LLV(Indic,30))/20 … that is, make the offset a function of the recent dynamic range. Actually, that offset determination can call for some fancy hoop jumping if you are picky about the dashes always appearing to be “about the same height”. I’ll leave it to you to fuss around with that part of you want to :-)
Top of the page Bottom of the page
VinayJain
Posted 8/14/2018 11:27 AM (#9121 - in reply to #9120)
Subject: Plotting Techniques


Regular

Posts: 59
2525
Location:
India: , Bangalore
JimDean - 8/14/2018 4:17 PM

I’ll leave it to you to fuss around with that part of you want to :-)


It is beyond my competence to do that. Thanks for the detailed explanation.

Top of the page Bottom of the page
VinayJain
Posted 8/30/2018 10:24 AM (#9155 - in reply to #9116)
Subject: Plotting Techniques


Regular

Posts: 59
2525
Location:
India: , Bangalore
In post #9117 in "aJDndHistoOverlay" Indicator there is a line of code:
if bar = 0 then plot("Label",0,white) ' readable label (otherwise, green)

and in "aJDndLineStack" Indicator, the corresponding line of code is:
if bar = 0 then plot("Label",-1,yellow) ' readable label (otherwise, green)

It appears that these line are meant to control the color of labels. Can you explain in little more details? Secondly why the value of "Label" is 0 in the first Indicator while it is -1 in the second?

Top of the page Bottom of the page
JimDean
Posted 8/30/2018 10:39 AM (#9156 - in reply to #9155)
Subject: Plotting Techniques



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
The label that shows the parameters is set to the color of the first encountered plot command. Since I use a *wide* variety of colors, sometimes the automatic choice makes the label text unreadable.

So, on bar 0 only, I plot a value either on the price or indicator pane with the color I want for the label.

Since the recent change in OT has the label on a line above the indicator pane proper, with a default gray background, I usually use white for that label (or gainsboro) - prior to the change I often used I used silver.

The value of 0 or -1 etc is chosen specific to the scale of the pane to hide the actual one-Bar plotted line from view.
Top of the page Bottom of the page
JimDean
Posted 8/30/2018 12:02 PM (#9157 - in reply to #9156)
Subject: Plotting Techniques



Owner/Admin

Posts: 3925
2000100050010010010010025
Location:
USA: GA, Lawrenceville
NOTE that there are some additional useful plotting techniques shown in here, for Adx and Bands:
http://tradetight.org/forums/thread-view.asp?tid=681#M9138
Top of the page Bottom of the page
Jump to page : 1
Now viewing page 1 [50 msgs/pg]
( E-mail a Link | Printer Version | Search Room )

Owner of site: Jim Dean -- Forum content is confidential, and may not be distributed without written permission.