Fix an EA that isn't performing in the Strategy Tester

Job finished

Execution time 3 days
Feedback from employee
Good description of requirements specifications. Fast communication. Looking forward to working with you again

Specification

The specifications:

This EA uses the RSI exclusively for trade opens and closes.  The RSI crosses 50 moving upward and alerts the EA to watch.  When it reaches 53 it triggers a buy order.  When the RSI reaches 70, it triggers a close order.  Conversely, when the RSI crosses 50 moving downward, it alerts the EA.  When it reaches 47 it triggers a sell order.  This order is closed at RSI 30.  There is also a contingency if the RSI crosses over the 50 moving the opposite direction that the trade would close.  

As much is in the existing code.

Currently, the EA will only open and close one trade in the Strategy Tester.  I would like you to modify the EA to operate according to these specifications.  

I would also like you to add a trailing stop that can be adjusted.


Here is the existing code:



// Global Variables

enum StateType {WATCHING, LONG_ENTRY, SHORT_ENTRY, CLOSE_TRADE};

StateType state = WATCHING;

double LotSize = 0.1;  // Lot size

double StopLoss = 20.0 * Point;  // Stop loss in price difference

double TakeProfit = 100.0 * Point;  // Take profit in price difference

int slippage = 3;

int RSI_Period = 14;


// OnTick function

void OnTick() {

    double currentRSI = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE, 0);

    double previousRSI = iRSI(Symbol(), 0, RSI_Period, PRICE_CLOSE, 1);


    if (state == WATCHING) {

        if (currentRSI > 50 && previousRSI <= 50) {

            state = LONG_ENTRY;

        } else if (currentRSI < 50 && previousRSI >= 50) {

            state = SHORT_ENTRY;

        }

    }


    if (state == LONG_ENTRY && currentRSI >= 53) {

        PlaceLongOrder();

    } else if (state == SHORT_ENTRY && currentRSI <= 47) {

        PlaceShortOrder();

    }


    if (state == CLOSE_TRADE) {

        CloseTrade(currentRSI);

    }

}


// Function to place a long order

void PlaceLongOrder() {

    if (OrdersTotal() == 0) {

        double price = Ask;

        int ticket = OrderSend(Symbol(), OP_BUY, LotSize, price, slippage, price - StopLoss, price + TakeProfit, "Buy Order", 0, 0, clrGreen);

        if (ticket > 0) state = CLOSE_TRADE;

    }

}


// Function to place a short order

void PlaceShortOrder() {

    if (OrdersTotal() == 0) {

        double price = Bid;

        int ticket = OrderSend(Symbol(), OP_SELL, LotSize, price, slippage, price + StopLoss, price - TakeProfit, "Sell Order", 0, 0, clrRed);

        if (ticket > 0) state = CLOSE_TRADE;

    }

}


// Function to close the trade based on RSI

void CloseTrade(double currentRSI) {

    for (int i = 0; i < OrdersTotal(); i++) {

        if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol()) {

            if ((OrderType() == OP_BUY && currentRSI >= 70) || (OrderType() == OP_SELL && currentRSI <= 30)) {

                bool closed = OrderClose(OrderTicket(), OrderLots(), (OrderType() == OP_BUY ? Bid : Ask), 3, clrRed);

                if (closed) state = WATCHING;

            } else if ((OrderType() == OP_BUY && currentRSI < 50) || (OrderType() == OP_SELL && currentRSI > 50)) {

                closed = OrderClose(OrderTicket(), OrderLots(), (OrderType() == OP_BUY ? Bid : Ask), 3, clrRed);

                if (closed) state = WATCHING;

            }

        }

    }

}

    



Responded

1
Developer 1
Rating
(161)
Projects
192
26%
Arbitration
8
25% / 38%
Overdue
5
3%
Loaded
2
Developer 2
Rating
(37)
Projects
59
27%
Arbitration
25
20% / 52%
Overdue
10
17%
Working
3
Developer 3
Rating
(2449)
Projects
3086
66%
Arbitration
77
48% / 14%
Overdue
340
11%
Free
4
Developer 4
Rating
(11)
Projects
27
30%
Arbitration
3
0% / 0%
Overdue
1
4%
Busy
5
Developer 5
Rating
(14)
Projects
18
67%
Arbitration
2
50% / 50%
Overdue
3
17%
Free
6
Developer 6
Rating
(2114)
Projects
2684
62%
Arbitration
114
46% / 25%
Overdue
419
16%
Busy
7
Developer 7
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
8
Developer 8
Rating
Projects
0
0%
Arbitration
1
0% / 100%
Overdue
0
Free
9
Developer 9
Rating
(42)
Projects
62
8%
Arbitration
12
58% / 42%
Overdue
1
2%
Free
10
Developer 10
Rating
(39)
Projects
40
10%
Arbitration
0
Overdue
0
Free
Similar orders
Enter buy trade at close of candle when bar closes above the 3 emas. Emas are 34 ema, 64 ema and 128 ema. For a buy trade the 34 ema must be above the other two emas. The 64 ema should be in the middle. The 128 ema should be below the other two emas. For a buy trade the Awesome Oscillator should be above the middle line and colored green. Exit a buy trade when price touches 64 ema. Sell trade same conditions as buy
I want to make AI based on Attached Picture Swing High low. If you have experience can share demo first. Stop loss, take profit, trailing , break even ,DD etc. also amiable
Hello, I’m looking for a TradingView indicator that fits my forex trading needs. If you can create or customize one for me, please reach out. I'd appreciate your help! Thanks in advance."
Pls I need help I don’t have much but pls accept my little payment for the work thanks 🙏 mt5 file Once it opens buy and move positively to buy let it use auto trailing to follow the trend that’s if I choose to use trailing option and before the trailing starts it must reach the actual profit target example if I set profit target to 500 then once profit is at 500 let trailing immediately protect it and any 1 pip
Hey greetings am in need of a developer that can convert my simple tradingview indicator to MT4 I have the source code of the indicator and is also a public indicator on Tradingview site Kindly bid and let started
Hello my developer colleagues, am also a developer like you but i just hear about this mql site and i will like to sell, develop and build bots for buyer. But i don't know how to become a seller here please i need help in helping me to create a seller account on mql and i will be very glad if you can help me out and i will appreciate you
Preciso de um EA que abra ordens a mercado a partir de um indicador, Ele precisa obter take e stop loss fixos, spread máximo, horários de início e final das operações, meta e stop diário, martingale, painel e a função no script para que eu possa ceder o EA apartir do id do mt4 de terceiros
Hello Investors, I'm selling a profitable and stable expert advisor trading on the Gold (XAUUSD) pair using a cutting-edge scalping strategy. The EA is able to generate a stable monthly income without using martingale strategy, and with an optional cut loss in place. Particularly the average monthly gain can go from 2-3% (at a relatively low risk, with an historical max DD of 6%) to 20-30% (with an aggressive style
can you help me with Ctrader i need modification on the linkhttps://docs.google.com/document/d/1fggk49xWbnwahtfOlE-U7G6muZB1FT8eWmftGiY7R-s/edit?usp=sharing can you assist with cTrader modifications to enhance functionality and improve performance. do text me if you a professional on it i will be looking forward to your response best regards
Would I honestly need is someone who can make a profitable EA for me that can at least make me around $80 a day starting with $50 and the EA must be able to work with exness the EA should automat trades 24/7. Broker = Exness Pairs = USD/JPY XAU/USD and etc Chart time frames = M1 M15 History = last month till last 6 months. Lot size 0.10 take profit at $2 stop

Project information

Budget
50+ USD
For the developer
45 USD
Deadline
from 1 to 5 day(s)