Trading Ideas Based on Prices Direction and Movement Speed

Alexander Fedosov | 21 April, 2015

Introduction

It has long been known that when a price moves all liquid markets reveal some sort of wave cyclical nature first going up and then going down. It is clearly seen on charts of higher timeframes. Sinusoidal nature is a reflection of the fact that the price has certain persistence. Otherwise it would look like a zigzag: abrupt upward and downward movements within short periods of time. Let us try to find out reasons of this phenomenon and ways of employment it in trading.


Movement Beginning and Persistence

Any movement in our world can be characterized by its direction, acceleration and speed. It works in liquid markets as well. This implies one important rule which says that never a one strong directed movement of the price can harshly end. It can be compared with a train: when a whole train set brakes at its full speed, its brake way can be up to one kilometer.

So when does a trend begin? When majority of market participants change their opinion to the contrary for some reasons whether it pertains to global change in direction or change in some important factors influencing on the market or news. With that a considered collective opinion is formed and the trend begins. Market participants have increasing belief that movement is becoming stronger and will go on further. It has a direction, acceleration and a certain speed because big players enter the market with large positions. This is where those, who entered at the beginning of the movement and gave it an impulse and speed, start gaining profit. Other traders enter the market later and with less attractive price. But unlike the first traders, they try to use the price movement direction.

The trend ends when changes occur. But why is the price still moving in the same way? Why doesn't it change abruptly? The reason of such behavior is that those, who were accelerating and pushing the price in the desired direction, start closing their positions and thereby suppress the trend. And those, who were just "riding the wave", still believe that nothing has changed and even try to move the price. But this "train" does not just stop. It starts moving in the opposite direction and here the story ends.


Trading Idea and How not to Get Run Over by the "Train"

The idea of using the movement and gaining profit is based on the analysis of the current trend depth, i.e. its size and duration.

To provide a vivid example we use standard indicators: RSI (Relative Strength Index) and AC (Acceleration/Deceleration).

1. Conditions for entering the market

We will use the first indicator to demonstrate how far and deep the price has currently moved.

We will place levels to determine a distance and a depth:

Fig. 1 RSI oscillator levels

Fig. 1. RSI oscillator levels

The price movement depth evaluation criteria:

Buy price movement zones:

Let us similarly index sell prices:

We can describe this condition in the MQL4 language as follows:

//--- determining buy index
   double rsi=iRSI(Symbol(),tf,period,PRICE_CLOSE,0);
   index_rsi = 0;
   if(rsi>90.0) index_rsi=4;
   else if( rsi > 80.0 ) 
   index_rsi = 3;
   else if( rsi > 70.0 ) 
   index_rsi = 2;
   else if( rsi > 60.0 ) 
   index_rsi = 1;
   else if( rsi < 10.0 ) 
   index_rsi = -4;
   else if( rsi < 20.0 ) 
   index_rsi = -3;
   else if( rsi < 30.0 ) 
   index_rsi = -2;
   else if( rsi < 40.0 ) 
   index_rsi = -1;

We will use Bill Williams' AC indicator for its intended purpose, namely we will measure speed and acceleration of the current movement.

Fig. 2. AC indicator

Fig. 2. AC indicator

Speed evaluation criteria:

Growth.

Fall.

In MQL4 that will look as follows:

double ac[];
   ArrayResize(ac,5);
   for(int i=0; i<5; i++)
      ac[i]=iAC(Symbol(),tf,i);

   index_ac=0;
//--- buy signal
   if(ac[0]>ac[1])
      index_ac=1;
   else if(ac[0]>ac[1] && ac[1]>ac[2])
      index_ac=2;
   else if(ac[0]>ac[1] && ac[1]>ac[2] && ac[2]>ac[3])
      index_ac=3;
   else if(ac[0]>ac[1] && ac[1]>ac[2] && ac[2]>ac[3] && ac[3]>ac[4])
      index_ac=4;
//--- sell signal
   else if(ac[0]<ac[1])
      index_ac=-1;
   else if(ac[0]<ac[1] && ac[1]<ac[2])
      index_ac=-2;
   else if(ac[0]<ac[1] && ac[1]<ac[2] && ac[2]<ac[3])
      index_ac=-3;
   else if(ac[0]<ac[1] && ac[1]<ac[2] && ac[2]<ac[3] && ac[3]<ac[4])
      index_ac=-4;

If we have movement depth indexes and know the movement speed, we can lay down and classify some entry conditions.

There are options of market entry:

