Trading scheme using Horizontal lines. Simple trading scheme

Best Binary Options Brokers 2020:
  • Binarium

    Top Binary Options Broker 2020!
    Perfect For Beginners and Middle-Leveled Traders!
    Free Education How To Trade!
    Free Demo Account!
    Big Sign-up Bonus!

  • Binomo

    Good Choice For Experienced Traders!

RSI indicator and a simple trading strategy

Do you know how RSI indicator works? Well, now you are about to find out along with learning a simple and effective trading strategy.

In order for you to successfully trade the RSI indicator you firstly need to understand its principle. RSI is a shortage for Relative Strenght Index and it can have a value from 0 to 100. While values under 30 indicate an oversold market, the values above 70 signalise an overbought market. So simply put, it can help us to determine whether a price of an asset has a higher value than it should have (overbought market) or if the value is lower than it should be – a case of an undersell situation. There are other more in-depth explanations of RSI, but today we will not concern ourself with them, this simple explanation will do the trick for now. Let’s get to our draft strategy.

RSI technical analysis – draft strategy

RSI indicator is best to be used along with one other supplementary indicator that will confirm our entry signals. Today, we will use a combination of the RSI along with a stochastic oscillator (link to our article describing its use). In case you haven’t read the previous article you might find some difficulties with this strategy because we will continue in our already prepared draft from that article. Once we open the template with the stochastic oscillator we add an RSI indicator. Again delete second line “Moving Average 5”, which would only confuse you. After that, click on the RSI indicator settings, choose “edit” and adjust the period from level 50 to level 14. The next step is to create two horizontal lines which we set up to levels 30 and 70. Now all that remains is to attentively wait until the market reaches our established horizontal lines simultaneously on the RSI as well as on the stochastic.

Green vertical lines mark sucesfull trades. Red dots implies crossing both boundaries simultaneously.

Once both signals are confirmed at the same time, we might consider moving towards creating a trade. If the stochastic curve is below level 20 and RSI oscillator above level 30, we might think of creating a Call trade (upwards direction). Oppositely, if the curve on stochastic indicator is located above level 80 and RSI above level 70, then we can consider creating a Put trade (downwards direction). When I trade this strategy I usually choose expiration time between 5 to 10 minutes, but you can try your own setting. As you may have noticed, once we added the RSI indicator we received a significantly smaller amount of signals in comparison to using just the stochastic oscillator. That is completely normal because situations which are confirmed by both indicators do not occur on the market so often, but on the bright side, they should theoretically have a better success rate.

RSI trading – quick summary of the strategy

RSI and Stochastic above levels 70 and 80 – we consider to create a Put option – downwards direction
RSI and Stochastic above levels 30 and 20 – we consider to create a Call option – upwards direction

Forex trading strategy #45 (Simple trading strategy guidelines)

Submitted by Sanjay Ram

Hello all, Sanjay Ram here from Liverpool, England. This is a great spirited site that lends a heart and ear to many aspiring traders, and God Bless the good people who are hosting this site.

I am a businessman, but have been trading for about three years now. I would like to share a very simple strategy. I apologise if it is too simple, or even ridiculous.

1) Plot Support and Resistence Lines on a Daily Chart.
Use pairs like EUR/USD, GBP/USD, AUD/USD, USD/CAD. Remember, S/R are Key Levels of the market; Swing points, historical S/R, short term S/R. Take all these points and connect horizontal lines. Also, note the general trend.

2) At the 4 Hour Chart, plot the lines drawn from the Daily Chart.
Now look for what generally price is doing.For example, if in the Daily Chart price has broken a resistence and moving up (one bar formed only), in the 4 hour chart, there will be a teeny meeny mini uptrend. If this trend were to continue in the Daily Charts, then the 4 hour will hold true to a trend that can last about a week or so.
(get it?)

3) Now plot Bollinger Band, Standard 2 deviation to 10 (not 20).
Take the middle line away and plot a 20SMA. You can do this is METATRADER.

4) Look out for price hitting onto your DRAWN horizontal lines (either S/R).
Then, look out for PIERCING candles on these S/R points. Eg, if is the said uptrend above, we will be looking for a price low to enter.Let’s say price is now at a Support level, it is inside the BB, and at the said support level, it closes with wicks piercing the bands. This is as good a trade to be had in terms of probabilities. On the next candles Half close, we enter long.

