Strategy · Pine Script v5 · On the chart

Buy/Sell Test for More Freq

by hasnocool· code credited to svatvlad1993

This strategy executes high-pyramiding trades using a combination of dynamic support and resistance breakout channels, the Supertrend indicator, and an array of predefined price levels.

View on GitHub

GitHub stars106on the repository
Pine versionv5runs as is
Lines of code68
Settings2inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 2024

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

68 lines of Pine Script v5 from Buy-Sell on the levels.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

Buy-Sell on the levels.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © svatvlad1993
//@version=5
strategy("test for more freq","BUY/SELL test for more freq",pyramiding=100 , overlay=true, currency=currency.USDT, commission_type=strategy.commission.percent,
     commission_value=0.05,initial_capital=5000, margin_long=10, margin_short=10, max_lines_count = 500, max_labels_count = 500, max_bars_back = 5000)//, default_qty_type=strategy.percent_of_equity, default_qty_value=4)
// tail-resistance for buy
var last_min = low[0]
var last_max = high[0]
var permission_for_buy = 0
lowest0 = ta.lowest(low,100)
highest0 = ta.highest(high,100)
if close > last_max
    if lowest0 != 0
        last_min := lowest0
    else
        last_min := close - (close * 0.02)
    last_max := high
    permission_for_buy := 1
    
if close < last_min
    last_min := low
    if highest0 != 0
        last_max := highest0
    else
        last_max := close + (close * 0.02)
    permission_for_buy := 0
plot_diaps1 = plot(permission_for_buy != 0? na : last_max, title='Max',color=color.new(#ff0000, 95),style=plot.style_cross,trackprice=true )
plot_diaps2 = plot(permission_for_buy != 0? na : last_min, title='Min',color=color.new(#ff0000, 95),style=plot.style_cross,trackprice=true )
plot_diaps3 = plot(permission_for_buy != 1? na : last_max, title='max',color=color.new(color.green, 95),style=plot.style_cross,trackprice=true )
plot_diaps4 = plot(permission_for_buy != 1? na : last_min, title='min',color=color.new(color.green, 95),style=plot.style_cross,trackprice=true )
fill(plot_diaps1, plot_diaps2,color=color.new(#ff0000, 95))
fill(plot_diaps3, plot_diaps4,color=color.new(color.green, 95))
//Supertrend
atrPeriod = input(10, "ATR Length")
factor = input.float(2.5, "Factor", step = 0.01)
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.teal, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.maroon, style=plot.style_linebr)
fill(bodyMiddle, upTrend, color.new(color.teal, 75), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.maroon, 75), fillgaps=false)
// levels sell/buy
var float[] price_to_sellBue = array.from(1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.071, 1.082, 1.093, 1.104, 1.115, 1.126, 1.137, 1.148, 1.159, 1.171, 1.183, 1.195, 1.207, 1.219, 1.231, 1.243, 1.255, 1.268, 1.281, 1.294, 1.307, 1.32, 1.333, 1.346, 1.359, 1.373, 1.387, 1.401, 1.415, 1.429, 1.443, 1.457, 1.472, 1.487, 1.502, 1.517, 1.532, 1.547, 1.562, 1.578, 1.594, 1.61, 1.626, 1.642, 1.658, 1.675, 1.692, 1.709, 1.726, 1.743, 1.76, 1.778, 1.796, 1.814, 1.832, 1.85, 1.869, 1.888, 1.907, 1.926, 1.945, 1.964, 1.984, 2.004, 2.024, 2.044, 2.064, 2.085, 2.106, 2.127, 2.148, 2.169, 2.191, 2.213, 2.235, 2.257, 2.28, 2.303, 2.326, 2.349, 2.372, 2.396, 2.42, 2.444, 2.468, 2.493, 2.518, 2.543, 2.568, 2.594, 2.62, 2.646, 2.672, 2.699, 2.726, 2.753, 2.781, 2.809, 2.837, 2.865, 2.894, 2.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buy
for i = 0 to 139
    if array.get(price_to_sellBue, i) >= open[0] and array.get(price_to_sellBue, i) <= close[0] and
     direction[0] < 0 and permission_for_buy != 0
        if array.get(count_of_orders, i) > 0
            strategy.order(str.tostring(i), strategy.long, 15)
            g = array.get(count_of_orders, i)
            array.set(count_of_orders, i, g - 2)
            break
var SELL_amount = 0
var strategy_short = 0
for i = 0 to 139
    if array.get(price_to_sellBue, i) <= open[0] and array.get(price_to_sellBue, i) >= close[0]
        for j = 0 to i-1 
            if array.get(count_of_orders, j) != 2
                strategy_short := strategy_short + 1
                array.set(count_of_orders, j, 2)
                SELL_amount := SELL_amount + 15
        strategy.order(str.tostring(strategy_short),strategy.short, SELL_amount)
        SELL_amount := 0
        break
// добавить SMA и продавать при низходящем тренде
plot(strategy.equity)
Expand (106 lines)

Overview

Buy/Sell Test for More Freq tracks recent 100-bar extremes to permit buys on breakouts and manages downside boundaries through dynamic channel bands. Overlay plots display the trading channel ranges and Supertrend direction directly on the price chart. Key inputs configure the Supertrend ATR length and multiplier factor. The strategy permits up to 100 concurrent pyramid entries and does not define a protective stop loss.

Details

Published by

hasnocool on GitHub

Code credit

svatvlad1993, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Support & resistance, Breakout

Markets

Crypto, Forex

Timeframes

M1-M5, M15-H1

Risk Notes

  • The strategy can add several entries in the same direction
  • The strategy enters trades without a stop loss

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

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

SettingTypeDefaultVariable
ATR Lengthint10atrPeriod
Factorfloat2.5factor
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

This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr

Strategy v6 BreakoutTrend
Updated today · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout
257 stars

This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos

Strategy v6 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Best Chart 1m Strategy Candle Bar

This trend breakout strategy plots Donchian Channels consisting of upper, lower, and middle bands directly on the main price chart. Long positions enter when price touches the upper channel and pulls back to or below the middle band, placing a stop loss at the

Strategy v6 TrendBreakout
Updated 2 months ago · MPL-2.0 GitHub repository of Donchian Strategy - Dynamic TP, Fixed SL, 1% Risk, Daily Target
43 stars

This strategy executes trades on short-term cryptocurrency charts using a combination of pivot support and resistance levels and a multi-pole smoothed trend filter. Entries trigger when price crosses the smoothed trend line and confirms above or below a short-

Strategy v5 TrendBreakout Repaints
Updated 2 years ago · None stated GitHub repository of SOL 1m - Strategy Candle Bar
16 stars

This strategy trades Donchian breakouts measured on weekly bars while orders execute on the chart timeframe. It allows long and short entries when price breaks the prior weekly channel and exits against the shorter weekly channel. Position size risks a set per

Strategy v6 TrendBreakout
Updated 11 months ago · None stated GitHub repository of Seykota Alt 4: Weekly Donchian

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