Ключевая стратегия обратного теста

Автор:Чао Чжан, Дата: 2024-01-26 16:11:28
Тэги:

img

Обзор

Принцип стратегии

Анализ преимуществ

Анализ рисков

  1. Проверка на обратном пути. Исполнение любых правил и сигналов в режиме реального времени может отклоняться от результатов обратного пути и не воспроизводить прибыль обратного пути.

Руководство по оптимизации

Резюме


/*backtest
start: 2024-01-18 00:00:00
end: 2024-01-25 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 21/01/2020
//
// A key reversal is a one-day trading pattern that may signal the reversal of a trend. 
// Other frequently-used names for key reversal include "one-day reversal" and "reversal day."
// How Does a Key Reversal Work?
// Depending on which way the stock is trending, a key reversal day occurs when:
// In an uptrend -- prices hit a new high and then close near the previous day's lows.
// In a downtrend -- prices hit a new low, but close near the previous day's highs
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Key Reversal Up Backtest", shorttitle="KRU Backtest", overlay = true) 
nLength = input(1, minval=1, title="Enter the number of bars over which to look for a new low in prices.")
input_takeprofit = input(20, title="Take Profit pip", step=0.01)
input_stoploss = input(10, title="Stop Loss pip", step=0.01)
xLL = lowest(low[1], nLength)
C1 = iff(low < xLL and close > close[1], true, false)
plotshape(C1, style=shape.triangleup, size = size.small, color=color.green, location = location.belowbar )
posprice = 0.0
pos = 0
barcolor(nz(pos[1], 0) == -1 ? color.red: nz(pos[1], 0) == 1 ? color.green : color.blue ) 
posprice := iff(C1== true, close, nz(posprice[1], 0)) 
pos := iff(posprice > 0, 1, 0)
if (pos == 0) 
    strategy.close_all()
if (pos == 1)
    strategy.entry("Long", strategy.long)
posprice := iff(low <= posprice - input_stoploss and posprice > 0, 0 ,  nz(posprice, 0))
posprice := iff(high >= posprice + input_takeprofit and posprice > 0, 0 ,  nz(posprice, 0))

Больше