Heiliger Gral für heikin aschi
Forums › ProRealTime Deutsch forum › Generelle Trading-Themen › Heiliger Gral für heikin aschi
- This topic has 2 replies, 2 voices, and was last updated 2 weeks ago by
Iván.
Viewing 3 posts - 1 through 3 (of 3 total)
-
-
03/30/2025 at 5:38 PM #245427123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960//@version=5strategy(“Heiliger Gral (Heikin Ashi)”, overlay=true)// Auswahl des Timeframes für externe Berechnungentf = input.timeframe(“1D”, title=”Timeframe für Berechnung”) // Standardmäßig 1 Tag// Auswahl: Trading Direction (Long, Short oder Long and Short)tradeDirection = input.string(“Long and Short”, title=”Trading Direction”, options=[“Long”, “Short”, “Long and Short”])// Kopierschutz: Definiere das feste Enddatum für den Backtestint backtest_end_date = timestamp(2035, 2, 14, 0, 0)current_time = time// *** Heikin Ashi für den aktuellen Timeframe ***ha_close_curr = (open + high + low + close) / 4var float ha_open_curr = (open + close) / 2ha_open_curr := (ha_open_curr + ha_close_curr[1]) / 2ha_high_curr = math.max(high, math.max(ha_open_curr, ha_close_curr))ha_low_curr = math.min(low, math.min(ha_open_curr, ha_close_curr))// *** Heikin Ashi-Kerzen aus dem anderen Timeframe berechnen ***ha_close_ext = request.security(syminfo.tickerid, tf, (open + high + low + close) / 4)ha_open_ext_pre = request.security(syminfo.tickerid, tf, (open[1] + close[1]) / 2)ha_open_ext = request.security(syminfo.tickerid, tf, na(ha_open_ext_pre[1]) ? ha_open_ext_pre : (ha_open_ext_pre[1] + ha_close_ext[1]) / 2)ha_high_ext = request.security(syminfo.tickerid, tf, math.max(high, math.max(ha_open_ext, ha_close_ext)))ha_low_ext = request.security(syminfo.tickerid, tf, math.min(low, math.min(ha_open_ext, ha_close_ext)))// **Berechnung von z1 und z2 basierend auf externen Heikin Ashi-Kerzen**a = request.security(syminfo.tickerid, tf, ta.highest(ha_high_ext, 3))b = request.security(syminfo.tickerid, tf, ta.lowest(ha_low_ext, 3))var float z1 = navar float z2 = nafloat z1_plot = nafloat z2_plot = nafloat z3 = naif (current_time <= backtest_end_date)ifha_close_ext[1]>ha_open_ext[1]andha_close_ext<ha_open_extz1:=aifha_close_ext[1]<ha_open_ext[1]andha_close_ext>ha_open_extz2:=b// Berechne z3, wenn z1 und z2 gültig sindifnotna(z1)andnotna(z2)z3:=(z1+z2)/2// Entry-LogikiftradeDirection==”Long”ortradeDirection==”Long and Short”ifha_close_curr>z3strategy.entry(“Long”,strategy.long)iftradeDirection==”Short”ortradeDirection==”Long and Short”ifha_close_curr<z3strategy.entry(“Short”,strategy.short)// Exit-Logik basierend auf z3ifnotna(z3)ifclose>z3strategy.close(“Short”)ifclose<z3strategy.close(“Long”)z1_plot:=z1z2_plot:=z2elsestrategy.close(“Long”)strategy.close(“Short”)label.new(bar_index,high,”No Live Trading”,color=color.red,textcolor=color.white,style=label.style_label_down)// Plottingplot(z1_plot, title=”z1 – Höchster Wert”, color=color.blue, linewidth=2, style=plot.style_stepline)plot(z2_plot, title=”z2 – Tiefster Wert”, color=color.red, linewidth=2, style=plot.style_stepline)plot(z3, title=”z3 – Mitte von z1 und z2″, color=color.gray, linewidth=2, style=plot.style_line)03/30/2025 at 5:47 PM #24542804/09/2025 at 3:18 PM #245761
Hier sind sie:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566tradeDirection=2//------------------------------------------------//// Heikin Ashi candles Current time frame//------------------------------------------------//once haopen=openhaclose=(open+close+high+low)/4if barindex> 0 thenhaopen=(haopen+haclose[1])/2endifhalow=min(low,min(haclose,haopen))hahigh=max(high,max(haclose,haopen))//------------------------------------------------//// Heikin Ashi candles External timeframe//------------------------------------------------//timeframe(daily,updateonclose)once haopenext=openhacloseext=(open+close+high+low)/4if barindex> 0 thenhaopenext=(haopenext+hacloseext[1])/2endifhalowext=min(low,min(hacloseext,haopenext))hahighext=max(high,max(hacloseext,haopenext))a=highest[3](hahighext)b=lowest[3](halowext)timeframe(default)// Z1 and Z2if hacloseext[1]>haopenext[1] and hacloseext<haopenext thenz1=aelsif hacloseext[1]<haopenext[1] and hacloseext>haopenext thenz2=bendif// Z3if z1<>undefined and z2<>undefined thenz3=(z1+z2)/2endif//------------------------------------------------//// Long and Short trades//------------------------------------------------//if not onmarket thenif tradeDirection=1 and haclose>z3 thenbuy 1 contract at marketelsif tradeDirection=-1 and haclose<z3 thensellshort 1 contract at marketelsif tradeDirection=2 and haclose>z3 thenbuy 1 contract at marketelsif tradeDirection=2 and haclose<z3 thensellshort 1 contract at marketendifendifif longonmarket and close<z3 thensell at marketelsif shortonmarket and close>z3 thenexitshort at marketendif//------------------------------------------------//// Graph//------------------------------------------------//graphonprice z1 coloured("blue") as "Z1 max"graphonprice z2 coloured("red") as "Z2 min"graphonprice z3 coloured("orange") as "Z3 med"1 user thanked author for this post.
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
Find exclusive trading pro-tools on
Similar topics: