Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mohammad95labbaf/pso-ga-strategy-optimization
This repository focuses on optimizing a trend-based trading strategy for the EURUSD currency pair. By combining PSO and GA, the goal is to maximize returns while minimizing risk. The strategy considers buy and sell signals based on Supertrend and EMA conditions, with a fixed commission of 3 pips per trade.
https://github.com/mohammad95labbaf/pso-ga-strategy-optimization
backtesting backtesting-trading-strategies exponential-moving-average forex forex-trading genetic-algorithm genetic-algorithms geneticalgorithm indicator moving-average pandas particle-swarm-optimization pyswarms supertrend technical-analysis technical-indicators trade trading-strategies
Last synced: 1 day ago
JSON representation
This repository focuses on optimizing a trend-based trading strategy for the EURUSD currency pair. By combining PSO and GA, the goal is to maximize returns while minimizing risk. The strategy considers buy and sell signals based on Supertrend and EMA conditions, with a fixed commission of 3 pips per trade.
- Host: GitHub
- URL: https://github.com/mohammad95labbaf/pso-ga-strategy-optimization
- Owner: mohammad95labbaf
- Created: 2024-02-18T09:22:01.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-18T11:52:08.000Z (9 months ago)
- Last Synced: 2024-02-18T14:24:03.728Z (9 months ago)
- Topics: backtesting, backtesting-trading-strategies, exponential-moving-average, forex, forex-trading, genetic-algorithm, genetic-algorithms, geneticalgorithm, indicator, moving-average, pandas, particle-swarm-optimization, pyswarms, supertrend, technical-analysis, technical-indicators, trade, trading-strategies
- Language: Jupyter Notebook
- Homepage:
- Size: 1.89 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Trend-Based Strategy Optimization using PSO and GA
## Overview
This repository contains code and instructions for optimizing a trend-based trading strategy using Particle Swarm Optimization (PSO) and Genetic Algorithm (GA). The strategy focuses on the EURUSD currency pair, utilizing 90% of 1-hour candlestick data.## Strategy Description
- **Objective**: Maximize returns while minimizing risk.
- **Conditions for Buy Signal**:
- Close price is greater than the Supertrend value.
- Close price is greater than the Exponential Moving Average (EMA).
- **Conditions for Sell Signal**:
- Close price is less than the Supertrend value.
- Close price is less than the Exponential Moving Average (EMA).
- **Commission**: Considered as 3 pips per trade.
- **Margin**: Not used in this strategy.## Repository Structure
- `data/`: Store your historical EURUSD candlestick data (EURUSD_H1.CSV).
- `notebooks/`: Jupyter Notebook files for strategy development and optimization (PSO_GA_Strategy_Optimization.ipynb).
- `pine_script/`: Pine Script code for implementing the strategy on TradingView (PSO_GA_Strategy_Optimization.txt).## Getting Started
1. **Data Preparation**:
- Collect historical EURUSD 1-hour candlestick data.
- Preprocess and clean the data (handle missing values, outliers, etc.).2. **Strategy Development**:
- Implement the Supertrend and EMA indicators.
- Define buy/sell signals based on the conditions mentioned above.3. **Optimization**:
- Use PSO and GA to find optimal parameter values for Supertrend and EMA.
- Optimize for maximum return while considering the commission.4. **Backtesting**:
- Backtest the strategy using historical data.
- Calculate performance metrics (e.g., Sharpe ratio, drawdown).5. **Recommendations for Future Work**:
- **RSI or CCI Integration**: Consider adding Relative Strength Index (RSI) or Commodity Channel Index (CCI) to enhance the strategy.
- **Different ATR Types**: Explore different types of Average True Range (ATR) calculations.
- **Multiple Moving Averages**: Experiment with various moving average types (e.g., EMA, WMA, ALMA).
- **Dual Supertrends**: Implement short-term and long-term Supertrends.
- **Multitime Frame Analysis**: Extend the strategy to other time frames (e.g., 4-hour or daily candlesticks).
- **SL and TP Determination using ATR**: Use ATR to set stop loss (SL) and take profit (TP) levels.
- **Trailing Stop**: Add a trailing stop feature.
- **Margin Optimization**: Optimize margin settings for risk management.## Disclaimer
This code is provided for educational and research purposes only. It is **not financial advice**. Use it at your own risk. Always consult with a qualified financial professional before making any investment decisions.Feel free to customize this template with additional details specific to your project. Good luck with your strategy optimization and future enhancements! 🚀📈.