I like to display levels in my charts - all kind of levels (breakout, stop loss, profit target) - and sometimes I like to display my indicators in in a drawing style called "staircase", where IMHO you can much easier see when the indicator value is broken, something stayed in a range, etc. Please see the picture below for a comparison of staircase vs regular.
For most things you can use trendlines, but you would have lot's of objects and I find it really messy to keep track of.
Attached you will find my implemetation of this with CustomDraw, two sample indicators and one function.
Indicator 1: __i_Staircase
It is a basic sample of the staircase/levels using the CustomDraw. It just uses the HighValues and draws a staircase.
With each bar it builds up a List<double> where the indicator value is stored and in the drawing part the indicator is matched to the CurrentBar. You can switch the vertical lines on/off and with indicator value -1 it hides the plot. It works fine as a demonstration of the staircase when you do not have to use "MaxBarsBack" At that point the arrays don't match that nicely and the plot is offset.
Indicator 2: __i_SampleLevels
It is using the __f_DrawLevels. I'm not going into much detail - it is just a sample, please look at the code and ask if anything is unclear.
The advantages are that you can have several pens/styles for one indicator (including blank/don't draw!), start/end lines between bars and extend for realtime (w/o flickering). The MaxBars offset should be taken care of and with a few function calls you can display levels and the staircase from any indicator.
This is work in progress and my first stab at this, so there might be bugs and issues. If you find any and preferably can give a solution - please let me know.
Also if someone has an easier solution where VariableSeries<> is used, please let me know. I couldn't get it to work as the VariableSeries<> is out of context in the CustomDraw.
CustomDraw - Levels - Staircase
1 post • Page 1 of 1