5) Please keep in mind the following:

a) Always use the ATR to know what are your chances of gaining how many pips. I have written separately on this subject. Please read up on this matter.

b) Always use good money management. This site has many good reads on this subject.

c) Be disciplined. Like a recent article i saw in this respected site, do not do what you FEEl. do what your analysis tells you.

Wait and wait and wait for your opportunity. The market will always be there after you and me are long gone, my friend, so why worry. Opportunities are galore in the Forex Market. Patience, friend, patience.

And there you have it. I am sorry if this strategy did not use any indicators or other fanciful techniques like switching too many time frames. I have a personal belief; ALL techniques are good, it all depends on the person executing it. Learn which suits you best, and believe me, you will find one!

The Market is True, The Pips are True.

(For now, try and avoid JPY, because of the recent havoc the country has been through, and their central banks trying to hold base. During the Asian session, this can be easily seen and although we can Short positions in most JPY pairs, the retracements and swings will easily eat your Stops out. Just a word of caution only.)

(I am not selling anything, I do write articles for magazines. If the Administrators allow, you may email me.)


Although backtesting is meant to be an automated process based on mathematical calculations, it is often the case that one wants to actually visualize what’s going on. Be it with an existing algorithm which has undergone a backtesting run or looking at what really indicators (built-in or custom) deliver with the data.

And because everything has a human being behind it, charting the data feeds, indicators, operations, evolution of cash and portfolio value can help the humans to better appreciate what’s going on, discard/modify/create ideas and whatever the human looking at the chart may do with the visual information.

That’s why backtrader, using the facilities provided by matplotlib , provides built-in charting facilities.

How to plot

Any backtesting run can be plotted with the invocation of a single method:

Of course this is usually the last command issued like in this simple code which uses one of the sample data from the backtrader sources.

And this yields the following chart.

The chart includes 3 Observers which in this case and given the lack of any trading are mostly pointless

A CashValue observer which as the name implies keeps track of the Cash and total portolio Value (including cash) during the life of the backtesting run

A Trade Observer which shows, at the end of a trade, the actual Profit and Loss

A trade is defined as opening a position and taking the position back to 0 (directly or crossing over from long to short or short to long)

A BuySell observer which plots (on top of the prices) where buy and sell operations have taken place

These 3 Observers are automatically added by cerebro , and are controlled with the stdstats parameter (default: True ). Do the following to disable them if you wish:

or later when running as in:

Plotted Elements

Although the Observers have already been mentioned above in the introduction, they are not the only elements to get plotted. These 3 things get plotted:

Data Feeds added to Cerebro with adddata , replaydata and resampledata

Indicators declared at strategy level (or added to cerebro with addindicator which is purely meant for experimentation purposes and has the indicator added to a dummy strategy)

Observers added to cerebro with addobserver

The Observers are lines objects which run in sync with the strategy and have access to the entire ecosystem, to be able to track things like Cash and Value

Plotting Options

Indicators and Observers have several options that control how they have to be plotted on the chart. There are 3 big groups:

Options affecting the plotting behavior of the entire object

Options affecting the plotting behavior of individual lines

Options affecting the SYSTEM wide plotting options

Object-wide plotting options

These are controlled by this data set in Indicators and Observers:

Although plotinfo is shown as a dict during class definition, the metaclass machinery of backtrader turns that into an object which is inherited and can undergo even multiple inheritance. Than means:

  • If a subclass changes for example a value like subplot=True to subplot=False , subclasses further down the hierarchy will have the latter as the default value for subplot

There are 2 methods of giving value to these parameters. Let’s look at a SimpleMovingAverage instantiation for the 1 st method:

As can be inferred from the example, any **kwargs not consumed by the SimpleMovingAverage constructor will be parsed (if possible) as plotinfo values. The SimpleMovingAverage has a single parameter defined which is period . And this means that plotname will be matched against the parameter of the same name in plotinfo .

The 2 nd method:

The plotinfo object instantiated along the SimpleMovingAverage can be accessed and the parameters inside can also be accessed with the standard Python dot notation. Easy and possibly clearer than the syntax abve.

The meaning of the options

plot : whether the object has to be plotted

subplot : whether to plot along the data or in an independent subchart. Moving Averages are an example of plotting over the data. Stochastic and RSI are examples of things plotted in a subchart on a different scale.

plotname : name to use on the chart instead of the class name. As in the example above mysma instead of SimpleMovingAverage