//--- buy signal
if(index_rsi==1 && index_ac>=1) //possible buy movement
if(index_rsi==2 && index_ac>=1) //weak buy movement
if(index_rsi==3 && index_ac==1) //weak buy movement
if(index_rsi==3 && index_ac>=2) //moderate buy movement
if(index_rsi==4 && index_ac>=1) //strong buy movement

//--- sell signal  
if(index_rsi==-1 && index_ac<=-1) //possible sell movement
if(index_rsi==-2 && index_ac<=-1) //weak sell movement
if(index_rsi==-3 && index_ac==-1) //weak sell movement
if(index_rsi==-3 && index_ac<=-2) //moderate sell movement
if(index_rsi==-4 && index_ac<=-1) //strong sell movement

//--- flat 
if(index_rsi==0) 


2. Conditions for exiting the market

We have defined and classified entry parameters. We will make the following analogy to explain how market exit conditions have been formed.

Think, for instance, of a children's rubber ball. And now let's think what will happen if someone throws this ball in water from a very high spot. First it will be falling and gathering speed due to gravitational acceleration. Then it bumps up against water. But it has enough speed to submerge at a certain depth loosing its speed and having a negative value. The ball is affected by the Archimedes' principle, so it is pushed to the surface.

Now we will drill down this example:

Two main goals to gain profit are as follows:

  1. Timely determine a moment when the ball has already been thrown and buy or sell.
  2. Close a position when the ball plunges into water and slows down.

It can be difficult to determine duration and the ball's exact distance of fall as we do not see a person throwing the ball nor water in financial markets. We can only see the ball's speed and direction.

We have reviewed the price movement depth and speed evaluation criteria above.

Now we will define exit conditions:

//--- possible downward reversal
if(index_rsi>2 && index_ac<0) 

If the price was moving up long enough, its acceleration becomes negative (to the downside). This points to the fact that change in trend is quite possible.

//--- possible upward reversal
if(index_rsi<-2 && index_ac>0) 

Similarly with the given example: the ball was falling for long enough, but it fell into water, and the water pushes the ball out in the opposite direction. It indicates the moment for closing positions.


3. Enhancement of entry and exit efficiency

It is known that some trading indicators get up their speed of response to the trend change when we use a larger period. But more false signals appear as well.

The alternative way is not to change the calculation period to the lower side but to track it on several timeframes.

Fig. 3. Trend on different timeframes based on RSI and AC signals

Fig. 3. Trend on different timeframes based on RSI and AC signals

The price movement trend can be clearly seen in the figure due to our criteria and RSI and AC indicators. Let's take a detailed look into it.

Movement and speed on M1: strong movement, AC index is 4, RSI index depth is 2. M5 has the same depth but the speed equals to 1. The same movement is determined on M15 but it is less visible than on lower charts. Speaking about 30 minutes and one hour chart, it is impressive to see that M30 already has a signal, and H1 has deceleration and even a signal of possible reversal.

This example gives us a weighty conclusion:

If we considered H1 only, we would place a sell order waiting for reversal. But it would be a false signal which we filtered out conducting the analysis of lower timeframes.


4. Implementation of the trading strategy in the form of an expert advisor

Expert advisor code:

//+------------------------------------------------------------------+
//|                                                       tester.mq4 |
//|                                                Alexander Fedosov |
//+------------------------------------------------------------------+
#property copyright "Alexander Fedosov"
#property strict
#include <trading.mqh>      //Support library for trade operations
//+------------------------------------------------------------------+
//| Parameters                                                       |
//+------------------------------------------------------------------+
input int             SL = 40;               // Stop loss
input int             TP = 70;               // Take profit
input bool            Lot_perm=true;         // Lot of balance?
input double          lt=0.01;               // Lot
input double          risk = 2;              // Risk of deposit, %
input int             slippage= 5;           // Slippage
input int             magic=2356;            // Magic number
input int             period=8;              // RSI indicator period
input ENUM_TIMEFRAMES tf=PERIOD_CURRENT;     // Working timeframe
int dg,index_rsi,index_ac;
trading tr;
//+------------------------------------------------------------------+
//| Expert Advisor initialization function                           |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- determining variables for auxiliary class of trading functions
//--- language for displaying errors, Russian of by default.
   tr.ruErr=true;
   tr.Magic=magic;
   tr.slipag=slippage;
   tr.Lot_const=Lot_perm;
   tr.Lot=lt;
   tr.Risk=risk;
//--- number of attempts.
   tr.NumTry=5;
