Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.5 kB
7
Indexable
Never
//@Rp4000 
//@version=5
// The bot combines EMA with Ichimoku
//  Disclaimer:
//    1. I am not licensed financial advisors or broker dealers. I do not tell you 
//       when or what to buy or sell. I developed this software which enables you 
//       execute manual or automated trades using TradingView. The 
//       software allows you to set the criteria you want for entering and exiting 
//       trades.
//    2. Do not trade with money you cannot afford to lose. I am not accountable for any losses.
//    3. I do not guarantee consistent profits or that anyone can make money with no 
//       effort. And I am not selling the holy grail.
//    4. Every system can have winning and losing streaks.
//    5. Money management plays a large role in the results of your trading. For 
//       example: lot size, account size, broker leverage, and broker margin call 
//       rules all have an effect on results. Also, your Take Profit and Stop Loss 
//       settings for individual pair trades and for overall account equity have a 
//       major impact on results. If you are new to trading and do not understand 
//       these items, then I recommend you seek education materials to further your
//       knowledge.
// If this helped you and if you are able consider sending a tip
strategy(title="RoyalPrince Ichimoku EA", shorttitle="RoyalPrince Ichimoku EA", overlay=true, currency=currency.NONE, initial_capital = 1000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_value = 0.05)
conversionPeriods = input.int(9, minval=1, title="Conversion Line Length")
basePeriods = input.int(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length")
displacement = input.int(26, minval=1, title="Lagging Span")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=#2962FF, title="Conversion Line")
plot(baseLine, color=#B71C1C, title="Base Line")
plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,
	 title="Leading Span A")
p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,
	 title="Leading Span B")
plot(leadLine1 > leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Upper Line", display = display.none) 
plot(leadLine1 < leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Lower Line", display = display.none) 
fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))

// Add EMA
longest = ta.ema(close, 200)
plot(longest, color = color.yellow)

// Long Entry
if (close > leadLine1) and (close > leadLine2) and (close > conversionLine) and (close > baseLine) and (close > longest)
    strategy.entry("Long", strategy.long)

// Short Entry
if (close < leadLine1) and (close < leadLine2) and (close < conversionLine) and (close < baseLine) and (close < longest)
    strategy.entry("Short", strategy.short)

// Exit
if (strategy.position_size > 0) and (close < leadLine1)
    strategy.close("Exit Long", "Long")
if (strategy.position_size < 0) and (close > leadLine1)
    strategy.close("Exit Short", "Short")