OPEN-SOURCE SCRIPT

MA + Volume Strategy

//version=5
strategy("MA + Volume Strategy", overlay=true)

// Parameters
maLength = input.int(50, title="MA Length", minval=1)
volLength = input.int(20, title="Volume MA Length", minval=1)

// Calculating Moving Average and Volume Average
ma = ta.sma(close, maLength)
volMa = ta.sma(volume, volLength)

// Plot the Moving Average
plot(ma, title="Moving Average", color=color.blue, linewidth=2)

// Buy Condition: Price crosses above the MA and Volume > Volume MA
buyCondition = ta.crossover(close, ma) and volume > volMa

// Sell Condition: Price crosses below the MA and Volume > Volume MA
sellCondition = ta.crossunder(close, ma) and volume > volMa

// Strategy entry/exit
if (buyCondition)
strategy.entry("Buy", strategy.long)

if (sellCondition)
strategy.close("Buy")

// Plot volume with volume average for reference
plot(volume, title="Volume", color=color.green, style=plot.style_histogram, transp=70)
plot(volMa, title="Volume Moving Average", color=color.red)
Bill Williams Indicators

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור