gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
کد استراتژی بر مبنای سوپر ترند برای استفاده در تریدینگ ویو
- User
کد استراتژی بر مبنای سوپر ترند برای استفاده در تریدینگ ویو
- Assistant
TradingView Pine Script برای استراتژی مبتنی بر نشانگر Super Trend:
//@version=4 strategy("Super Trend Strategy", shorttitle="STS", overlay=true) // تنظیمات ورودی atrLength = input(14, title="ATR Length", type=input.integer) mul = input(1, title="Multiplier", type=input.float) resolution = input(title="Resolution", type=input.resolution, defval="D") exitDays = input(10, title="Exit after days", type=input.integer) // محاسبهی مقادیر Super Trend atr = security(syminfo.tickerid, resolution, atr(atrLength)) up = (high + low) / 2 + mul * atr dn = (high + low) / 2 - mul * atr trendUp = nz(trendUp[1], up) trendDown = nz(trendDown[1], dn) trend = change(trendUp > trendDown ? 1 : -1) != 0 ? trendUp > trendDown ? 1 : -1 : nz(trend[1], 1) // ایجاد سیگنالهای خرید و فروش longCondition = crossover(close, trendUp) and trend == 1 if (longCondition) strategy.entry("Long", strategy.long) shortCondition = crossunder(close, trendDown) and trend == -1 if (shortCondition) strategy.entry("Short", strategy.short) // خروج از موقعیت پس از روزهای مشخصشده strategy.exit("Exit Long", "Long", loss=atr, qty_percent=100, when=barssince(longCondition) >= exitDays) strategy.exit("Exit Short", "Short", loss=atr, qty_percent=100, when=barssince(shortCondition) >= exitDays) // رسم خطوط Super Trend در نمودار plot(strategy.position_size > 0 ? trendUp : na, color=color.green, linewidth=2, style=plot.style_linebr) plot(strategy.position_size < 0 ? trendDown : na, color=color.red, linewidth=2, style=plot.style_linebr)این کد را در تریدینگ ویو اجرا کنید تا استراتژی مبتنی بر سوپر ترند را بر روی نمودار شما ببینید. شما میتوانید تنظیمات این استراتژی را به دلخواه خود تغییر دهید و عملکرد آن را بررسی و بهینهسازی کنید.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.