Strategy · Pine Script v5 · On the chart

Hotch Build File

by rajatjpatel· code credited to plewis22782

A strategy template rather than a finished system.

View on GitHub

Repaints

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code69
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago18 Oct 2022

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

69 lines of Pine Script v5 from message (5).txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

message (5).txt
/// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © plewis22782
//@version=5
//
strategy("Hotch build file", overlay=true, pyramiding=20, default_qty_type= strategy.percent_of_equity, default_qty_value = 10, calc_on_order_fills=true, slippage=0,commission_type=strategy.commission.percent,commission_value=0.014)
strat_dir_input = input.string(title="Strategy Direction", defval="all", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)
//////////////////////////////////////////////////////////////////////

string sessionInput = input.session("0600-1700", "Session")
string daysInput = input.string("1234567", tooltip = "1 = Sunday, 7 = Saturday")
sessionString = sessionInput + ":" + daysInput
inSession = not na(time(timeframe.period, sessionString))
bgcolor(inSession ? color.new(color.silver,85) : na)

// Testing Start End Dates

testStartYear = input(2020, "Backtest Start Year")
testStartMonth = input(10, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

//Stop date if you want to use a specific range of dates

testStopYear = input(2030, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
/////////////////////////////////////Insert code here

/////////////////////////////////////Trade and TP/SL logic
varip float currentLongSL= na
varip float currentShortSL= na
varip float currentLongTP= na
varip float currentShortTP= na
varip float closeLast =na

longCondition=  
shortCondition= 

longCloseCondition = 
shortCloseCondition = 

if (longCondition) and testPeriod() and strategy.position_size == 0 and inSession
    closeLast := close
    currentLongSL :=
    currentLongTP :=
    strategy.entry("Long", strategy.long)

if (shortCondition) and testPeriod() and strategy.position_size == 0 and inSession 
    closeLast := close
    currentShortSL :=
    currentShortTP :=
    strategy.entry("Short", strategy.short)
    
strategy.close("Long", longCloseCondition)  
strategy.close("Short", shortCloseCondition)  

plot(strategy.position_size <= 0 ? na : currentLongSL, color=color.red,  linewidth=2)
plot(strategy.position_size <= 0 ? na : currentLongTP, color=color.green,  linewidth=2)
plot(strategy.position_size <= 0 ? na : closeLast, color=color.blue, linewidth=2)

plot(strategy.position_size >= 0 ? na : currentShortSL, color=color.red,  linewidth=2)
plot(strategy.position_size >= 0 ? na : currentShortTP, color=color.green,  linewidth=2)
plot(strategy.position_size >= 0 ? na : closeLast, color=color.blue, linewidth=2)

Overview

Hotch Build File provides a session filter, weekday selection, backtest start and stop dates, a long, short or both direction setting, and plots for stop loss, take profit and entry price while a trade is open. The long and short entry, exit, stop and target conditions are left blank in the file, so it needs the author's own rules before it will work. It allows up to 20 stacked entries at 10 percent of equity each, with a small percentage commission.

Details

Published by

rajatjpatel on GitHub

Code credit

plewis22782, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • The strategy can add several entries in the same direction
  • 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
Strategy Directionstringallstrat_dir_input
Sessionsession0600-1700sessionInput
daysInputstring1234567daysInput
Backtest Start Yearint2020testStartYear
Backtest Start Monthint10testStartMonth
Backtest Start Dayint1testStartDay
Backtest Stop Yearint2030testStopYear
Backtest Stop Monthint12testStopMonth
Backtest Stop Dayint30testStopDay
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

361 stars

Forven S01512 — Monday Drift is a calendar-based long trading strategy designed to exploit time-based recurring market patterns. It tracks UTC calendar days and hours to enter a long position at a specified day and hour, holding it for a fixed duration until a

Strategy v6 Sessions & time
Updated 2 days ago · AGPL-3.0 GitHub repository of Forven S01512 - Monday Drift

This overlay strategy offers two selectable entry modes: a Bollinger squeeze on typical price and a simple moving-average cross. It filters trades by weekday, session, date range, and an optional news window, and can restrict direction or invert the side. Risk

Strategy v5 Volatility & bandsMoving averages
Updated 2 days ago · None stated GitHub repository of Boilerplate Configurable Strategy [Yosiet]
257 stars

Donald - Test Logic Futures is an overlay strategy designed for intraday futures trading. It combines kernel regression functions with exponential moving averages to evaluate price retracements and entry timing. Trades are filtered by session execution windows

Strategy v5 TrendMoving averages Repaints
Updated 7 weeks ago · None stated GitHub repository of Donald - Test Logic Futures

Daily Bias + FVG Strategy

by TradersPost
228 stars

This overlay strategy plots previous-day high and low, the daily open, and fair value gap zones on the price chart. It takes entries on a selectable timeframe when the FVG requirement and an optional session window allow them, then uses an ATR or fixed pip sto

Strategy v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Daily Bias + FVG Strategy
106 stars

This script monitors opening gap conditions and breakout behavior relative to the first candle's range across up to twenty configurable stock tickers. It detects whether following bars remain inside the opening range before breaking out, displaying the status

Strategy v4 Screeners & dashboardsBreakout Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 1St Bar GAP+BkOut Screener v2 by RM
53 stars

This strategy enters long or short on the price chart when price is on the correct side of a 200-period EMA, MACD agrees, RSI is not at the opposing extreme, ADX exceeds a threshold, volume beats a 20-bar average, and close breaks the recent high or low. A tim

Strategy v6 TrendOscillators & momentum
Updated 2 months ago · MPL-2.0 GitHub repository of BTCUSD 5M Optimized Strategy

More Sessions & time 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