指定

# Import necessary libraries
import pandas as pd

# Define parameters
stop_loss_percentage = 0.02  # Set stop loss percentage (2% in this example)
take_profit_percentage = 0.05  # Set take profit percentage (5% in this example)

# Read historical price data
df = pd.read_csv("historical_data.csv")  # Replace with your historical data file or API integration

# Calculate moving averages
df['SMA_50'] = df['Close'].rolling(window=50).mean()
df['SMA_200'] = df['Close'].rolling(window=200).mean()

# Initialize variables
position = None
entry_price = 0.0

# Start trading loop
for i in range(200, len(df)):
    current_price = df['Close'].iloc[i]

    # Check for entry conditions
    if position is None and df['SMA_50'].iloc[i] > df['SMA_200'].iloc[i]:
        position = 'long'
        entry_price = current_price
        print(f"Enter long position at {entry_price}")

    elif position is None and df['SMA_50'].iloc[i] < df['SMA_200'].iloc[i]:
        position = 'short'
        entry_price = current_price
        print(f"Enter short position at {entry_price}")

    # Check for exit conditions
    if position == 'long' and current_price >= (1 + take_profit_percentage) * entry_price:
        position = None
        exit_price = current_price
        print(f"Exit long position at {exit_price}")
        profit = exit_price - entry_price
        print(f"Profit: {profit}")

    elif position == 'long' and current_price <= (1 - stop_loss_percentage) * entry_price:
        position = None
        exit_price = current_price
        print(f"Exit long position at {exit_price}")
        loss = exit_price - entry_price
        print(f"Loss: {loss}")

    elif position == 'short' and current_price <= (1 - take_profit_percentage) * entry_price:
        position = None
        exit_price = current_price
        print(f"Exit short position at {exit_price}")
        profit = entry_price - exit_price
        print(f"Profit: {profit}")

    elif position == 'short' and current_price >= (1 + stop_loss_percentage) * entry_price:
        position = None
        exit_price = current_price
        print(f"Exit short position at {exit_price}")
        loss = entry_price - exit_price
        print(f"Loss: {loss}")

応答済み

1
開発者 1
評価
(2)
プロジェクト
2
0%
仲裁
1
0% / 0%
期限切れ
2
100%
2
開発者 2
評価
(42)
プロジェクト
62
8%
仲裁
12
58% / 42%
期限切れ
1
2%
3
開発者 3
評価
(35)
プロジェクト
50
42%
仲裁
3
33% / 33%
期限切れ
4
8%
4
開発者 4
評価
(6)
プロジェクト
10
50%
仲裁
6
17% / 50%
期限切れ
3
30%
仕事中
5
開発者 5
評価
(5)
プロジェクト
4
50%
仲裁
4
0% / 75%
期限切れ
0
類似した注文
am looking for who help me convert tradingview indicator to mt5 car trading strategy and make sure you are an expert before u apply to this and also my budget for this is 30$ so the name of the indicator is Breaker Blocks with Signals (LuxAlgo)
I'm looking for who can help me with converting tradingview indicator to mt5 car trading strategy, And am in need of an expert for this, the indicator name : Breaker Blocks with Signals [LuxAlgo] ### 1. ** Entry Condition **: - ** For Long**: The trade is entered **after BB + ** is confirmed. - ** For Short **: The trade is entered **after BB -** is confirmed. ### 2nd **Stop Loss **: - ** For long Entries **: stop
Hello Developers, I’m seeking a professional and highly experienced MQL4 developer to assist with converting an existing TradingView indicator into a fully functional MT4 indicator (.exe file). The source code will be provided , and the key task is ensuring that all features and functionality are preserved in the MT4 version. Project Requirements: Proven experience in converting TradingView Pine Script to MQL4
I would like to have an EA built for MT4 that utilizes Tradingview indicators. The strategy will use two Hull suites, two market bias indicators, and parabolic sar. Exit strategy will have the option of one take profit, or multiple take profits. Also, the option to use a stop loss or a trail stop. I want to be able to select between (ATR, $, or %) for setting profit targets and stop loss
Hello, I hope you're doing well. I recently developed a platform on TradingView, and I’m seeking assistance from a developer to guide me through the process. Based on the feedback provided, I will like you to help me make necessary modifications with it. Your expertise would be greatly appreciated! All Requirements will be sent via inbox. Thanks
Hello i'm look for someone to create an MT4 Expert Advisor Universal EA very simple 1 MQL4 that will have the following features:- Magic Number: to identify the chart Custom Indicator: ( here will be the name of the custom indicator we will use that will generate buy or Sell signal ) Buy Buffer: ( this is the buffer that the custom indicator use for Buy signals )
Hello, I'm looking for who can help me in converting my tradingview indicator to mt5 car trading strategy The Indicator name is Breaker Blocks with Signals(LuxAlgo) Let me know if you can get this done for me please
Hello there am looking for who can help me converting tradingview indicator to mt5 auto trading strategy, the indicator name : Breaker Blocks with Signals [LuxAlgo] ### 1. **Entry Condition**: - **For Long**: The trade is entered **after BB+** is confirmed. - **For Short**: The trade is entered **after BB-** is confirmed. ### 2. **Stop Loss**: - **For Long Entries**: Stop loss is triggered on a **candle close above
Hello , I've developed a new trading view platform recently, and I'd like an expert to give me some feedbacks. I will try to modify it based on your feedback. Looking forward to the proficient proposal in the comment section
Hello, I’m seeking a professional and experienced TradingView platform developer who can review and optimize a newly developed TradingView platform. The platform has not been deployed yet, and the goal is to refine it to perfection before launch. Requirements: Expertise in TradingView platform development and source code analysis. Proven experience in optimizing trading platforms for performance, functionality, and

プロジェクト情報

予算
30+ USD
開発者用
27 USD
締め切り
最低 1 最高 2 日