Vortex Indicator to build trading strategies

 

Quantitative technology house team launched a series of quantitative investment courses in CSDN College

Students who are interested in systematically learning quantitative investment are welcome, click the link below to register:

Quantitative Investment Crash Camp (Introductory Course)

Python stock quantitative investment

Python Futures Quantitative Investment

Python digital currency quantitative investment

C++ Language CTP Futures Trading System Development

Digital currency JavaScript language quantitative trading system development


In today's article, we will introduce a Vortex Indicator, which is similar to DMI (Directional Movement Index) and judges the long-short trend. The original concept of DMI is to calculate the ups and downs of the trend within a period of time, and judge the strength of long and short. The upward force conceptually uses the difference between today's high point and yesterday's high point. If today's high point is higher than yesterday's high point, it means that the upward force is relatively strong. Downward force is the opposite.

The concept of Vortex Indicator is slightly different from that of DMI. The upward force is calculated by using the absolute value of the difference between today's high point and yesterday's low point, and the downward force is calculated by using the difference between today's low point and yesterday's low point. Absolute value.

Vortex Indicator calculation method

1. Take the absolute value by subtracting the highest price of the day from the lowest price of the previous day: VM+= AbsValue(High - Low[1])

2. Use the lowest price of the day minus the highest price of the previous day to get the absolute value: VM- = AbsValue(Low - High[1])

3. Sum up the VM+ in the period: VMPlusSum = Summation(VM+, Length)

4. Sum up the VM- in the period: VMMinusSum = Summation(VM-, Length)

5. Sum up the daily true fluctuation ranges in the period: TRSum = Summation(TrueRange, Length)

6. Finally, divide VMPlusSum by TRSum to get +VM7. Finally, divide VMPlusSum by TRSum to get -VM

Vortex Indicator long and short judgment

If +VM crosses -VM from bottom to top, the current market trend is long

If -VM crosses -VM from bottom to top, the current market trend is short

Vortex Indicator effect display

If the calculation method is iconized on the K-line chart, it looks like a vortex (Vortex) pattern, so it is named Vortex Indicator.

Vortex Indicator indicator code (MC version)

//Indicator:  Vortex

inputs:Length( 14 ) ;
variables:VMPlus( 0 ),VMMinus( 0 ),VMPlusSum( 0 ),VMMinusSum( 0 ),TR( 0 ),TRSum( 0 ),VIPlusSumRge( 0 ),VIMinusSumRge( 0 ),DX(0),ADXX(0);

VMPlus = AbsValue( High - Low[1] ) ;
VMMinus = AbsValue( Low - High[1] ) ;
VMPlusSum = Summation( VMPlus, Length ) ;
VMMinusSum = Summation( VMMinus, Length ) ;
TR = TrueRange ;
TRSum = Summation( TR, Length ) ;

if TRSum <> 0  then
 begin
 VIPlusSumRge = VMPlusSum / TRSum ;
 VIMinusSumRge = VMMinusSum / TRSum ;
 end ;

Plot1( VIPlusSumRge, "VI+Sum/Rge", Green ) ;
Plot2( VIMinusSumRge, "VI-Sum/Rge", Red ) ;

 

Vortex Indicator Trading Strategy (MC Version)

Next, use the Vortex indicator to backtest a homeopathic trading strategy

1. When +VM crosses -VM, it is judged as a long position, and when the price breaks through the time, it is judged to be long.

2. When -VM crosses +VM, it is judged as a short position, and the price low when the breakthrough crosses is short

3. Long-short backhand, no other entry conditions, has been in the market

inputs:Length( 14 ); 
variables:VMPlus( 0 ),VMMinus( 0 ),VMPlusSum( 0 ),VMMinusSum( 0 ),TR( 0 ),TRSum( 0 ),
 VIPlusSumRge( 0 ),VIMinusSumRge( 0 ),SignalTradeNum( 0 ),BuySignal( false ),
 ShortSignal( false ),StopPrice( 0 ) ;

VMPlus = AbsValue( High - Low[1] ) ;
VMMinus = AbsValue( Low - High[1] ) ;
VMPlusSum = Summation( VMPlus, Length ) ;
VMMinusSum = Summation( VMMinus, Length ) ;
TR = TrueRange ;
TRSum = Summation( TR, Length ) ;

if TRSum <> 0  then
 begin
 VIPlusSumRge = VMPlusSum / TRSum ;
 VIMinusSumRge = VMMinusSum / TRSum ;
 end ;

if VIPlusSumRge crosses over VIMinusSumRge then
 begin
 SignalTradeNum = TotalTrades ;
 BuySignal = true ;
 ShortSignal = false ; 
 StopPrice = High ;
 end 
else if VIPlusSumRge crosses under VIMinusSumRge then
 begin
 SignalTradeNum = TotalTrades ;
 BuySignal = false ;
 ShortSignal = true ; 
 StopPrice = Low ;
 end ;

if BuySignal and TotalTrades = SignalTradeNum and MarketPosition <> 1 then
 Buy next bar StopPrice stop ;

if ShortSignal and TotalTrades = SignalTradeNum and MarketPosition <> -1 then
 SellShort next bar at StopPrice stop ;

The following is an example of the trading signal of the Vortex strategy on the K line

Strategy backtest performance (MC version)

The backtest performance of the strategy on the Taiwan Index Futures 60-minute K-line:

The backtest performance of the strategy on the 120-minute K-line of NYMEX light crude oil:

 

 

Guess you like

Origin blog.csdn.net/sljsz/article/details/131925085