Strategy · Pine Script v5 · On the chart

My First Indicator

by wynnforthework· code credited to huojichuanqi3

This strategy plots EMA 25 in yellow and EMA 100 in green on the price chart.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code32
Settings1inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago7 Oct 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

32 lines of Pine Script v5 from 策略/开源分享/入门课程btc1小时的课程代码.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

入门课程btc1小时的课程代码.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © huojichuanqi3 代码是录制视频随便举例的,误打误撞效果在btc 1小时交易对效果还行,仅作文案用,实盘请知晓风险!
   
//@version=5
strategy("我的第一个指标", shorttitle="短名称1", overlay=true, initial_capital=1000)
atrNo = input(14,'atr长度')

ema25 = ta.ema(close, 25)
ema100 = ta.ema(close, 100)
l1 = plot(ema25, color = color.yellow, title = 'ema25')
l2 = plot(ema100, color = color.green, title = 'ema100')


buy = ta.crossover(ema25,ema100)  //金叉
sell = ta.crossover(ema100,ema25)  //死叉

//atr满足上涨条件  今天的atr数值大于前两天的 布尔型
atr = ta.atr(atrNo) > ta.atr(atrNo)[2]

//vol 满足成交量上涨条件 
vol = volume > volume[1]
//开多单
if buy and atr and vol  //满足金叉 加上 满足atr2上涨 加上满足vol也是上涨
    strategy.entry('long1', strategy.long, 1)
if sell
    strategy.close('long1', qty_percent=100 ,comment='关掉long1这个多单')
// plotchar(buy, text = 'buy', color=color.green)
// plotchar(sell, text = 'sell', color=color.red)

// l_color = (ema25 > ema100) ? color.green : color.red  //如果ema25也就是黄线大于ema100这根绿线 那么就是绿色,反之就是红色

// fill(l1, l2 ,color = color.new(l_color, 80))

Overview

My First Indicator generates buy signals on EMA 25 crossing above EMA 100 when ATR length 14 rises over two prior bars and volume exceeds prior bar. It opens a long position of 1 unit on signal. It closes the long position fully when EMA 100 crosses above EMA 25. The ATR input length controls volatility filter sensitivity. No stop loss is applied.

Details

Published by

wynnforthework on GitHub

Code credit

huojichuanqi3, as written in the script's header

Draws

On the price chart

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
atr长度int14atrNo
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Prototype

by hasnocool
106 stars

This strategy overlays Supertrend-style ATR trailing stop levels on the price chart alongside multi-period moving averages, volume metrics, and Bollinger Bands. It flags trend direction changes using an ATR offset channel, plotting buy and sell signals directl

Strategy v4 TrendVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of Prototype

This strategy enters long or short when eight conditions align over the last two bars. It requires EMA 10 and EMA 55 alignment on the one-hour, four-hour and daily charts, a positive ADX slope, matching monitor direction, and price relative to a 400-bar point

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ruckard ABCBitcoin TradingLatino B002
8 stars

This overlay strategy combines three distinct SuperTrend levels with multiple moving averages and volume profile analytics on the main price chart. It calculates trend directions using three configurable ATR periods and multipliers alongside SMA, EMA, and HMA

Strategy v5 TrendVolatility & bands
Updated 4 years ago · None stated GitHub repository of ATR 3Lvls VP Strategy
4 stars

This trend-following strategy generates long and short entries when a fast EMA crosses a slow EMA, overlaying directly on the price chart. To reduce false signals, it applies four configurable fakeout filters: volume moving average threshold, consecutive bar c

Strategy v6 TrendMoving averages
Updated 2 months ago · MIT GitHub repository of Fakeout-Confirmed Strategy
2 stars

This overlay strategy enters long when a fast EMA crosses above a slow EMA, the candle closes above the fast EMA and above its open, and volume is at least a set multiple of its SMA. Position size defaults to 95 percent of equity with no pyramiding. It exits w

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of EMA20/50 ATR Trail Spot
2 stars

The SuperTrend Regime Confluence strategy combines an adaptive SuperTrend indicator with market regime detection to generate trading signals. It computes a composite conviction score using an ADX regime lookback, a trend EMA, and a volume moving average. Trade

Strategy v6 TrendVolatility & bands
Updated 2 weeks ago · MIT GitHub repository of SuperTrend Regime Confluence

More Moving averages scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers