Skrip ini adalah strategi untuk sistem Ichimoku Cloud untuk perdagangan.
Skrip ini membolehkan anda menguji pelbagai isyarat perdagangan yang ditawarkan oleh sistem awan Ichimoku.
Jika anda
Anda boleh menukar nisbah untuk mengambil keuntungan (TP) dan nilai stop loss (SL) dalam parameter skrip.
Skrip ini menggunakan pengiraan Ichimoku Cloud untuk input isyarat seperti Tenkan/Kijun, Harga/Kijun, dan Harga/Tenkan antara lain.
Awan Ichimoku digambarkan menggunakan fungsi donchian, dan isyarat dihasilkan apabila harga melintasi di atas atau di bawah garis penukaran, garis asas, kumo tinggi atau kumo rendah berdasarkan pilihan anda dari menu input.
Skrip ini juga merangkumi syarat untuk entri perdagangan panjang dan pendek.
Ia menggunakan Julat Benar Purata (ATR) untuk pengurusan wang, menggunakan pengganda untuk hentikan kerugian dan mengambil keuntungan yang boleh diselaraskan.
Di samping itu, terdapat penapis untuk masa ujian, yang membolehkan anda menentukan berapa tahun di masa lalu anda ingin menguji strategi.
Akhirnya, strategi ditetapkan untuk memasuki atau keluar dari perdagangan berdasarkan isyarat kesinambungan dan nilai ATR untuk keuntungan dan kerugian.
Skrip ini boleh menjadi alat yang berguna untuk menguji strategi perdagangan Ichimoku Cloud, tetapi seperti biasa, seseorang harus meluangkan masa untuk memahami logik dan menyesuaikan parameter berdasarkan pengetahuan dan tahap keselesaan mereka.
/*backtest start: 2023-01-01 00:00:00 end: 2023-03-21 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/ // © vuagnouxb //@version=4 strategy("BV's ICHIMOKU CLOUD SIGNAL TESTER", overlay=true) // Signal imputs signalChoice = input(title = "SIGNAL - Choose your signal", defval = "Tenkan/Kijun", options = ["Tenkan/Kijun", "Tenkan/Kijun+Kumo", "Price/Tenkan", "Price/Tenkan+Kumo", "Price/Kijun", "Price/Kijun+Kumo", "Price/Kumo", "Kumo Color"]) JPYPair = input(type = input.bool, title = "ATR - Check if JPY Pair ", defval = false) //------------------------------------------------------------------------ //---------- ICHIMOKU CLOUD Calculation ----------- INPUT //------------------------------------------------------------------------ conversionPeriods = input(9, minval=1, title="Conversion Line Periods"), basePeriods = input(26, minval=1, title="Base Line Periods") laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"), displacement = input(26, minval=1, title="Displacement") donchian(len) => avg(lowest(len), highest(len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) plot(conversionLine, color=#0496ff, title="Conversion Line") plot(baseLine, color=#991515, title="Base Line") plot(close, offset = -displacement + 1, color=#459915, title="Lagging Span") p1 = plot(leadLine1, offset = displacement - 1, color=color.green, title="Lead 1") p2 = plot(leadLine2, offset = displacement - 1, color=color.red, title="Lead 2") fill(p1, p2, color = leadLine1 > leadLine2 ? color.green : color.red) kumoHigh = max(leadLine1[displacement-1], leadLine2[displacement-1]) kumoLow = min(leadLine1[displacement-1], leadLine2[displacement-1]) // -- Trade entry signals continuationSignalLong = signalChoice == "Tenkan/Kijun" ? crossover(conversionLine, baseLine) : signalChoice == "Tenkan/Kijun+Kumo" ? crossover(conversionLine, baseLine) and close > kumoHigh : signalChoice == "Price/Tenkan" ? crossover(close, conversionLine) : signalChoice == "Price/Tenkan+Kumo" ? crossover(close, conversionLine) and close > kumoHigh : signalChoice == "Price/Kijun" ? crossover(close, baseLine) : signalChoice == "Price/Kijun+Kumo" ? crossover(close, baseLine) and close > kumoHigh : signalChoice == "Price/Kumo" ? crossover(close, kumoHigh) : signalChoice == "Kumo Color" ? crossover(leadLine1, leadLine2) : false continuationSignalShort = signalChoice == "Tenkan/Kijun" ? crossunder(conversionLine, baseLine) : signalChoice == "Tenkan/Kijun+Kumo" ? crossunder(conversionLine, baseLine) and close < kumoLow : signalChoice == "Price/Tenkan" ? crossunder(close, conversionLine) : signalChoice == "Price/Tenkan+Kumo" ? crossunder(close, conversionLine) and close < kumoLow : signalChoice == "Price/Kijun" ? crossunder(close, baseLine) : signalChoice == "Price/Kijun+Kumo" ? crossunder(close, baseLine) and close < kumoLow : signalChoice == "Price/Kumo" ? crossunder(close, kumoLow) : signalChoice == "Kumo Color" ? crossunder(leadLine1, leadLine2) : false longCondition = continuationSignalLong shortCondition = continuationSignalShort //------------------------------------------------------------------------ //---------- ATR MONEY MANAGEMENT ------------ //------------------------------------------------------------------------ SLmultiplier = input(title = "ATR - Stop Loss Multiplier", type = input.float, defval = 1.5, step = 0.1) TPmultiplier = input(title = "ATR - Take Profit Multiplier", type = input.float, defval = 1.0, step = 0.1) pipAdjuster = JPYPair ? 1000 : 100000 ATR = atr(14) * pipAdjuster // 1000 for jpy pairs : 100000 SL = ATR * SLmultiplier TP = ATR * TPmultiplier //------------------------------------------------------------------------ //---------- TIME FILTER ------------ //------------------------------------------------------------------------ YearOfTesting = input(title = "Time - How many years of testing ?" , type = input.integer, defval = 3) _time = 2020 - YearOfTesting timeFilter = (year > _time) //------------------------------------------------------------------------ //--------- ENTRY FUNCTIONS ----------- INPUT //------------------------------------------------------------------------ if (longCondition and timeFilter) strategy.entry("Long", strategy.long) if (shortCondition and timeFilter) strategy.entry("Short", strategy.short) //------------------------------------------------------------------------ //--------- EXIT FUNCTIONS ----------- //------------------------------------------------------------------------ strategy.exit("ATR", from_entry = "Long", profit = TP, loss = SL) strategy.exit("ATR", from_entry = "Short", profit = TP, loss = SL)