이 전략은 Fractal Chaos Oscillator (FCO) 지표를 계산하여 시장의 경향 방향을 판단하여 트렌드 추적을 구현한다. FCO는 지역 극대값과 극소값의 변화를 비교하여 가격 움직임을 판단한다. 수치는 -1에서 1 사이이며 수치가 높을수록 추세는 더 분명하다. FCO가 더 높은 값을 달성하면 더 많이 하고, 낮은 값을 달성하면 공백한다.
특정 K선 형태를 찾아서 국소 극대값과 극소값을 판단한다. 인접한 두 개의 극대값의 변화를 비교해, FCO 지수를 산출한다. 예를 들어, 최신 세트의 극대 최소값이 이전 세트와 동시되지 않을 때, FCO가 1인 것은 가격 상승 추세가 강해진다는 것을 의미한다. FCO 값에 따라 추세 방향을 판단한다. 값이 높을수록 더 많이 하고, 값이 낮을수록 공백하게 한다.
적절한 최적화 파라미터, 또는 다른 지표와 결합하여 트렌드 반전을 판단할 수 있다.
FCO 전략은 간단한 지표를 통해 트렌드 방향을 판단하고, 짧은 라인 거래에 적합하다. 파라미터 최적화와 같은 방법으로 효과를 높일 수 있다. 쉽게 구현할 수 있는 트렌드 추적 전략이다.
/*backtest
start: 2023-09-10 00:00:00
end: 2023-09-17 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 22/02/2018
// The value of Fractal Chaos Oscillator is calculated as the difference between
// the most subtle movements of the market. In general, its value moves between
// -1.000 and 1.000. The higher the value of the Fractal Chaos Oscillator, the
// more one can say that it follows a certain trend – an increase in prices trend,
// or a decrease in prices trend.
//
// Being an indicator expressed in a numeric value, traders say that this is an
// indicator that puts a value on the trendiness of the markets. When the FCO reaches
// a high value, they initiate the “buy” operation, contrarily when the FCO reaches a
// low value, they signal the “sell” action. This is an excellent indicator to use in
// intra-day trading.
//
// You can change long to short in the Input Settings
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
fractalUp(pattern) =>
p = high[pattern+1]
okl = 1
okr = 1
for i = pattern to 1
okl := iff(high[i] < high[i+1] and okl == 1 , 1, 0)
for i = pattern+2 to pattern*2+1
okr := iff(high[i] < high[i-1] and okr == 1, 1, 0)
res = iff(okl == 1 and okr == 1, p, res[1])
res
fractalDn(pattern) =>
p = low[pattern+1]
okl = 1
okr = 1
for i = pattern to 1
okl := iff(low[i] > low[i+1] and okl == 1 , 1, 0)
for i = pattern+2 to pattern*2+1
okr := iff(low[i] > low[i-1] and okr == 1, 1, 0)
res = iff(okl == 1 and okr == 1, p, res[1])
res
strategy(title="Fractal Chaos Oscillator", overlay = false)
Pattern = input(1, minval=1)
reverse = input(false, title="Trade reverse")
xUpper = fractalUp(Pattern)
xLower = fractalDn(Pattern)
xRes = iff(xUpper != xUpper[1], 1,
iff(xLower != xLower[1], -1, 0))
pos = iff(xRes == 1, 1,
iff(xRes == -1, -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 )
plot(xRes, color=blue, title="FCO")