指定

# 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
空闲
相似订单
Nt8 30+ USD
i'm searching a way to define which IP address is using by NT8 cause i'm using a multiple IPs machine (for my daily job) and I'd need to have a further confirmation that I'm using the correct IP address with NT8 could anyone explain explain me how to do it for a fee
I need a developer with FxDreema experience to build an MT5 EA that: Manages recovery zones with pending buy/sell orders. Implements trailing stops, pre-defined profit lines, and dynamic lot sizing. Supports money management based on account balance and lot size and money value. Offers options for continuous or stop trading. The developer must provide the source code and FxDreema link . More specific details will be
I want Ea tht will work on boom and crash only. The ea must work in m1 / m5 and it must scalp . I want the ea grow small account like 10 usd to 100/50 usd daily.. boom and crash no loss . The developer must came with the strategy... this ea is for small account
I need to create an EA based on my own strategy that actually is a little bit different from most of the usual EA. This because it use an indicator but the power of the system is just because it can shows target price by designing trendline on the price chart in a unusual way. A friend of mine tried to create it on MT4 platform but, in the end, he realized that this platform has big limits when the program lines
This is a 2000 lines own-made breakout EA that I need to have cleanly converted from mql4 to mql5 for learning purposes The start() is about 400 lines long ; basic breakout with specific features , built for Index CFDs with 2 digits (typically DAX or SP500; TP SL... are expressed in actual Points) The Ontester() is about 400 lines (contains 58 different custom opimizations) The Deinit() is about 150 lines The
Hallo zusammen, es wird ein Entwickler für einen eigenen Expert Advisors gesucht. Der Expert Advisor soll anhand von zwei miteinander kombinierbaren Indikatoren (Relative Stärke inkl. Gleitender Durchschnitte und dem Supertrend-Indikator) Einstiegssignale in Long und Shortrichtung für alle möglichen Underlyings suchen. Hierbei soll bei einem initialen Einstieg zusätzlich in einem zeitlichen Abstand und gemäß
Convert my tradingview pine script to mt4, Its a simple and straight code i need an expert programmer to convert my tradingview pine script to mt4, Thats All Thank you
Hello, i would like to have a fix on my plotted lines I use a liquidity strategy on the 1 hr time frame but the indicator that i am using for plotting the 1 hr lines is having a issue and printing the plot lines all over the place on the current 1 and 4 hr plot line as you can see in the screenshot this is very disturbing while i am trading can u fix that or just remove the current 1 hr plot line ?and or only show
Here's the bot's trading strategy in a nutshell>>> I would like to make a simple scalping MT5 EA trading bot for the synthetic indices, specifically for the Boom 1000 Index. This MT5 EA trading bot will be based off of the 10 period moving average that follows specific rules for entry. The parameters of the moving average are as follows: Period:10 Shift:1 Method:Linear Weight Apply to:Close The bot will only initiate
For Chart Panel : Needs a Black Back ground at present its transparent . ✔️ Trading Panel (To be reset weekly = 1-6) 1. EA Status : (on/off) 2. Total Trades Taken : 3. Number of Profitable Trades Today : 4. Number of Loosing Trades Today : 5. Number of Profitable Trades This Week : 6. Number of Loosing Trades This Week : (To be Reset every Month = 7-9) 7. Number of Profitable Trades This Month : 8. Number of Loosing

项目信息

预算
30+ USD
开发人员
27 USD
截止日期
 1  2 天