
この戦略は,プラズマ振動指数に基づいて市場のトレンドを判断し,それに基づいて長短ポジションを構築する.プラズマ振動指数は,価格の近くの最近のプラズマと価格の差値を計算し,正値は多頭トレンドを表示し,負値は空頭トレンドを表示する.この戦略は,価格振動時に隠されたトレンド情報を捕捉し,突破取引の指針となる.
この策略は,まず,PrimeNumberOscillator関数を定義し,価格とallowedPercentのパラメータを入力する.この関数は,価格が正負allowedPercentの範囲で価格に最も近い正数を探し,両者の差を返します.差が0より大きい場合は多頭傾向を示し,0より小さい場合は空頭傾向を示します.
策略では,PrimeNumberOscillator関数を使ってxPNO値を計算する.xPNOがポジションの方向を正負で判断し,ReverseFactorで最終的な取引方向を決定する.取引方向に応じてポジションを開き,空白を多めにする.
この戦略は,主に質量振動指数によってトレンドの方向を判断する.指数は,それ自体には粗略であり,取引信号を検証するために他の要因と組み合わせる必要があります.しかし,数学原理に基づいて,一定の客観的な指針を提供することができます.
この戦略は,質数振動原理に基づいてトレンドの方向を判断し,シンプルで論理的に明確である.しかし,質数振動自体には一定の制限があり,慎重に使用する必要があります.他の技術指標を組み合わせてシグナルを検証し,取引リスクを制御することができます.この戦略は,数学取引戦略の典型的代表であり,学習や研究に一定の参照価値があります.
/*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)