Strategy · Pine Script v4 · Own pane

8 Whittle Down

by hasnocool

This strategy executes short positions during the end-of-day session (14:29–15:00) when the price is below the 200-day simple moving average.

View on GitHub

GitHub stars106on the repository
Pine versionv4older, still runs
Lines of code44
Settings4inputs
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

44 lines of Pine Script v4 from 8 Whittle Down.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

8 Whittle Down.pine
//              @version=4
strategy("8 Whittle Down", "8 WD", 1, initial_capital=0)
//              DUAL ENTRIES
//              ADDS ON MORE SHARES IF THE PILOT TRADE DOES NOT REACH PROFIT TARGET
//              RED     LINE        == STOP LOSS LINE
//              GREEN   LINE        == PROFIT TARGET FOR THE 1ST TRADE
//              YELLOW  LINE        == ADD ON SHARES TO THE TRADE
//              WHITE   LINE        == PROFIT TARGET FOR THE 1ST & SECOND TRADE COMBINED
StopLossPerc        = input(1.15, "Total Stop Loss", step=0.01)
T2EntTrgPerc        = input(1.05, "Enter Second trade @ what higher 5%?", step=0.01)    //  BUY STOP LIMIT ONLY WHEN ONE TRADE IS ALREADY OPEN & AIMS TO BUY DOUBLE THE OWNED SHARES AT A HIGHER ENTRY PRICE // YELLOW LINE
T1ProfTrgPerc       = input(0.95, "First Trade Profit % Target", step=0.01)
T2ProfTrgPerc       = input(0.90, "Second Trade Profit % Target", step=0.01)
RiskRange           = close*(StopLossPerc)-1
Shares              = floor(1000*1000/RiskRange) / 3                                    //  SPLITS THE RISK OVER THREE TRADES
F1                  = close < sma(security(syminfo.tickerid, "D", close[2]), 200)       //  HIGH OF OLD DATA -- SO NO REPAINTING
F2                  = strategy.opentrades == 0
buyTime             = time(timeframe.period, "1429-1500")                               //  BUY AT THE END OF THE  DAY
 
 
StopLossLine        = strategy.position_avg_price * StopLossPerc
StopLossCol         = strategy.opentrades != 0 ? #FF0000 : na
plot(StopLossLine,  "StopLossLine", StopLossCol, 2)
strategy.cancel_all()                                                                   //  CANCELS ALL ORDERS: BECAUSE THE SYSTEM WILL ADD A BUY STOP LIMIT ORDER FOR ENTRY TWO
///==============   ENTRY 1   ==============   
if  F1 and buyTime and strategy.opentrades == 0
    strategy.entry("S1", false, qty=Shares)
T1Prof              = strategy.position_avg_price * T1ProfTrgPerc
plot(T1Prof,        "1st Profit Target", strategy.opentrades == 1 ? #00FF00 : na, 2)
strategy.exit("S1 Ex", "S1", limit=T1Prof, stop=StopLossLine )
///==============   ENTRY 2   ==============   
T2EntryTrg          = strategy.position_avg_price * T2EntTrgPerc // enters on higher target than 1st entry
plot(T2EntryTrg,    "ent2EntryTrg", strategy.opentrades == 1 ? color.yellow : na, 2)
    
    
if  strategy.opentrades == 1
    strategy.order("S2", false, stop=T2EntryTrg, limit= T2EntryTrg, qty=Shares * 2)     //  BUYS MORE SHARES
T2Prof              = strategy.position_avg_price * T2ProfTrgPerc
    
T2Col               = strategy.opentrades == 2 ? color.white : na
plot(T2Prof,        "2nd Profit Target", T2Col, 2)
    
    
strategy.exit("S2 Ex", "S2", limit=T2Prof, stop=StopLossLine )
Expand (94 lines)

Overview

If price moves higher against the initial short trade, it scales into the position by submitting a second short order with double the initial quantity. Both trades are managed with percentage-based profit targets and a shared stop loss calculated from the average position price. It plots the active stop loss, scale-in trigger, and profit levels on the chart.

Details

Published by

hasnocool on GitHub

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Trend, Moving averages, Sessions & time, Mean reversion

Markets

Stocks

Timeframes

M15-H1

Risk Notes

  • The strategy can add several entries in the same direction

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

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

SettingTypeDefaultVariable
Total Stop Lossfloat1.15StopLossPerc
Enter Second trade @ what higher 5%?float1.05T2EntTrgPerc
First Trade Profit % Targetfloat0.95T1ProfTrgPerc
Second Trade Profit % Targetfloat0.90T2ProfTrgPerc
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 mean-reversion strategy plots Bollinger Bands and a long-term moving average directly on the price chart. It enters trades when price candles penetrate the outer Bollinger Bands beyond a user-defined body percentage, anticipating a price reversal. Entries

Strategy v5 Mean reversionVolatility & bands
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner PRO [Alorse]
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 6 weeks ago · None stated GitHub repository of Donald - Test Logic Futures

Bollinger Bands Strategy

by cklose2000
105 stars

This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po

Strategy v5 Volatility & bandsMoving averages
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Strategy
53 stars

This strategy identifies long entry opportunities based on short-term price pullbacks below a major trend filter. It enters long when three consecutive lower closes occur below the 200-period simple moving average, followed by the current bar closing back abov

Strategy v6 TrendMoving averages
Updated 2 months ago · MPL-2.0 GitHub repository of Ivan Scherman Pattern - TP/SL
13 stars

This strategy evaluates market trend direction using a Noro TrendRibbon and creates a price corridor based on recent moving-average extremes, plotting directly on the price chart. It executes long entries when price dips below the corridor during an upward tre

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ruckard Noro TrendRibbon G004

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