monthe

47
// استراتيجية تداول بناءً على شمعة الشهر السابق وخط افتتاح الشهر الجديد //version=5 strategy("Monthly Opening Strategy", overlay=true, default_qty_type=strategy.fixed, default_qty_value=0.1)

// حساب خط افتتاح الشهر الجديد var float monthlyOpen = na var float prevMonthClose = na var float stopLoss = na var float takeProfit = na

if (month(time) != month(time[1])) monthlyOpen := open prevMonthClose := close[1]

// تحديد الاتجاه بناءً على شمعة الشهر السابق longCondition = prevMonthClose > open[1] // إذا كانت الشمعة خضراء، ندخل شراء shortCondition = prevMonthClose < open[1] // إذا كانت الشمعة حمراء، ندخل بيع

// الانتظار لأول ساعة قبل الدخول startTime = timestamp(year, month, dayofmonth, 1, 0) // الساعة الأولى من اليوم الأول بالشهر canTrade = time > startTime

// الشروط للدخول مع التأكيد longEntry = canTrade and longCondition and close > monthlyOpen shortEntry = canTrade and shortCondition and close < monthlyOpen

// إعداد وقف الخسارة وجني الأرباح buffer = 10 * syminfo.mintick // هامش الأمان if longEntry stopLoss := monthlyOpen - buffer takeProfit := close + (close - stopLoss) * 2 // نسبة 1:2 strategy.entry("Long", strategy.long) strategy.exit("Take Profit", from_entry="Long", limit=takeProfit, stop=stopLoss)

if shortEntry stopLoss := monthlyOpen + buffer takeProfit := close - (stopLoss - close) * 2 // نسبة 1:2 strategy.entry("Short", strategy.short) strategy.exit("Take Profit", from_entry="Short", limit=takeProfit, stop=stopLoss)

// رسم خط الافتتاح الشهري plot(monthlyOpen, title="Monthly Open", color=color.blue, linewidth=2)

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.