OPEN-SOURCE SCRIPT

Improved EMA Crossover with Target and Stop Loss

//version=5
strategy("Improved EMA Crossover with Target and Stop Loss", overlay=true)

// Define the EMAs
ema36 = ta.ema(close, 36)
ema52 = ta.ema(close, 52)

// Plot the EMAs
plot(ema36, color=color.blue, title="EMA 36")
plot(ema52, color=color.red, title="EMA 52")

// Define the crossover conditions
longCondition = ta.crossover(ema36, ema52) and ta.rsi(close, 14) < 70
shortCondition = ta.crossunder(ema36, ema52) and ta.rsi(close, 14) > 30

// Define target and stop loss levels
target = input(150, title="Target in Points")
stopLoss = input(75, title="Stop Loss in Points")

// Execute trades
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Take Profit", "Long", limit=close + target, stop=close - stopLoss)

if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Take Profit", "Short", limit=close - target, stop=close + stopLoss)
Bands and ChannelsBill Williams IndicatorsChart patterns

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明