Strategy · Pine Script v4 · On the chart

Yaroslav93rus

by DaniilOkrug· code credited to icewalk

This TradingView Pine Script strategy overlays two exponential moving averages (lengths 10 and 28) on the price chart along with markers for pivot highs and lows.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv4older, still runs
Lines of code125
Settings14inputs
LicenceMIT
Last update4 years ago15 Dec 2021

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

125 lines of Pine Script v4 from [Order] Yaroslav93rus.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

[Order] Yaroslav93rus.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © icewalk

//@version=4
strategy("[Order] Yaroslav93rus", overlay=true, margin_long=100, margin_short=100, max_bars_back=500)

ema_length1 = input(title="EMA 1 Length", defval=10, type=input.integer, group="EMA")
ema_length2 = input(title="EMA 2 Length", defval=28, type=input.integer, group="EMA")

leftLenH = input(title="Pivot High", type=input.integer, defval=10, minval=1, inline="Pivot High", group="Контрольные точки разворота")
rightLenH = input(title="/", type=input.integer, defval=10, minval=1, inline="Pivot High",group="Контрольные точки разворота")
colorH = input(title="", defval=color.green, inline="Pivot High",group="Контрольные точки разворота")

leftLenL = input(title="Pivot Low", type=input.integer, defval=10, minval=1, inline="Pivot Low", group="Контрольные точки разворота")
rightLenL = input(title="/", type=input.integer, defval=10, minval=1, inline="Pivot Low",group="Контрольные точки разворота")
colorL = input(title="", defval=color.red, inline="Pivot Low",group="Контрольные точки разворота")

showSupRes = input(title="Показать линии поддержки/сопротивления", defval=false, type=input.bool, group="Поддержка/сопротивление")
line_width = input(2, type = input.integer, title="SR Level line Width")
level_min_lengh = input(10, type = input.integer, title="Set minimum number of bars from level start to qualify a level", group="Поддержка/сопротивление")
y  = input("Lime", "Line Color", options=["Red", "Lime", "Orange", "Teal", "Yellow", "White", "Black"], group="Поддержка/сопротивление")
line_extend = input(false, type = input.bool, title = "Extend Level line Right", group="Поддержка/сопротивление") ? extend.right : extend.none
sr_tf = input("", type = input.resolution, title="SR Timeframe (Beta)", group="Поддержка/сопротивление")

// EMAs
ema1 = ema(close, ema_length1)
ema2 = ema(close, ema_length2)

// Pivots
ph = pivothigh(leftLenH, rightLenH)
pl = pivotlow(leftLenL, rightLenL)

plotshape(not na(ph), "Pivot high", offset=-rightLenH, location=location.abovebar, style=shape.xcross, color=colorH, size=size.tiny)
plotshape(not na(pl), "Pivot low", offset=-rightLenH, location=location.belowbar, style=shape.xcross, color=colorL, size=size.tiny)

// Support/Resistanse
//color function
colour(z) => z=="Red"?color.red:z=="Lime"?color.lime:z=="Orange"?color.orange:z=="Teal"?color.teal:z=="Yellow"?color.yellow:z=="Black"?color.black:color.white
 
//Legacy RSI calc
rsi_src = close, len = 9
up1 = rma(max(change(rsi_src), 0), len)
down1 = rma(-min(change(rsi_src), 0), len)
legacy_rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1))

//CMO based on HMA
length = 1
src1 = hma(open, 5)[1] // legacy hma(5) calculation gives a resul with one candel shift, thus use hma()[1]
src2 = hma(close, 12)
momm1 = change(src1)
momm2 = change(src2)
f1(m, n) => m >= n ? m : 0.0
f2(m, n) => m >= n ? 0.0 : -m
m1 = f1(momm1, momm2)
m2 = f2(momm1, momm2)
sm1 = sum(m1, length)
sm2 = sum(m2, length)
percent(nom, div) => 100 * nom / div
cmo_new = percent(sm1-sm2, sm1+sm2)

//Legacy Close Pivots calcs.
len5 = 2
h = highest(len5)
h1 = dev(h, len5) ? na : h
hpivot = fixnan(h1)
l = lowest(len5)
l1 = dev(l, len5) ? na : l
lpivot = fixnan(l1)

//Calc Values

rsi_new = rsi(close,9)
lpivot_new =  lpivot  // use legacy pivots calculation as integrated pivotlow/pivothigh functions give very different result
hpivot_new =  hpivot

sup = rsi_new < 25 and cmo_new > 50  and lpivot_new
res = rsi_new > 75 and cmo_new < -50  and hpivot_new
calcXup() =>
    var xup = 0.0
    xup :=  sup ? low : xup[1]
calcXdown() =>
    var xdown = 0.0
    xdown := res ? high : xdown[1]