plotskip (deprecated): and old alias of plot

plotabove : whether to plot above the data. Else plot below. This has only effect if subplot=True

plotlinelabels : whether to plot the names of the individudal lines along the data in the legend on the chart when subplot=False

Example: The Bollinger Bands have 3 lines but the indicator is plotted on top of the data. It seems sensible to have the legend only display a single name like BollingerBands rather than having the name of the 3 individual lines displayed ( mid , top , bot )

A use case for this is the BuySell observer for which it makes sense to display the name of the 2 lines and its markers: Buy and Sell to make it clear for the end user what is what.

plotlinevalues : controls whether the legend for the lines in indicators and observers has the last plotted value. Can be controlled on a per-line basis with _plotvalue for each line

plotvaluetags : controls whether a value tag with the last value is plotted on the right hand side of the line. Can be controlled on a per-line basis with _plotvaluetag for each line

plotymargin : margin to add to the top and bottom of individual subcharts on the graph

It is a percentage but 1 based. For example: 0.05 -> 5%

plothlines : an iterable containing values (within the scale) at which horizontal lines have to be plotted.

This for example helps for the classical indicators with overbought, oversold areas like the RSI which usually has lines plotted at 70 and 30

plotyticks : an iterable containing values (within the scale) at which value ticks have to specifically be placed on the scale

For example to force the scale to have a 50 to identify the mid point of the scale. Although this seems obvious, the indicators use an auto-scaling mechanism and the 50 may not be obviously be in the centre if an indicator with a 0-100 scale moves between 30-95 on a regular basis.

plotyhlines : an iterable containing values (within the scale) at which horizontal lines have to be plotted.

This can take over both plothlines and plotyticks .

If none of the above are defined, then where to place horizontal lines and ticks will be entirely controlled by this value

If any of the above are defined they have precedence over the values present in this option

plotforce : sometimes and thus the complex process of matching data feeds to indicators and bla, bla, bla … a custom indicator may fail to plot. This is a last resort mechanism to try to enforce plotting.

Use it if all else fails

plotmaster : an Indicator/Observer has a master which is the data on which is working. In some cases plotting it with a different master may be wished needed.

A use case is the PivotPoint indicator which is calculated on Monthly data but is meant for Daily data. It only makes sense to plot it on the daily data which is where the indicator makes sense.

