A Comissão considera que o auxílio não é seletivo.

Autora:ChaoZhang, Data: 2023-11-01 16:20:45
Tags:

img

Resumo

Esta estratégia é projetada como um sistema de negociação de tendência flexível baseado no indicador CCI. Ela pode gerar sinais de negociação baseados em cruzamento de linha zero CCI ou cruzes de banda superior/inferior personalizadas. A estratégia permite definir taxas de stop loss e take profit fixas, negociação em prazos específicos e muito mais.

Estratégia lógica

  1. O CCI deve ser utilizado para determinar as tendências do mercado.

  2. Configure as faixas superiores e inferiores do CCI personalizadas. O cruzamento do CCI acima da faixa superior é de alta e o cruzamento abaixo da faixa inferior é de baixa.

  3. Opção para negociar apenas em prazos específicos e fechar todas as posições fora desses períodos.

  4. Definir stop loss fixos e percentagem de lucro.

  5. Mensagens de alerta personalizáveis para sinais de entrada e saída.

  6. Estratégia altamente personalizável com parâmetros CCI ajustáveis, bandas, paradas, etc.

Análise das vantagens

  1. O CCI é sensível às variações de preços, bom para detectar inversões de tendência.

  2. As bandas personalizadas podem ser ajustadas para diferentes mercados.

  3. Apoiar a negociação em diferentes prazos com parâmetros otimizados com base nas características.

  4. Relatórios de risco/recompensa pré-estabelecidos de stop loss/take profit fixos e risco limite.

  5. Parâmetros totalmente personalizáveis otimizam a estratégia para diferentes produtos e condições de mercado.

Análise de riscos

  1. A CCI é propensa a sinais falsos e deve verificar os sinais com indicadores de prazo mais longo.

  2. As percentagens fixas de stop/take não podem adaptar-se às condições de mercado em evolução.

  3. A negociação em prazos fixos corre o risco de perder oportunidades durante os períodos de intervalo.

  4. As melhorias frequentes dos parâmetros podem levar a operações excessivas ou em falta.

  5. Os factores macro devem ser tidos em consideração, pois a otimização por si só não é suficiente para eliminar os riscos.

Orientações de otimização

  1. Adicionar indicadores de prazo mais longo para verificar os sinais CCI.

  2. Incorporar paradas/tomadas dinâmicas, tais como ATR.

  3. Testar parâmetros em diferentes prazos e encontrar períodos de alta eficiência.

  4. Otimizar os parâmetros e as faixas do CCI para os mercados em evolução.

  5. Considere incorporar outros fatores como volatilidade e volume.

  6. Selecionar os prazos adequados para os produtos negociados.

  7. Considere a aprendizagem de máquina para automatizar a otimização de estratégias.

Resumo

No geral, este é um sistema de tendência muito flexível e personalizável. As principais vantagens são o uso de CCI para tendências, bandas personalizadas para limitar o risco, paradas / tomadas fixas e seleção de prazos. É necessário observar sinais falsos de CCI e paradas inflexíveis. Melhorias futuras podem vir da otimização de parâmetros, filtragem de sinais, seleção de prazos eficientes e incorporação de aprendizado de máquina para adaptações automáticas às mudanças do mercado, a fim de alcançar retornos excessivos mais consistentes.


/*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)



Mais.