Strategy vault / Machine learning
Logarithmic Price Forecasting Strategy
This strategy uses logarithmic functions to model price changes based on the standard deviation and mean of trading volume to calculate z-score as input parameters to the logarithmic function for predicting future…

Overview
This strategy uses logarithmic functions to model price changes based on the standard deviation and mean of trading volume to calculate z-score as input parameters to the logarithmic function for predicting future prices.
Strategy Principles
- Calculate ROC value of closing price, accumulate positive values into volume_pos and negative values into volume_neg
- Calculate the difference between volume_pos and volume_neg as net_volume
- Calculate standard deviation net_std and mean net_sma of net_volume
- Calculate z-score by dividing net_sma by net_std
- Use closing price, 20-day standard deviation of closing price and z-score as parameters into the logistic function to predict next period's price
- Long when predicted price is above current actual price * 1.005, close position when below * 0.995
Advantage Analysis
This strategy combines statistical information of trading volume and price prediction using logarithmic functions.
Advantages are:
- Utilizes long-short difference in trading volume to gauge market sentiment
- Logarithmic function fits price change curve well for prediction
- Simple and straightforward strategy, easy to implement
Risk Analysis
Some risks also exist in this strategy:
- Trading volume indicators have lag, cannot timely reflect market changes
- Logarithmic prediction not always accurate, can be misleading
- Lack of stop loss measures inability to control losses
Risks can be reduced by:
- Combine other indicators to judge reliability of volume signals
- Optimize parameters of logarithmic function to improve prediction accuracy
- Set stop loss lines to limit maximum loss per trade and overall
Optimization Directions
This strategy can be further optimized by:
- Adopt machine learning to dynamically optimize logarithmic function
- Incorporate volatility indicators to adjust position sizing
- Add Bayesian filtering to filter out invalid signals
- Combine with breakout strategies to enter on breakout points
- Use association rules to detect volume-price divergence signals
Combining multiple methods can further improve stability and profitability.
Conclusion
This strategy integrates statistical indicators of trading volume and logarithmic prediction into a unique quantitative trading methodology. With continuous optimization, it can become an efficient and stable automated trading system. By leveraging machine learning and portfolio optimization theories, we are confident to further improve its trading performance.
Source Pine Script
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-10 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Logistic", overlay=true )
volume_pos = 0.0
volume_neg = 0.0
roc = roc(close, 1)
for i = 0 to 100
if (roc > 0)
volume_pos := volume
else
volume_neg := volume
volume_net = volume_pos - volume_neg
net_std = stdev(volume_net, 100)
net_sma = sma(volume_net, 10)
z = net_sma / net_std
std = stdev(close, 20)
logistic(close, std, z) =>
m = (close + std)
a = std / close
pt = m / ( 1 + a*exp(-z))
pt
pred = logistic(close, std, z)
buy = pred > close * 1.005
sell = pred < close * 0.995
color = strategy.position_size > 0? #3BB3E4 : strategy.position_size == 0? #FF006E : #6b6b6b
barcolor(color)
if (buy == true)
strategy.entry("Long", strategy.long, comment="Open L")
if (sell == true)
strategy.close("Long", comment="Close L")
Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-20. 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/Logarithmic-Price-Forecasting-Strategy.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
- AI Driven Dynamic Volatility Adaptive Trend Breakout Trading StrategyPine Script · Machine learning · 2d
- AI Powered Volatility Price System Divergence Trading StrategyPine Script · Machine learning · 1h
- Configurable BBRSIAroon Strategy BacktestPine Script · Machine learning · 5m
- Dual Moving Average Matching Strategy Based on Bollinger BandsPine Script · Machine learning · 1h
- Dynamic Weighted Moving Average Trading StrategyPine Script · Machine learning · 1d
- EMA and RSI Quantitative Trading StrategyPine Script · Machine learning · 1h