Algorithmic Trading Tips 19.
VISUAL SIGNALS ON YOUR CHART.
HOW TO CREATE YOUR OWN INDICATORS AND VISUALIZE YOUR SIGNALS.
The analysis and observation of charts is much easier with the help of graphical indicators. Whether you are looking for overbought/oversold market conditions, reversal patterns, trends or periods with large trading moves – This issue contains several Equilla codes for easy visualisation.
DOWNLOAD WORKSPACE. (For users with Refinitiv Eikon.)
DOWNLOAD WORKSPACE. (For users with Bloomberg.)
By downloading you agree to the terms of use below.
With Tradesignal and its formula language Equilla you can create virtually any indicator and trading strategy. In this issue we would like to show you how specific market situations can be shown graphically on the chart. This makes your analysis more efficient and comfortable, at the same time you can discover new patterns in the market and back test them later.
TREND BAR INDICATOR.
Visualizing Trends.
The Trend Bar Indicator colours a bar chart depending on its current situation and trend, thus ensuring a better overview in chart analysis. A simple moving average (SMA) serves as input for the definition of the trend. Of course, it is possible to use any desired trend indicator, or even a combination of several indicators. You can easily modify the Equilla code contained in the workspace to suit your needs.
By default, a bar chart is coloured green when the price moves above its 200-period SMA. If the price is below the SMA, the bars turn red. The colour feature is made possible by the use of the Drawbar command in Equilla.
FIGURE 1: S&P 500 WITH TREND BAR INDICATOR APPLIED TO THREE TIME FRAMES.
The screenshot shows the Trend Bar Indicator in action. Shown is the S&P 500 as a weekly, daily and hourly chart. Using the colour distinction, you immediately realise whether the index holds above or below its long term trend.
EQUILLA CODE FOR TREND BAR INDICATOR
Meta: subchart(false);
Inputs: LongPeriod(200);
Variables: longAV, colour;
longAV=average(close,LongPeriod);
colour=black;
if close<longAV
then colour=red;
if close>longAV
then colour=green;
drawbar(open,high,low,close, colour,colour);
BIG BAR INDICATOR.
Marking Important Market Situations.
Marking disproportionately large candles in a chart can serve as valuable information that can be used for analysis or to generate trading strategies. The Big Bar indicator is created by using the Drawforest command and labels all bars whose range exceeds an arbitrary percentage value. The amount of margin can be set with the input “BarPerformancePerc”.
FIGURE 2: DAX WEEKLY CHART WITH BIG BAR INDICATOR.
The Big Bar Indicator marks all candles with a minimum margin of 8 per cent. Price declines are marked orange, while price increases are labelled gray. In the sub chart the Big Bar indicator was reinserted and adjusted with a percentage value of 4 percent.
EQUILLA CODE FOR THE BIG BAR INDICATOR.
Meta: subchart(true);
Inputs:BarPerformancePerc(3,0.1);
if close<((100-BarPerformancePerc)/100)*close[1] then begin
drawforest(0,1);
drawforest(1,0);
end;
if close>((100+BarPerformancePerc)/100)*close[1] then begin
drawforest(0,1);
drawforest(1,0);
end;
PULLBACK INDICATOR.
Visualization of overbought and oversold areas.
Buying after corrections in an intact up trend is the most popular trend-following approach of all. Following the motto „buy the dip“ it is important to take advantage of oversold conditions in an intact upward trend for long entry. In a down trend, the motto on the other hand is „sell the rally“, i.e. short-term recoveries, which end in an overbought condition, represent a good exit or short opportunity.
A simple method to improve the timing of trading decisions and to provide for a systematic basis, is to identify overbought and oversold market conditions by means of an oscillator.
The following example demonstrates the added value that provides the interaction of a SMA (trend follower) and Stochastic (oscillator). Shown here for the EUR/USD in a 30-minute chart.
Green triangles: oversold condition within an up trend
Red triangles: overbought condition within a down trend
FIGURE 3: PULLBACK INDICATOR FOR THE EUR/USD 30-MINUTE-CHART.
The indicator identifies overbought and oversold conditions and marks them based on the prevailing trend.
EQUILLA CODE FOR PULLBACK INDICATOR.
Meta: subchart(false);
Inputs: ATRmultiple(0.5),VolaPeriod(10);
Vars: ATR,BearReversal,BullReversal;
ATR=avgTrueRange(VolaPeriod);
BearReversal=(close[1]>open[1]+ATRmultiple*ATR
and close<open-ATRmultiple*ATR
and open<close[1]);
BullReversal=(close[1]<open[1]-ATRmultiple*ATR
and close>open+ATRmultiple*ATR
and open>close[1]);
If BearReversal then
begin
drawsymbol(high,"",symboldiamond,10,red,red);
end;
if BullReversal then
begin
drawsymbol(low,"",symboldiamond,10,green,green);
end;
REVERSAL PATTERNS.
Flagging individual patterns in a chart.
The display of individual patterns in a chart provides a useful overview, making it a valuable tool for all market participants. A two bar reversal serves as an example of the visualization. For a bearish reversal: After a positive candle a negative one follows, which also closes below the former candle. Both candles must have reached a definable minimum size. This is calculated using the Average True Range (ATR). If these conditions are met, an icon in the chart is shown. For bullish reversals the reverse rules apply.
FIGURE 4: TWO BAR REVERSAL INDICATOR FOR THE BASELOAD FRONT YEAR CONTRACT CAL 18.
All detected reversal patterns are automatically shown in the chart.
EQUILLA CODE FOR TWO BAR REVERSAL INDICATOR
Meta: subchart(false);
Inputs: ATRmultiple(0.5),VolaPeriod(10);
Vars: ATR,BearReversal,BullReversal;
ATR=avgTrueRange(VolaPeriod);
BearReversal=(close[1]>open[1]+ATRmultiple*ATR
and close<open-ATRmultiple*ATR
and open<close[1]);
BullReversal=(close[1]<open[1]-ATRmultiple*ATR
and close>open+ATRmultiple*ATR
and open>close[1]);
If BearReversal then
begin
drawsymbol(high,"",symboldiamond,10,red,red);
end;
if BullReversal then
begin
drawsymbol(low,"",symboldiamond,10,green,green);
end;
BY THE WAY:
To create a back test only a short extension of the code is required:
If BearReversal then short next bar at low stop;
If BullReversal then buy next bar at high stop;
CREATE INDICATORS AND BACK TEST.
To check the robustness and performance of the pattern, you can use already pre-installed exit modules. In the screenshot below the exit takes place on the open of the following trading day.
FIGURE 5: TWO BAR REVERSAL STRATEGY APPLIED TO BASELOAD FRONT YEAR CONTRACT CAL 18
With the expansion of the indicator with buy or sell orders and the use of a simple exit on the following day, you can back test the two bar Reversal Pattern.
As you can see, Tradesignal provides all the tools for creating your personal graphic tools. Using the examples provided you can implement your ideas quickly. Only a few lines suffice. It is also possible as we have shown to enhance existing indicators into simple trading strategies. This enables you to back test and explore how those indicators would have performed in the past.