この定量的な取引システムは,エントリー信号の潜在的なトレンド逆転を特定するために多項式回帰分析を使用します.これは規則に基づく体系的な方法でモメンタムを活用することを目的としています.
働き方
この戦略は,近年の高値と低値に多項式回帰線を合わせます.近年の高値や低値が回帰予測を上回る数を追跡します.
値上げや値下げの一定限界が突破した場合,新興傾向を示す買い買い信号が生成され,入力パーセントに基づいてストップとターゲットは設定されます.
変動角が最小値を超えると入札されます. 市場が不安定になるのを避けるため,取引は定義されたリスクパラメータに基づいて管理されます.
利点 と 欠点
数学的分析に基づいたトレンド信号を自動化することで,戦略は裁量的な取引に客観的なアプローチを提供します.最適化はパフォーマンスを向上させることができます.
しかし,カーブフィッティングは過剰な最適化につながる可能性があります.あらゆる技術システムと同様に,パフォーマンスは市場状況に大きく依存します.慎重なリスク管理を代替する戦略はありません.
耐久性を評価するには,さまざまな時間枠,資産クラス,市場環境を慎重にテストすることが重要です. 戦略は間違いないので,リスク管理は重要です.
総じて,定量戦略は,潜在的な取引を特定するためのルールに基づく方法論を提供します.数学的技術を組み合わせることで,タイミングとリスク校正を改善することができます.
/*backtest start: 2023-01-01 00:00:00 end: 2023-09-10 00:00:00 period: 4h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // //Ultima version underground09 // strategy(title = " underground09", // shorttitle = "Under09", // overlay = true, // precision = 8, // calc_on_order_fills = true, // calc_on_every_tick = true, // backtest_fill_limits_assumption = 0, // default_qty_type = strategy.fixed, // default_qty_value = 2, // initial_capital = 10000, // pyramiding=5, // currency = currency.USD, // linktoseries = true) // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // var sl = 0.0 var tp = 0.0 var acumaldor_vxp = 0.0 var acomuldor_vol = 0.0 //stop_loss = input(defval=0.2, title="Porcentaje Stop Loss", type=input.float, step=0.2) stop_loss = input(defval=1.4, title="Porcentaje Stop Loss", type=input.float, step=0.2) //take_profit = input(defval=4.4, title="Porcentaje Take Profit", type=input.float, step=0.2) take_profit = input(defval=5.6, title="Porcentaje Take Profit", type=input.float, step=0.2) //pintar_trade = input(defval=false, title="Pintar trade TP SL") angulo_permitido = input(defval=26.8, title="Angulo permitido", type=input.float, step=0.2) backTestSectionFrom = input(title = "═══════════════ From ═══════════════", defval = true, type = input.bool) FromMonth = input(defval = 1, title = "Month", minval = 1) FromDay = input(defval = 1, title = "Day", minval = 1) FromYear = input(defval = 2019, title = "Year", minval = 2014) backTestSectionTo = input(title = "════════════════ To ════════════════", defval = true, type = input.bool) ToMonth = input(defval = 31, title = "Month", minval = 1) ToDay = input(defval = 12, title = "Day", minval = 1) ToYear = input(defval = 9999, title = "Year", minval = 2014) Config = input(title = "══════════════ Config ══════════════", defval = true, type = input.bool) //p = input(6) p = input(4) //length = input(30) length = input(26) // backTestPeriod() => (time > timestamp(FromYear, FromMonth, FromDay, 00, 00)) and (time < timestamp(ToYear, ToMonth, ToDay, 23, 59)) // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // x1 = bar_index x2 = sqrt(x1) y = high // S11 = sum(x2,length) - sqrt(sum(x1,length)) / length S12 = sum(x1*x2,length) - (sum(x1,length) * sum(x2,length)) / length S22 = sum(sqrt(x2),length) - sqrt(sum(x2,length)) / length Sy1 = sum (y*x1,length) - (sum(y,length) * sum(x1,length)) / length Sy2 = sum (y*x2,length) - (sum(y,length) * sum(x2,length)) / length // max1 = sma(x1,length) max2 = sma(x2,length) may = sma(y,length) b2 = ((Sy1 * S22) - (Sy2*S12))/(S22*S11 - sqrt(S12)) b3 = ((Sy2 * S11) - (Sy1 * S12))/(S22 * S11 - sqrt(S12)) b1 = may - b2*max1 - b3*max2 qr = b1 + b2*x1 + b3*x2 // yl = low // Sy1l = sum(yl*x1,length) - (sum(yl,length) * sum(x1,length)) / length Sy2l = sum(yl*x2,length) - (sum(yl,length) * sum(x2,length)) / length // mayl = sma(yl,length) b2l = ((Sy1l * S22) - (Sy2l*S12))/(S22*S11 - sqrt(S12)) b3l = ((Sy2l * S11) - (Sy1l * S12))/(S22 * S11 - sqrt(S12)) b1l = mayl - b2l*max1 - b3l*max2 qrl = b1l + b2l*x1 + b3l*x2 // period = round(p/2)+1 hh = qr[period] ll = qrl[period] countH = 0 countL = 0 buy=0 sell=0 // for i = 1 to period-1 if qr[i]<hh countH:=countH+1 if qrl[i]>ll countL:=countL+1 for i = period+1 to p+1 if qr[i]<hh countH:=countH+1 if qrl[i]>ll countL:=countL+1 if countH==p pivotH = high[period] buy := 1 if countL==p pivotL = low[period] sell := 1 // Angulo(_serie) => atan( _serie - _serie[1] ) * 180 / acos(-1) //calcular elvwap vxp = volume*hlc3 //:= signo de acumulador acumaldor_vxp := acumaldor_vxp + vxp acomuldor_vol := acomuldor_vol + volume vwap2 = acumaldor_vxp / acomuldor_vol pendiente = Angulo(vwap2) // plotshape(buy == 1 , text='⬆️', style=shape.arrowup, location=location.belowbar, color=#32CD32, textcolor=color.white, offset=0, transp=0,size=size.auto) if buy == 1 alert("Posible long",alert.freq_all ) plotshape(sell == 1 , text='⬇️', style=shape.arrowdown, location=location.abovebar, color=#FF0000, textcolor=color.white, offset=0, transp=0,size=size.auto) if sell == 1 alert("Posible short",alert.freq_all ) // //if (backTestPeriod()) //strategy.entry("long", true, 1, when = buy == 1) // strategy.entry("short", false, 1, when = sell == 1) if buy == 1 and pendiente > angulo_permitido //if buy == 1 cantidad = round(strategy.equity / close ) strategy.entry("long", true, cantidad, comment = "Compra") sl := close * ( 1 - (stop_loss/100)) tp := close * ( 1 + (take_profit/100)) if sell == 1 and pendiente > angulo_permitido //if sell == 1 cantidad = round(strategy.equity / close ) strategy.entry("short", false, cantidad, comment = "Venta") sl := close * ( 1 + (stop_loss/100)) tp := close * ( 1 - (take_profit/100)) //Validaciones comprado = strategy.position_size > 0 //true si es positivo vendido = strategy.position_size < 0 //true si es negativo if comprado //Salir sl if close >= tp //plotshape(close >= tp, style=shape.xcross) strategy.close("long", comment="TP") //Salir tp if close <= sl strategy.close("long", comment="SL") if vendido //Salir sl if close <= tp strategy.close("short", comment="TP") //Salir tp if close >= sl strategy.close("short", comment="SL") //sl tp plot( sl , color =color.red, style=plot.style_cross) plot( tp , color= color.green , style=plot.style_circles) //color //bgcolor (comprado ? color.green: na) //bgcolor (vendido ? color.red: na) //if pintar_trade //bgcolor (close >= tp ? color.green : na, transp=80) //bgcolor (close >= sl ? color.red : na, transp=80)