素数オシレーター取引戦略

作者: リン・ハーンチャオチャン, 日付: 2023年11月2日 14:42:22
タグ:

img

概要

この戦略は,市場動向を決定し,それに応じてロング/ショートポジションを構築するためにプライムナンバーオシレーター指標を使用する.PNOは,価格と価格そのものの最も近いプライム数との違いを計算し,好値が上昇傾向を示し,負値が下落傾向を示します.この戦略は,価格振動中に隠されたトレンド情報を捉え,ブレイクアウト取引のガイドラインを提供します.

戦略の論理

戦略は,まず価格とpermitPercentをパラメータとして取る PrimeNumberOscillator関数を定義する.この関数は,permitPercent範囲内の価格に近い素数を検索し,その差を返します.ポジティブな差は上昇傾向を示し,マイナス差は下落傾向を示します.

戦略では,PrimeNumberOscillator関数を呼び出してxPNO値を計算する.ポジション方向はxPNOのサインによって決定され,最終的な取引方向を得るためにリバースファクターで掛けられる.方向に基づいてロング/ショートポジションが開かれる.

この戦略は主にPNO指標をベースに傾向の方向性を示しています.指標自体はかなり粗末で,シグナル検証のための他の要因と組み合わせなければなりません.しかし,それは数学原理に基づいています.そしていくつかの客観的なガイドを提供することができます.

利点分析

  • 数学的原理に基づいた 比較的客観的な
  • 振動に隠された傾向を特定できる
  • 柔軟なパラメータ調節 感度調整
  • 実行し,理解し,最適化しやすい

リスク分析

  • PNO自体は粗末で 複数の誤った信号に易い
  • 他の技術指標による検証が必要で,単独で使用することはできません.
  • 慎重なパラメータ選択が必要です,あまりにも大きいか小さい失敗します
  • 高取引頻度,ポジションサイズ管理のニーズ

オプティマイゼーションの方向性

  • 移動平均値,信号検証のためのRSIのようなフィルターを追加
  • ダウンサイドリスクを制限するためにストップロスを実施する
  • 動的に調整可能 市場状況に基づく割合
  • 波動性や他の指標を通じてポジションのサイズを最適化

結論

戦略は,単純な論理と実装により,素数振動原理に基づいてトレンド方向を決定する.しかし,PNOには慎重に使用する必要がある制限がある.シグナルを検証しリスクを制御するために他の技術指標を組み合わせることが必要です.数学取引戦略の典型的な代表として,研究と研究のための参照値を持っています.


/*backtest
start: 2023-10-02 00:00:00
end: 2023-11-01 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 29/03/2018
// Determining market trends has become a science even though a high number or people 
// still believe it’s a gambling game. Mathematicians, technicians, brokers and investors 
// have worked together in developing quite several indicators to help them better understand 
// and forecast market movements.
//
// Developed by Modulus Financial Engineering Inc., the prime number oscillator indicates the 
// nearest prime number, be it at the top or the bottom of the series, and outlines the 
// difference between that prime number and the respective series.
//
// You can change long to short in the Input Settings
// WARNING:
//  - For purpose educate only
//  - This script to change bars colors.
////////////////////////////////////////////////////////////
PrimeNumberOscillator(price, percent) =>
    res = 0
    res1 = 0
    res2 = 0
    for j = price to price + (price * percent / 100)
        res1 := j
	    for i = 2 to sqrt(price)
        	res1 := iff(j % i == 0 , 0, j)
            if res1 == 0 
                break
		if res1 > 0 
		    break
    for j = price to price - (price * percent / 100)
        res2 := j
	    for i = 2 to sqrt(price)
        	res2 := iff(j % i == 0 , 0, j)
            if res2 == 0 
                break
		if res2 > 0 
		    break
    res := iff(res1 - price < price - res2,  res1 - price, res2 - price)
    res := iff(res == 0, res[1], res)
    res
    
strategy(title="Prime Number Oscillator Backtest")
percent = input(5, minval=0.01, step = 0.01, title="Tolerance Percentage")
reverse = input(false, title="Trade reverse")
xPNO = PrimeNumberOscillator(close, percent)
pos = iff(xPNO > 0, 1,
       iff(xPNO < 0, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue ) 
clr = iff(xPNO > 0, green, red)
p1 = plot(xPNO, color=blue, title="KPO")
p2 = plot(0, color=black, title="0")
fill(p1,p2,color=clr)

もっと