plotylimited : currently only applies to data feeds. If True (default), other lines on the data plot don’t change the scale. Example: Bollinger Bands (top and bottom) may be far away from the actual absolute minimum/maximum of the data feed. With \ plotlimited=True , those bands remain out of the chart, because the data controls the scaling. If set to False`, the bands affects the y-scale and become visible on the chart

A use case is the PivotPoint indicator which is calculated on Monthly data but is meant for Daily data. It only makes sense to plot it on the daily data which is where the indicator makes sense.

Line specific plotting options

Indicators/Observers have lines and how this lines are plotted can be influenced with the plotlines object. Most of options specified in plotlines are meant to be directly passed over to matplotlib when plotting. The documentation relies therefore on examples of things that have been done.

IMPORTANT: The options are specified on a per-line basis.

Some of the options are controlled directly by backtrader. These all start with an underscore ( _ ):

_plotskip (boolean) which indicates that plotting of a specific line has to be skipped if set to True

_plotvalue (boolean) to control if the legend of this line will contain the last plotted value (default is True )

_plotvaluetag (boolean) to control if a righ hand side tag with the last value is plotted (default is True )

_name (string) which changes the plot name of a specific line

_skipnan (bool, default: False): to skip NaN values when plotting and allowing for example to draw a line between 2 distant points generated by an indicator, which has all intermediate values as NaN (default value for new created data points)

_samecolor (boolean) this forces the next line to have the same color as the previous one avoiding the matplotlib default mechanism of cycling trough a color map for each new plotted element

_method (string) which chooses the plotting method matplotlib will use for the element. If this is not specified, then the most basic plot method will be chosen.

Example from MACDHisto . Here the histo line is plotted as a bar which is the industry de-facto standard. The following definition can be found in the definition of MACDHisto :

alpha and width are options for matplotlib

Allow filling between the given line and:

A numeric value

The arguments is an iterable of 2 elements in which:

The 1 st argument is a string (name of reference line) or a numeric value

The filling will be done in between the own values and the values of the line or the numeric value

The 2 nd argument is either:

  • A string with a colour name (matplotlib compatible) or hex specification (see matloplit examples)
  • An iterable where the 1 st element is the string/hex value for the colour and the second element is a numeric value specifying the alpha transparency (default: 0.20 controlled with fillalpha in a plotting scheme)

Passing options to a not yet known line

  • Ue the name _X where X stands for a digit in a zero-based index. This means that the options are for line X

A use case from OscillatorMixIn :

As the name implies, this is a mixin class intended to be used in multiple inheritance schemes (specifically on the right hand side). The mixin has no knowledge of the actual name of the 1 st line (index is zero-based) from the other indicator that will be part of the multiple inheritance mix.

And that’s why the options are specified to be for: _0 . After the subclassing has taken place the 1 st line of the resulting class will have the name osc in plot.

Some plotlines examples

The BuySell observer has the following:

The buy and sell lines have options which are passed directly to matplotlib to define marker, markersize, color and fillstyle. All these options are defined in matplotlib

The Trades observer has the following:

Here the names of the lines have been redefined from for example pnlplus to Positive by using _name . The rest of the options are for matplotlib

The DrawDown observer:

This one defines two lines to let the end users access not only the value of the current drawdown but also its maximum value ( maxdrawdown ). But the latter is not plotted due to _plotskip=True

The BollingerBands indicator:

Here the mid line will have a dashed style and the top and bot lines will have the same color as the mid line.

The Stochastic (defined in _StochasticBase and inherited):

Best Binary Options Brokers 2020:
  • Binarium

    Top Binary Options Broker 2020!
    Perfect For Beginners and Middle-Leveled Traders!
    Free Education How To Trade!
    Free Demo Account!
    Big Sign-up Bonus!

  • Binomo

    Good Choice For Experienced Traders!

The slower line percD is plotted with a dashed style. And the names of the lines are changed to include fancy % signs ( %K and %D ) which cannot be used in name definitions in Python

Methods controlling plotting

When dealing with Indicators and Observers the following methods are supported to further control plotting:

Which should return a list of things to conform the labels which will be placed in between parentheses after the name of the Indicators or Observer

An example from the RSI indicator:

As can be seen this method returns:

An int which indicates the period configured for the RSI and if the default moving average has been changed, the specific class

In the background both will be converted to a string. In the case of the class an effort will be made to just print the name of the class rather than the complete combination.

Which is called at the beginning of plotting to do whatever specific initialization the indicator may need. Again, an example from RSI :

Here the code assigns a value to plotyhlines to have horizontal lines (the hlines part) plotted at specific y values.

The values of the parameters upperband and lowerband are used for this, which cannot be known in advance, because the parameters can be changed by the end user

System-wide plotting options

First the signature of plot within cerebro:

plotter : an object/class containing as attributes the options controlling the system wide plotting

If None is passed a default PlotScheme object (see below) will be instantiated

numfigs : in how many independent charts a plot has to be broken

Sometimes a chart contains too many bars and will not be easily readable if packed in a single figure. This breaks it down in as many pieces as requested

iplot : automatically plot inline if running inside a Jupyter Notebook

**kwargs : the args will be used to change the values of the attributes of plotter or the default PlotScheme object created if no plotter is passed.


This object contains all the options that contol system-wide plotting. The options are documented in the code:

Colors in PlotScheme

The PlotScheme class defines a method which can be overriden in subclasses which returns the next color to be used:

Where idx is the current index to the line being plotted on a individual subchart. The MACD for example plots 3 lines and hence the idx variable will only have the following values: 0 , 1 and 2 . The next chart (maybe another indicator) will star the count again at 0 .

The default color scheme used in backtrader uses (as seen above) is the Tableau 10 Color Palette with the index modified to be:

By overriding the color method or passing a lcolors variable to plot (or in a subclass of PlotScheme ) the colouring can be completely changed.

The source code contains also the defintions for the Tableau 10 Light and the Tableau 20 color palettes.

Best Binary Options Brokers 2020:
  • Binarium

    Top Binary Options Broker 2020!
    Perfect For Beginners and Middle-Leveled Traders!
    Free Education How To Trade!
    Free Demo Account!
    Big Sign-up Bonus!

  • Binomo

    Good Choice For Experienced Traders!

Like this post? Please share to your friends:
Binary Options Trading, Strategies and Robots
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: