効率的な量子取引戦略を組み合わせる

作者: リン・ハーンチャオチャン開催日:2024-02-01 15:09:06
タグ:

img

概要

この戦略は主に5日間のRSI指標と200日間の移動平均を組み合わせて,技術指標組み合わせ戦略に属する取引決定信号を形成する.その主な取引原則は:価格が過買い/過売りエリアに走るときは,売却をシグナル化する.価格が過売りエリアに落ちると,購入をシグナルする.この戦略の最大の利点は,戦略信号が比較的明確で,リトラセッションリスクは比較的小さいことである.しかし,マルチファクターモデルと機械学習アルゴリズムによって最適化できる単一の技術指標組み合わせに基づいて取引決定を形成するにも限界がある.

戦略原則

この戦略は主に5日間のRSI指標と200日間の移動平均を組み合わせて,価格が走っている超買/超売領域を判断し,取引決定を形成します.

  1. 5日間のRSIインジケターは,価格が走っているオーバーバイト/オーバーセールエリアを判断する.オーバーバイトラインは72でオーバーセールエリアは30と設定される.RSIインジケターは底から上へ30を突破すると,購入信号が生成され,RSIインジケーターが上から底まで72を下回ると,販売信号が生成される.

  2. 200日移動平均は,中長期トレンドの方向性を決定する.価格が200日移動平均を下回るときは,価格の下落段階であり,価格が200日移動平均を超えると,価格の上昇段階である.

  3. 1と2の判断を組み合わせると,この戦略は5日間のRSIインジケーターが過剰に買い上げられ72を下回ると売り切れ,5日間のRSIが30を下回り,価格が200日間の移動平均を下回ると購入します.

戦略 の 利点

  1. 戦略信号は比較的明確で,判断領域による過剰購入/過剰売却信号を決定するためにRSI指標を使用します.

  2. 200日間の移動平均は,逆転を避けるために主要なトレンドの方向性を決定します.

  3. リスク管理を助けるため,最大数のポジションを設定できます.

  4. この戦略にはパラメータ最適化,調整可能なRSIパラメータ,移動平均パラメータのための広い空間があります.

  5. 相対的に小さいリトレースリスクは,戦略の最大リトレースを効果的に制御することができます.

戦略 の リスク

  1. RSIと移動平均指標のみを使用すると,戦略シグナルが不安定になり,不安定な市場では,長期および短期間の揺れ動いた損失のリスクがあります.

  2. より良い戦略結果を得るために RSIパラメータと移動平均パラメータを最適化し テストする必要があります

  3. 戦略信号を最適化するために,他の指標やモデルも導入できます.例えば,変動指標,機械学習判断などの導入です.

戦略の最適化のための方向性

  1. MACD,KD,波動指標などより多くの指標組み合わせを使って判断してください.

  2. 機械学習モデル判断を 増やす.例えば,取引信号の安定性を判断するための LSTM.

  3. 取引量の変化,資本流通の方向性,および資本要因の他の判断など,定量的な要因を増やす.

  4. 戦略パラメータを最適化します.例えば,RSIパラメータ,移動平均パラメータなどです.

  5. ストップ・ロスのメカニズムを最適化します.例えば,ストップ・ロスの移動,タイム・ストップ・ロスの移動など.

概要

この戦略は,主に5日間のRSI指標と200日間の移動平均指標の組み合わせを使用して,価格の過買い/過売り領域を判断し,取引シグナルを形成する.これは技術指標組合せ戦略に属している.戦略信号は比較的明確で,最大リトレースリスクは比較的小さい.しかし,戦略結果を改善するために,マルチインジケーター組み合わせと機械学習判断によってさらに最適化することができます.


/*backtest
start: 2024-01-24 00:00:00
end: 2024-01-31 00:00:00
period: 3m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©chewyScripts.

//@version=5
strategy("96er RSI+200EMA Strategy + Alerts", overlay=true)
// This works best on a small account $100, with 50% of equity and up to 10 max open trades. 
// 96% Profitable, turns $100 into $350 in 1 month. very few losses. super happy with it.
// So far it triples the account on a 1m chart in 1 month back testing on the SEI-USD pair.
// I did not test on FX pairs or other instruments.
// had some issues with the inputs not working so had to hard code some, also the lastClose var sometimes breaks and starts following every candle, not sure why.

in_r1 = input.int(5,"5 day input or RSI1")
in_openOrders = input.int(3,"max open orders")

in_lowerRSI = input.int(30,"RSI Lower")
in_upperRSI = input.int(72,"RSI Upper ")

in_emaperiod = input.int(200,"EMA Period")

in_buybreakout = input.int(50,"Buy breakout range")

in_buyTP = input.float(1.05,"Buy TP: 1+TP %, .05 seems to work well.")
in_sellTP = input.float(0.9850, "Sell TP: 1-TP%. .025 seems to work well. ")

simple int rsi5 = in_r1

// 3 rsi strategy , when all of them are overbought we sell, and vice versa
rsi7 = ta.rsi(close,rsi5)
lastClose = request.security(syminfo.tickerid, "D", close, lookahead = barmerge.lookahead_on)
rsi3 = ta.rsi(close[5],rsi5)

ma = ta.ema(close,in_emaperiod)

plot(rsi7,"5 Day RSI",color.red)
plot(lastClose,"Yesterdays Close",color.green)
plot(rsi3,"Previous 5th candles RSI",color.purple)


// sell condition
//sell = ta.crossunder(rsi7,70) and ta.crossunder(rsi14,70) and ta.crossunder(rsi21,70)

//buy condition
//buy = ta.crossover(rsi7,in_lowerRSI) and close < ma and rsi3 <= in_upperRSI and strategy.opentrades < in_openOrders
//sell = ta.crossunder(rsi7,in_upperRSI) and close > ma and rsi3 >= in_lowerRSI3 and strategy.opentrades < in_openOrders

buy = ta.crossover(rsi7,in_lowerRSI) and close < ma and close < lastClose and strategy.opentrades < in_openOrders
sell = ta.crossunder(rsi7,in_upperRSI) and close > ma and close > lastClose and strategy.opentrades < in_openOrders


var lastBuy = close 
var lastSell = close 

if (buy)
    strategy.entry("BUY", strategy.long)
    lastBuy := close 
    alert("Buy")

if ((close >= lastBuy*in_buyTP ) or rsi7 > in_buybreakout and close >= lastClose and (close >= lastClose*in_buyTP or close >= lastBuy*in_buyTP ) )
    strategy.close("BUY", "BUY Exit")
    alert("Buy Exit")
    
if (sell)
    strategy.entry("SELL", strategy.short)
    lastSell := close 
    alert("Sell")

if ( close < ma and (close <= lastSell*in_sellTP ) or (close < lastClose*in_sellTP) )
    strategy.close("SELL", "Sell Exit")
    alert("Sell Exit")


もっと