OPEN-SOURCE SCRIPT

SMA, VWAP with Buy/Sell Signals - First Signal Only

アップデート済
Indicator: SMA, VWAP with First Buy/Sell Signals
Overview:
This indicator plots two Simple Moving Averages (SMA 20 and SMA 200) and the Volume-Weighted Average Price (VWAP) on the chart, with fully customizable colors and line thickness. Additionally, it provides buy and sell signals based on the price action relative to these indicators.

Buy Signal:
A buy signal is generated when a green candle (bullish candle) closes above the SMA 20, SMA 200, and VWAP without touching them (i.e., the low of the candle is above all three). This signal will only be plotted for the first such candle of the day to avoid signal clutter.

Sell Signal:
A sell signal is generated when a candle closes below the SMA 20, SMA 200, and VWAP without touching them (i.e., the high of the candle is below all three). Similar to the buy signal, it will only be plotted for the first qualifying candle of the day.

Customization:
SMAs and VWAP: Users can adjust the lengths, colors, and line thickness of the SMAs and VWAP to suit their preferences.
Signal Shape: You can choose from different shapes (arrow, circle, or cross) to represent the buy and sell signals on the chart.
Key Features:
First Candle Only: Both buy and sell signals are generated only for the first candle that satisfies the conditions, ensuring clean and actionable signals.
Visual Customization: Full control over the appearance of the indicator, including signal shapes and line properties.
Works Across Assets: This indicator is applicable to any asset (stocks, forex, crypto) where price action relative to moving averages and VWAP is important.
リリースノート
Overview:
This indicator plots two Simple Moving Averages (SMA 20 and SMA 200) and the Volume-Weighted Average Price (VWAP) on the chart, with fully customizable colors and line thickness. Additionally, it provides buy and sell signals based on the price action relative to these indicators.

Buy Signal:
A buy signal is generated when a green candle (bullish candle) closes above the SMA 20, SMA 200, and VWAP without touching them (i.e., the low of the candle is above all three). This signal will only be plotted for the first such candle of the day to avoid signal clutter.

Sell Signal:
A sell signal is generated when a candle closes below the SMA 20, SMA 200, and VWAP without touching them (i.e., the high of the candle is below all three). Similar to the buy signal, it will only be plotted for the first qualifying candle of the day.

Customization:
SMAs and VWAP: Users can adjust the lengths, colors, and line thickness of the SMAs and VWAP to suit their preferences.
Signal Shape: You can choose from different shapes (arrow, circle, or cross) to represent the buy and sell signals on the chart.
Key Features:
First Candle Only: Both buy and sell signals are generated only for the first candle that satisfies the conditions, ensuring clean and actionable signals.
Visual Customization: Full control over the appearance of the indicator, including signal shapes and line properties.
Works Across Assets: This indicator is applicable to any asset (stocks, forex, crypto) where price action relative to moving averages and VWAP is important.
リリースノート
User Inputs:

Allows customization of parameters like SMA lengths, colors, and line thickness for SMA 20, SMA 200, and VWAP.
Enables setting target points for three profit levels.
Calculations:

Calculates SMA 20, SMA 200, and VWAP based on the close price.
Determines the minimum and maximum points for targets to ensure user inputs are within a specific range.
Signal Logic:

buySignal and sellSignal are initialized as false and reset daily.
Defines stop-loss levels based on the lowest (for long trades) or highest (for short trades) value among VWAP, SMA 20, and SMA 200.
Buy Signal:

A buy signal occurs if a green candle (close > open) is above all three indicators (SMA 20, SMA 200, and VWAP).
Sets the entry price, stop loss, and three target levels based on input values.
Creates labels and lines for the entry, stop loss, and each target on the chart.
Sell Signal:

A sell signal occurs if a red candle (close < open) is below all three indicators.
Similar to buy signals, it sets entry, stop loss, and target levels for short trades.
Plotting:

Plots the SMA 20, SMA 200, and VWAP on the chart using user-defined colors and thickness.
This code provides clear buy/sell points and visually marks entry, stop-loss, and target levels, which is useful for trend-following strategies based on moving averages and VWAP.
リリースノート
Inputs and Customization Options
SMA and VWAP lengths, colors, and line thickness:

sma20_length: Length of the Simple Moving Average (SMA).

sma20_color: Color of the SMA line.

sma20_thickness: Thickness of the SMA line.

vwap_color: Color of the Volume Weighted Average Price (VWAP) line.

vwap_thickness: Thickness of the VWAP line.

Target Points:

Enables the user to input target points for three levels.

showTargets: A checkbox to enable or disable targets.

Calculations
SMA and VWAP:

Calculates a 20-period SMA.

Calculates the VWAP.

Trading Signals
Buy Conditions:

The script checks if a green candle closes above both the 20-period SMA and the VWAP.

When the condition is met, it generates a buy signal with an entry point, stop loss (previous candle's low), and three target points.

Sell Conditions:

The script checks if a red candle closes below both the 20-period SMA and the VWAP.

When the condition is met, it generates a sell signal with an entry point, stop loss (previous candle's high), and three target points.

Signal Plotting
Labels and Lines:

Plots labels and lines for entry points, stop loss, and target levels when the conditions are met.

Customizable labels for "Entry," "Stop Loss," "Target 1," "Target 2," and "Target 3."

Plotting Indicators
SMA and VWAP:

Plots the 20-period SMA and VWAP on the chart based on the user-specified colors and thickness.

The script is designed to provide clear buy and sell signals based on price action relative to the SMA and VWAP, with customizable targets for better visualization and trading decisions.
Simple Moving Average (SMA)Volume Weighted Average Price (VWAP)

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?

免責事項