//--- determining decimal places on the current chart
   dg=tr.Dig();
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Main calculation function                                        |
//+------------------------------------------------------------------+
void OnTick()
  {
   depth_trend();
   speed_ac();
//--- check for presence of open orders
   if(OrdersTotal()<1)
     {
      //--- check of buy conditions
      if(Buy())
         tr.OpnOrd(OP_BUY,tr.Lots(),Ask,SL*dg,TP*dg);
      //--- check of sell conditions
      if(Sell())
         tr.OpnOrd(OP_SELL,tr.Lots(),Bid,SL*dg,TP*dg);
     }
//--- are there open orders?
   if(OrdersTotal()>0)
     {
      //--- check and close sell orders which meet closing conditions.
      if(Sell_close())
         tr.ClosePosAll(OP_SELL);
      //--- check and close buy orders which meet closing conditions.
      if(Buy_close())
         tr.ClosePosAll(OP_BUY);
     }

  }
//+------------------------------------------------------------------+
//| Function for determining the trend depth                         |
//+------------------------------------------------------------------+
void depth_trend()
  {
//--- determining buy index
   double rsi=iRSI(Symbol(),tf,period,PRICE_CLOSE,0);
   index_rsi = 0;
   if(rsi>90.0) index_rsi=4;
   else if(rsi>80.0)
      index_rsi=3;
   else if(rsi>70.0)
      index_rsi=2;
   else if(rsi>60.0)
      index_rsi=1;
   else if(rsi<10.0)
      index_rsi=-4;
   else if(rsi<20.0)
      index_rsi=-3;
   else if(rsi<30.0)
      index_rsi=-2;
   else if(rsi<40.0)
      index_rsi=-1;
  }
//+------------------------------------------------------------------+
//| Function for determining the trend speed                         |
//+------------------------------------------------------------------+
void speed_ac()
  {
   double ac[];
   ArrayResize(ac,5);
   for(int i=0; i<5; i++)
      ac[i]=iAC(Symbol(),tf,i);

   index_ac=0;
//--- buy signal
   if(ac[0]>ac[1])
      index_ac=1;
   else if(ac[0]>ac[1] && ac[1]>ac[2])
      index_ac=2;
   else if(ac[0]>ac[1] && ac[1]>ac[2] && ac[2]>ac[3])
      index_ac=3;
   else if(ac[0]>ac[1] && ac[1]>ac[2] && ac[2]>ac[3] && ac[3]>ac[4])
      index_ac=4;
//--- sell signal
   else if(ac[0]<ac[1])
      index_ac=-1;
   else if(ac[0]<ac[1] && ac[1]<ac[2])
      index_ac=-2;
   else if(ac[0]<ac[1] && ac[1]<ac[2] && ac[2]<ac[3])
      index_ac=-3;
   else if(ac[0]<ac[1] && ac[1]<ac[2] && ac[2]<ac[3] && ac[3]<ac[4])
      index_ac=-4;
  }
//+------------------------------------------------------------------+
//| Function for checking buy conditions                             |
//+------------------------------------------------------------------+
bool Buy()
  {
   bool res=false;
   if((index_rsi==2 && index_ac>=1) || (index_rsi==3 && index_ac==1))
      res=true;
   return (res);
  }
//+------------------------------------------------------------------+
//| Function for checking sell conditions                            |
//+------------------------------------------------------------------+
bool Sell()
  {
   bool res=false;
   if((index_rsi==-2 && index_ac<=-1) || (index_rsi==-3 && index_ac==-1))
      res=true;
   return (res);
  }
//+------------------------------------------------------------------+
//| Function for checking buy position closing conditions            |
//+------------------------------------------------------------------+
bool Buy_close()
  {
   bool res=false;
   if(index_rsi>2 && index_ac<0)
      res=true;
   return (res);
  }
//+------------------------------------------------------------------+
//| Function for checking sell position closing conditions           |
//+------------------------------------------------------------------+
bool Sell_close()
  {
   bool res=false;
   if(index_rsi<-2 && index_ac>0)
      res=true;
   return (res);
  }

We have performed a small optimization using only two parameters: tf (working timeframe) and period (RSI indicator period).

And we obtained following results on M15:


Fig. 4. The Expert Advisor backtesting results

Attention! This is just a demo version. We do not recommend using it for tests and on real accounts.

Conclusion

Determination of beginning and end of the trend is one of complicated tasks for traders all over the world as it is impossible to predict market behavior.

But it is entirely possible to determine entry and exit moments in the current trend and therefore gain sizable profit. And the general idea of determination and dynamic track of the movement speed can be helpful in this matter.

Wish you successful trades.