![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What do you want to get?
Do you have a code for mt4 to understand what you need?
double rsii1[100], rsii2[100],profit_m[100]; int b,s,b1,s1;
extern int rsi_shift=1;
extern intrsi_period1=4;
extern int rsi_period2=14;
extern int N=5;
extern int Level1=20;
extern int Level2=80;
extern int Level3=30;
extern int Level4=70;
int signal() // 3. Signal Function
{
int b = 0, s = 0, b1 = 0, s1 = 0; // Reset conditions
for (int i = 1; i <= N; i++) // Conditions over the last bars
{
rsii1[i] = iRSI(_Symbol, PERIOD_CURRENT, Inp_RSI_ma_period, PRICE_CLOSE, i);
rsii2[i] = iRSI(_Symbol, PERIOD_CURRENT, Inp_RSI_ma_period, PRICE_CLOSE, i);
if (rsii1[i] < Level1) b = 1;
if (rsii1[i] > Level2) s = 1;
if (rsii2[i] < Level3) b1 = 1;
if (rsii2[i] > Level4) s1 = 1;
}
double rsi1 = iRSI(_Symbol, PERIOD_CURRENT, rsi_period1, PRICE_CLOSE, rsi_shift);
double rsi2 = iRSI(_Symbol, PERIOD_CURRENT, rsi_period1, PRICE_CLOSE, rsi_shift + 1);
double rsi3 = iRSI(_Symbol, PERIOD_CURRENT, rsi_period2, PRICE_CLOSE, rsi_shift);
double rsi4 = iRSI(_Symbol, PERIOD_CURRENT, rsi_period2, PRICE_CLOSE, rsi_shift + 1);
if (rsi1 > rsi3 && rsi2 <= rsi4 && b == 1 && b1 == 1) return (ORDER_TYPE_BUY); //open buy
if (rsi1 < rsi3 && rsi2 >= rsi4 && s == 1 && s1 == 1) return (ORDER_TYPE_SELL); // open Sell
return(0);
}
I am trying to convert it to 5 by inserting a muving handle into the two rsi values.
The cross of RSI and MA above or below the specified levels
i.e. RSI above 70 and MA above 60 at cross from top to bottom opens short, and vice versa RS below and MA below at cross from bottom to top opens long.
I have a couple of dozens of such functions and I am trying to adapt them to 5. Some of them work, some of them don't.
H.Y. how do you hide the code area so that you don't get such sheets? I don't see the spoiler button so that I don't have to throw a thousand and a half lines on 5.0.
double rsii1[100], rsii2[100],profit_m[100]; int b,s,b1,s1;
H.Y. how do you hide the code area so that you don't get such sheets? I can't see the spoiler button so that I don't have to throw a thousand and a half lines on 5k.
Here I have finished something else, in idea it should close when receiving a profit in xxx amount
I want to change the condition to "if we have orders and they are of such type and they are in profit for the amount of OverProfit, then when receiving the opposite signal they close. Otherwise, our grid of orders averages the position by the amount of OverLoss/
. As I understand it is necessary to insert a memorable variable into the function of searching for signals and reset it after closing positions.
What is stressing me here - I have no idea how to work with these structures and take pieces from the database, so I edit by poke.