//Lines drawing variables
tf1 = security(syminfo.tickerid, sr_tf, calcXup(), lookahead=barmerge.lookahead_on)
tf2  = security(syminfo.tickerid, sr_tf, calcXdown(), lookahead=barmerge.lookahead_on)

//SR Line plotting
var tf1_line = line.new(0, 0, 0, 0)
var tf1_bi_start = 0
var tf1_bi_end = 0
tf1_bi_start := change(tf1) ? bar_index : tf1_bi_start[1]
tf1_bi_end := change(tf1) ? tf1_bi_start : bar_index
if change(tf1)
    if (line.get_x2(tf1_line) - line.get_x1(tf1_line)) < level_min_lengh
        line.delete(tf1_line)
    tf1_line := line.new(tf1_bi_start, tf1, tf1_bi_end, tf1, color = colour(y), width = line_width, extend = line_extend)
line.set_x2(tf1_line, tf1_bi_end)

var tf2_line = line.new(0, 0, 0, 0)
var tf2_bi_start = 0
var tf2_bi_end = 0
tf2_bi_start := change(tf2) ? bar_index : tf2_bi_start[1]
tf2_bi_end := change(tf2) ? tf2_bi_start : bar_index
if change(tf2)
    if (line.get_x2(tf2_line) - line.get_x1(tf2_line)) < level_min_lengh
        line.delete(tf2_line)
    tf2_line := line.new(tf2_bi_start, tf2, tf2_bi_end, tf2, color =  colour(y), width = line_width, extend = line_extend)
line.set_x2(tf2_line, tf2_bi_end)

alertcondition(change(tf1) != 0 or change(tf2) != 0 , message = "New S/R line" )

if not showSupRes
    line.delete(tf1_line)
    line.delete(tf2_line)

// Open orders
longCondition = crossover(ema1, ema2)
if (longCondition)
    strategy.entry("Long", strategy.long)

shortCondition = crossunder(ema1, ema2)
if (shortCondition)
    strategy.entry("Short", strategy.short)

Overview

Yaroslav93rus optionally displays support and resistance levels based on user settings. The script includes legacy calculations for RSI and a custom CMO indicator derived from Hull Moving Averages plus highest close and deviation. Users can adjust EMA lengths, pivot detection parameters, pivot colors, and various options for the support resistance lines. The strategy uses a fixed margin for positions but does not include a stop loss by default and may have lookahead behavior in signal generation.

Details

Published by

DaniilOkrug on GitHub

Code credit

icewalk, as written in the script's header

Type

Strategy, Pine Script v4

Draws

On the price chart

Category

Moving averages, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time
  • 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
EMA 1 Lengthint10ema_length1
EMA 2 Lengthint28ema_length2
Pivot Highint10leftLenH
/int10rightLenH
colorHcolorcolor.greencolorH
Pivot Lowint10leftLenL
/int10rightLenL
colorLcolorcolor.redcolorL
Показать линии поддержки/сопротивленияboolfalseshowSupRes
SR Level line Widthint2line_width
Set minimum number of bars from level start to qualify a levelint10level_min_lengh
Line ColorstringLimey
Show all 14 settings
SettingTypeDefaultVariable
Extend Level line Rightboolfalseline_extend
SR Timeframe (Beta)timeframesr_tf
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

Omar Edited WF

by Alorse
330 stars

Omar Edited WF is a trading strategy overlay built around Williams Fractals and multiple Exponential Moving Averages. It detects high and low fractal pivot points over configurable lookback periods alongside three adjustable EMA trendlines. Long entries are ma

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of Omar Edited WF
257 stars

This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross

Strategy v5 TrendSupport & resistance Repaints
Updated 6 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar
106 stars

This strategy plots on the price chart and enters when three smoothed moving averages are aligned, RSI is on the matching side of 50, and a Williams fractal appears. An upward stack with RSI above 50 and a down fractal opens a long; the opposite setup opens a

Strategy v5 Moving averagesOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 3SmmaCrossUp + Fractal + RSI
104 stars

This strategy combines three Exponential Moving Averages with Williams Fractals to execute trend-following or mean-reverting trades. It analyzes price structure using short, medium, and long-term EMAs along with fractal highs and lows. Entries trigger when fra

Strategy v5 TrendMoving averages
Updated 3 years ago · MIT GitHub repository of 3MA and Fractals Strategy

This strategy executes trades based on pivot levels, an exponential moving average, and a multi-stage smoothing trend line. It identifies support and resistance points from pivot highs and lows, combining them with price relationship rules against a custom smo

Strategy v5 TrendMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of Binancash - Candle Strategy Futures on Binance

KC15

by benso87
24 stars

KC15 is a price-chart strategy that configures two moving averages, a Bollinger Band Width Percentile filter, and PMARP entry and exit thresholds for long and short trades. Users can switch each average between SMA and EMA, set lengths and colors, and toggle l

Strategy v5 Moving averagesVolatility & bands
Updated 4 years ago · MPL-2.0 GitHub repository of KC15

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers