0bps

Strategy vault / Scalping

Extreme Short term Scalping Strategy

The extreme short-term scalping strategy attempts to establish short positions when prices approach or break support lines and sets very small stop loss and take profit levels for high frequency trading. The strategy…

Author
ChaoZhang
Complexity
Intermediate · 62 lines
Parameters
8
Backtest bar
4h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

The extreme short-term scalping strategy attempts to establish short positions when prices approach or break support lines and sets very small stop loss and take profit levels for high frequency trading. The strategy exploits short-term price breakthroughs to capture market fluctuations for profits.

Strategy Logic

The strategy first calculates the linear regression line of prices. If the actual closing price is lower than the forecast closing price, long positions are established. If the actual closing price is higher than the forecast closing price, short positions are established. Stop loss and take profit are set to very small number of pips. The strategy allows choosing only long, only short or all direction trading.

Key parameters include:

  • Source price: closing price
  • Length of linear regression line: 14
  • Offset: 1
  • Trading direction: all/only buy/only sell
  • Stop loss and take profit in pips: very small fixed pips or minimum tick pips

The main idea of the strategy is to capture short-term price breakthroughs of moving averages. When prices approach or break through support or resistance lines, timely establish positions. And set very small stop loss and take profit to realise profit then close positions immediately, repeating the process.

Advantage Analysis

The strategy has the following advantages:

  1. High trading frequency, suitable for high frequency trading, can capture more short-term price fluctuations
  2. Very small stop loss and take profit helps control single loss
  3. Can flexibly choose trading direction to adapt to different market environments
  4. Easy to implement with simple logic

Risk Analysis

There are also some risks:

  1. Price gaps may lead to expanded losses
  2. High transaction costs
  3. Signal errors may happen and need timely attention and optimisation
  4. Requires continuous market monitoring

Corresponding risk management measures include:

  1. Disable overnight trading
  2. Optimise stop loss and take profit to reduce transaction cost impacts
  3. Test and optimise parameters to reduce wrong signals
  4. Pay close attention to the market

Optimisation Directions

Further optimisation directions include:

  1. Add other indicators to filter signals and reduce wrong trades
  2. Dynamically adjust stop loss and take profit
  3. Optimise parameters to reduce overfitting
  4. Consider transaction cost impacts for reasonable stop loss and take profit configuration
  5. Test stability across products and timeframes

Summary

The extreme short-term scalping strategy is a typical high frequency trading strategy. By establishing positions around key price levels and setting very small stop loss and take profit, it captures short-term price fluctuations. Although it can achieve high returns, there are also certain risks. With continuous testing and optimisation, the strategy can be further enhanced for stability and profitability.

Parameters

NameDefaultWhat it controls
v_input_1_close0Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_214Length
v_input_3trueoffset
v_input_4100gap_tick
v_input_5300fixedTP
v_input_6100fixedSL
v_input_7trueuseFixedSLTP
v_input_80Direction of order: ALL | BUY ONLY | SELL ONLY

Source Pine Script

/*backtest
start: 2024-01-09 00:00:00
end: 2024-01-16 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Extreme Scalping", overlay=true )
src = input(close,title="Source")
len = input(defval=14, minval=1, title="Length")
offset = input(1)
out = linreg(src, len, offset)
plot(out)

gap_tick=input(100)
fixedTP=input(300)
fixedSL=input(100)
useFixedSLTP=input(true)
direction=input(defval="ALL",title="Direction of order",options=["ALL","BUY ONLY","SELL ONLY"])
gap=gap_tick*syminfo.mintick
plot(out+gap,color=color.red)
plot(out-gap,color=color.green)

tp=useFixedSLTP?fixedTP:gap_tick
sl=useFixedSLTP?fixedSL:gap_tick

longCondition = close<(out-gap) and (direction=="ALL" or direction=="BUY ONLY")
shortCondition = close>(out+gap) and (direction=="ALL" or direction=="SELL ONLY")

if (longCondition)
    strategy.entry("Long", strategy.long)
    strategy.exit("exit long","Long",profit = tp,loss = sl)
    

if (shortCondition)
    strategy.entry("Short", strategy.short)
    strategy.exit("exit short","Short",profit =tp,loss=sl)
    
// === Backtesting Dates === thanks to Trost

// testPeriodSwitch = input(true, "Custom Backtesting Dates")
// testStartYear = input(2019, "Backtest Start Year")
// testStartMonth = input(10, "Backtest Start Month")
// testStartDay = input(3, "Backtest Start Day")
// testStartHour = input(0, "Backtest Start Hour")
// testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
// testStopYear = input(2019, "Backtest Stop Year")
// testStopMonth = input(12, "Backtest Stop Month")
// testStopDay = input(31, "Backtest Stop Day")
// testStopHour = input(23, "Backtest Stop Hour")
// testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
// testPeriod() =>
//     time >= testPeriodStart and time <= testPeriodStop ? true : false
// isPeriod = testPeriodSwitch == true ? testPeriod() : true
// // === /END

// if not isPeriod
//     strategy.cancel_all()
//     strategy.close_all()
        

Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-17. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Extreme-Short-term-Scalping-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open