Strategy vault / DCA & fixed investment
Fixed Investment and Take Profit Script
Pine Script strategy by Zer3192.
Pine ScriptDCA & fixed investment
The original spec has no written description. Read the source below.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 5 | Maximum loss percentage |
| v_input_2 | 3 | Take profit value |
Source Pine Script
//@version=4
strategy("Regular Investment Profit Taking", overlay=true)
//Define the maximum loss percentage
maxLossPercent = input(title="Maximum loss percentage", type=float,defval=5)
//Define take-profit number
stopProfitVal = input(title="Take profit value", type=float, defval=3)
//The main contract holds a long position
longCondition = crossover(open, close) //The main contract goes long by breaking through the closing price horizontally at the opening price
if (longCondition)
strategy.entry("Long", strategy.long, comment="Open Long")
//Stop-loss condition
//if (strategy.position_size > 0)
//strategy.exit("Exit long", stop=strategy.position_avg_price * (1 - maxLossPercent/100))
//Profit Taking Conditions
profitExit = strategy.position_avg_price + stopProfitVal
if (strategy.position_size > 0)
strategy.exit("Exit long", limit = profitExit)
Published by Zer3192 on the FMZ strategy square · last modified 2023-01-29. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Fixed-Investment-and-Take-Profit-Script.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- Dollar Cost Averaging Investment StrategyPine Script · DCA & fixed investment · 1d
- Dynamic DCA based Cryptocurrency Quantitative Trading StrategyPine Script · DCA & fixed investment · 1h
- Dynamic Position Building StrategyPine Script · DCA & fixed investment · 1h
- Fibonacci Zone DCA StrategyPine Script · DCA & fixed investment · 1d
- Multi Indicator Confirmation EMA Breakout with DCA and Dynamic Take Profit StrategyPine Script · DCA & fixed investment · 1d
- Bollinger Band and RSI Mixing with DCA StrategyPine Script · DCA & fixed investment · 1d