hello everyone, today I'm asking someone for help in identifying the value of an indicator as soon as a buy/sell stop opens, in order to calculate the difference in present value compared to the value of the indicator when the order was opened. so what i need is, as soon as a buy/sell stop opens the trade the ea has to register the value of the rsi, let's pretend it's 70, and since there if the rsi value has a decrease of 8 point, in case of a buy, i close the trade, so as soon as it reaches, by example, 62, it closes the trade.
struct TradeData {
int ticket;
double entryRSI;
};
TradeData trades[100]; // Aumenta la dimensione se prevedi più di 100 operazioni contemporaneamenteint tradeCount = 0;
void CheckRSIAndCloseTrades() {
double currentRSI = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);
for (int i = 0; i < tradeCount; i++) {
if (OrderSelect(trades[i].ticket, SELECT_BY_TICKET)) {
if (OrderType() == OP_BUY && trades[i].entryRSI - currentRSI >= 8) {
OrderClose(trades[i].ticket, OrderLots(), Bid, 3, clrRed);
// Rimuovi l'elemento dall'array se necessario o segnalo come non attivo
}
}
}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
so what i need is, as soon as a buy/sell stop opens the trade the ea has to register the value of the rsi, let's pretend it's 70, and since there if the rsi value has a decrease of 8 point, in case of a buy, i close the trade, so as soon as it reaches, by example, 62, it closes the trade.
I tried with this one but it doesn't work at all, returns a value of 0 when the trade opens...
can someone help pls?
thanks in advance.