
Esta estratégia é baseada no indicador CCI, um sistema de negociação automático de rastreamento de tendências flexível. Pode emitir sinais de negociação de acordo com o eixo 0 do indicador CCI, ou pode emitir sinais através de uma banda de canais ascendente e descendente e uma banda de canais cruzada. A estratégia pode configurar uma taxa de stop loss e stop loss fixa, além de ter várias funções, como negociação por período de tempo e negociação por período de tempo fixo por dia.
O indicador CCI usa o cruzamento do eixo 0 para determinar a tendência do mercado. O CCI acima do eixo 0 é um sinal de tendência positiva, e o CCI abaixo do eixo 0 é um sinal de tendência negativa.
A banda de canais superior e inferior do CCI é personalizada, e quando o CCI superior atravessa a banda de canais é um sinal positivo, o CCI inferior atravessa a banda de canais é um sinal negativo. O cruzamento da banda de canais é um sinal de parada.
Pode ser configurado para negociar apenas em determinados períodos de tempo, e para negociar em períodos de tempo não negociados. Pode ser configurado para negociar em períodos de tempo fixos diários.
Pode-se configurar a proporção de stop loss e stop loss.
Alerta de negociação personalizada para abrir posição.
As estratégias são totalmente personalizáveis e flexíveis, podendo ser ajustadas as estratégias de otimização, como parâmetros CCI, parâmetros de banda de passagem e parâmetros de parada de danos.
Usando o CCI para avaliar a tendência do mercado, o CCI é sensível às mudanças de preço e pode capturar rapidamente os pontos de inflexão do mercado.
A faixa de passagem personalizada pode ser ajustada de acordo com os parâmetros de diferentes mercados, e a faixa de passagem de stop loss pode controlar o risco de forma eficaz.
Suporta várias configurações de horário de negociação, pode ajustar os parâmetros da estratégia de acordo com diferentes períodos de tempo, aproveitando as características de diferentes períodos de tempo para obter lucros extras.
Suporta configuração de stop loss fixo, que permite a predefinição de ganhos e perdas, controlando efetivamente o risco de transações individuais.
Os parâmetros são totalmente personalizáveis e podem ser estrategicamente otimizados para diferentes variedades e situações de mercado para obter melhores resultados.
Os indicadores CCI são sensíveis às mudanças de preços e podem produzir alguns falsos sinais, que devem ser verificados em combinação com indicadores de ciclo mais longo.
A proporção de stop loss fixa não pode ser ajustada de acordo com as mudanças no mercado e deve ser adequadamente mantida.
O tempo de negociação fixo pode perder a oportunidade de ajustes de curto prazo no mercado, devendo ser adequadamente selecionado o período de tempo em que há valor de negociação.
Os parâmetros precisam ser frequentemente otimizados, e se a otimização for inadequada, isso pode levar a excesso de negociação ou perda de oportunidades de negociação.
A combinação de fatores como a situação do setor, o ambiente macroeconômico, etc., não pode ser totalmente evitável com a otimização de parâmetros.
Verificação em combinação com indicadores de ciclo longo e curto para evitar falsos sinais de CCI.
A utilização de indicadores como o ATR para definir o stop loss dinâmico.
Teste o efeito dos parâmetros em diferentes períodos de tempo e escolha os períodos de maior eficácia.
Optimizar os parâmetros do CCI, os parâmetros da faixa de corredores, adaptando-se às mudanças do mercado.
Para fazer um julgamento global, considere a combinação de fatores como tendências, volatilidade e volume de transações.
Escolha o período de tempo adequado de acordo com as características da variedade de transação.
Considere a inclusão de algoritmos de aprendizagem de máquina para a otimização automática da estratégia.
Esta estratégia é um sistema de negociação de seguimento de tendências muito flexível e personalizável. A estratégia possui várias vantagens, como o uso de CCI para determinar tendências, controle de risco de banda de canal personalizado, configuração de stop loss fixo e seleção de período de negociação.
/*backtest
start: 2023-10-01 00:00:00
end: 2023-10-31 00:00:00
period: 1h
basePeriod: 15m
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/
// © REV0LUTI0N
//@version=4
strategy(title="CCI Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)
//CCI Code
length = input(20, minval=1, title="CCI Length")
src = input(close, title="Source")
ma = sma(src, length)
cci = (src - ma) / (0.015 * dev(src, length))
// Strategy Backtesting
startDate = input(timestamp("2099-10-01T00:00:00"), type = input.time, title='Backtesting Start Date')
finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date')
time_cond = true
//Time Restriction Settings
startendtime = input("", title='Time Frame To Enter Trades')
enableclose = input(false, title='Enable Close Trade At End Of Time Frame')
timetobuy = true
timetoclose = true
//Strategy Settings
//Strategy Settings - Enable Check Boxes
enableentry = input(true, title="Enter First Trade ASAP")
enableconfirmation = input(false, title="Wait For Cross To Enter First Trade")
enablezero =input(true, title="Use CCI Simple Cross Line For Entries & Exits")
enablebands = input(false, title="Use Upper & Lower Bands For Entries & Exits")
//Strategy Settings - Band Sources
ccisource = input(0, title="CCI Simple Cross")
upperbandsource =input(100, title="CCI Enter Long Band")
upperbandexitsource =input(100, title="CCI Exit Long Band")
lowerbandsource =input(-100, title="CCI Enter Short Band")
lowerbandexitsource =input(-100, title="CCI Exit Short Band")
//Strategy Settings - Crosses
simplecrossup = crossover(cci, ccisource)
simplecrossdown = crossunder(cci, ccisource)
uppercrossup = crossover(cci, upperbandsource)
lowercrossdown = crossunder(cci, lowerbandsource)
uppercrossdown = crossunder(cci, upperbandexitsource)
lowercrossup = crossover(cci, lowerbandexitsource)
upperstop = crossunder(cci, upperbandsource)
lowerstop = crossover(cci, lowerbandsource)
// Stop Loss & Take Profit % Based
enablesl = input(false, title='Enable Stop Loss')
enabletp = input(false, title='Enable Take Profit')
stopTick = input(5.0, title='Stop Loss %', type=input.float, step=0.1) / 100
takeTick = input(10.0, title='Take Profit %', type=input.float, step=0.1) / 100
longStop = strategy.position_avg_price * (1 - stopTick)
shortStop = strategy.position_avg_price * (1 + stopTick)
shortTake = strategy.position_avg_price * (1 - takeTick)
longTake = strategy.position_avg_price * (1 + takeTick)
plot(strategy.position_size > 0 and enablesl ? longStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Fixed SL")
plot(strategy.position_size < 0 and enablesl ? shortStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Short Fixed SL")
plot(strategy.position_size > 0 and enabletp ? longTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Long Take Profit")
plot(strategy.position_size < 0 and enabletp ? shortTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Short Take Profit")
// Alert messages
message_enterlong = input("", title="Long Entry message")
message_entershort = input("", title="Short Entry message")
message_closelong = input("", title="Close Long message")
message_closeshort = input("", title="Close Short message")
//Strategy Execution
//Strategy Execution - Simple Line Cross
if (cci > ccisource and enablezero and enableentry and time_cond and timetobuy)
strategy.entry("Long", strategy.long, alert_message = message_enterlong)
if (cci < ccisource and enablezero and enableentry and time_cond and timetobuy)
strategy.entry("Short", strategy.short, alert_message = message_entershort)
if (simplecrossup and enablezero and enableconfirmation and time_cond and timetobuy)
strategy.entry("Long", strategy.long, alert_message = message_enterlong)
if (simplecrossdown and enablezero and enableconfirmation and time_cond and timetobuy)
strategy.entry("Short", strategy.short, alert_message = message_entershort)
//Strategy Execution - Upper and Lower Band Entry
if (uppercrossup and enablebands and time_cond and timetobuy)
strategy.entry("Long", strategy.long, alert_message = message_enterlong)
if (lowercrossdown and enablebands and time_cond and timetobuy)
strategy.entry("Short", strategy.short, alert_message = message_entershort)
//Strategy Execution - Upper and Lower Band Exit
if strategy.position_size > 0 and uppercrossdown and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and lowercrossup and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closeshort)
//Strategy Execution - Upper and Lower Band Stops
if strategy.position_size > 0 and upperstop and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and lowerstop and enablebands and time_cond and timetobuy
strategy.close_all(alert_message = message_closeshort)
//Strategy Execution - Close Trade At End Of Time Frame
if strategy.position_size > 0 and timetoclose and enableclose and time_cond
strategy.close_all(alert_message = message_closelong)
if strategy.position_size < 0 and timetoclose and enableclose and time_cond
strategy.close_all(alert_message = message_closeshort)
//Strategy Execution - Stop Loss and Take Profit
if strategy.position_size > 0 and enablesl and time_cond
strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enablesl and time_cond
strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)
if strategy.position_size > 0 and enabletp and time_cond
strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)
if strategy.position_size < 0 and enabletp and time_cond
strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)