Esta es una estrategia de negociación de acciones basada en el indicador Ichimoku Kinko Hyo, que utiliza los principios básicos de Ichimoku para determinar entradas y salidas.
La estrategia primero calcula los componentes de Ichimoku, incluyendo Tenkan-Sen, Kijun-Sen, Senkou Span A y Senkou Span B.
Entrada larga si se cumplen las siguientes condiciones:
Salida si se cumplen las siguientes condiciones:
Esta es una estrategia de trading de acciones muy práctica, utilizando Ichimoku para la tendencia y ATR para el control de riesgos, beneficiándose de la estrategia de persecución con stop loss. Las ventajas son obvias.
/*backtest start: 2022-12-05 00:00:00 end: 2023-12-11 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // Author Obarut //@version=5 strategy("İchimoku Strategy With Money Management",overlay=true) //Inputs ts_period = input.int(9, minval=1, title="Tenkan-Sen Period") ks_period = input.int(26, minval=1, title="Kijun-Sen Period") ssb_period = input.int(52, minval=1, title="Senkou-Span B Period") cs_offset = input.int(26, minval=1, title="Chikou-Span Offset") ss_offset = input.int(26, minval=1, title="Senkou-Span Offset") // Back Testing Period fromday = input.int(defval=1,title="Start Date",minval=1,maxval=31) frommonth = input.int(defval=1,title="Start Month",minval=1,maxval=12) fromyear = input.int(defval=1980,title="Start Year",minval=1800, maxval=2100) today = input.int(defval=1,title="En Date",minval=1,maxval=31) tomonth = input.int(defval=1,title="End Month",minval=1,maxval=12) toyear =input.int(defval=2100,title="End Year",minval=1800,maxval=2200) start=timestamp(fromyear,frommonth,fromday,00,00) finish=timestamp(toyear,tomonth,today,00,00) timewindow= time>=start and time<=finish middle(len) => math.avg(ta.lowest(len), ta.highest(len)) // Ichimoku Components tenkan = middle(ts_period) kijun = middle(ks_period) senkouA = math.avg(tenkan, kijun) senkouB = middle(ssb_period) atr = ta.atr(14) ss_above = math.max(senkouA[ss_offset-1], senkouB[ss_offset-1]) ss_below = math.min(senkouA[ss_offset-1], senkouB[ss_offset-1]) // Price Distance From Tenkan distance = close - tenkan // Price Distance from Kijun distancek = close - kijun // Entry/Exit Signals tk_cross_kijun_bull = tenkan >= kijun tk_cross_kijun_bear = tenkan <= kijun cs_cross_bull = ta.mom(close, cs_offset-1) > 0 cs_cross_bear = ta.mom(close, cs_offset-1) < 0 price_above_kumo = close > ss_above pbsenkA = close < ss_above pasenkB = close > ss_below price_below_kumo = close < ss_above future_kumo_bull = senkouA > senkouB future_kumo_bear = senkouA < senkouB // Price Distance From Tenken disbull = distance < 2*atr //Price Distance From Kijun disbullk = distancek < 3*atr //Price Above Tenkan Condition patk = close > tenkan // Kijun Above Senkou Span Condition kjasenkA = kijun > ss_above // Price Below Kijun Condition pbkijun = close < kijun //Bullish Condition bullish= tk_cross_kijun_bull and cs_cross_bull and price_above_kumo and future_kumo_bull and patk and disbull and disbullk and (tenkan>ss_above) and (kijun>ss_above) if(bullish and timewindow ) strategy.entry("Long Entry", strategy.long) // Bearish Condition bearish=tk_cross_kijun_bear and pbsenkA and cs_cross_bear or pbkijun or price_below_kumo lastentryprice = strategy.opentrades.entry_price(strategy.opentrades - 1) // Take Profit or Stop Loss in Bearish if(bearish and timewindow or (close>1.30*lastentryprice and close<kijun ) or (close< 0.93*lastentryprice)) strategy.close("Long Entry") if(time>finish) strategy.close_all("time up") plot(tenkan, color=#0496ff, title="Tenkan-Sen") plot(kijun, color=#991515, title="Kijun-Sen") plot(close, offset=-cs_offset+1, color=#2e640e, title="Chikou-Span") sa=plot(senkouA, offset=ss_offset-1, color=color.rgb(17, 122, 21), title="Senkou-Span A") sb=plot(senkouB, offset=ss_offset-1, color=color.rgb(88, 8, 8), title="Senkou-Span B") fill(sa, sb, color = senkouA > senkouB ? color.rgb(198, 234, 198) : color.rgb(208, 153, 153), title="Cloud color")