dolczaku:
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
Hi there!
I'm new to the community and to the idea of algo trading, and I'm in need of help with coding my very first EA!
What I did is that I downloaded EA from this link:
https://book.mql4.com/samples/expert
and tried to modify 'Trading criteria' in order to meet my expectations. Of course my C/MQL4 skills happened insufficient, therefore what I would like to kindly ask You is help to get this done.
This is what I added to the code:
<CODE REMOVED>
- Use SRC
- There is no loop there so the problem is elsewhere. Either post the rest, or add some print statements to find out what and why.
WHRoeder:
- Use SRC
- There is no loop there so the problem is elsewhere. Either post the rest, or add some print statements to find out what and why.
Sorry for the code!
I'm attaching whole EA then :)
Thanks for answering,
Best regards,
Rafal
Files:
tradingexpert.mq4
14 kb
//for(int i=1; i>=OrdersTotal(); i++) // Loop through orders for(int i=1; i<=OrdersTotal(); i++) // Loop through orders
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
Hi there!
I'm new to the community and to the idea of algo trading, and I'm in need of help with coding my very first EA!
What I did is that I downloaded EA from this link:
https://book.mql4.com/samples/expert
and tried to modify 'Trading criteria' in order to meet my expectations. Of course my C/MQL4 skills happened insufficient, therefore what I would like to kindly ask You is help to get this done.
This is what I added to the code:
// Trading criteria
EMA_1=iMA(NULL,0,4,0,MODE_EMA,PRICE_CLOSE,0); // ĚŔ_1
EMA_2=iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,0); // ĚŔ_2
RSI=iRSI(NULL,0,8,PRICE_CLOSE,0);
MFI=iMFI(NULL,0,8,0);
AD=iAD(NULL,0,0) - iAD(NULL,0,1);
SAR=iSAR(NULL, 0, 0.02, 0.2, 0);
buy_cnt=0;
sell_cnt=0;
if (EMA_1 > EMA_2)
{
buy_cnt ++;
}
if (EMA_1 < EMA_2)
{
sell_cnt ++;
}
if (RSI > 70)
{
buy_cnt ++;
}
if (RSI < 30)
{
sell_cnt ++;
}
if (MFI > 70)
{
buy_cnt ++;
}
if (MFI < 30)
{
sell_cnt ++;
}
if (AD > 0)
{
buy_cnt ++;
}
if (AD < 0)
{
sell_cnt ++;
}
if (SAR < iClose(NULL,0,0))
{
buy_cnt ++;
}
if (SAR > iClose(NULL,0,0))
{
sell_cnt ++;
}
if (buy_cnt > 3) // If difference between
{ // ..MA 1 and 2 is large
Opn_B=true; // Criterion for opening Buy
Cls_S=true; // Criterion for closing Sell
}
if (sell_cnt > 3) // If difference between
{ // ..MA 1 and 2 is large
Opn_S=true; // Criterion for opening Sell
Cls_B=true; // Criterion for closing Buy
}
And as a word of explanation, the purpose of this code is simple: to calculate 5 basic indicators (RSI, EMA, MFI, AD, SAR) and then to specify conditions on which they give BUY or SELL signals.
Strategy:
When at least 4 out of 5 indicaters give BUY signals, buy order should be submit. Same with SELL.
EA compiles, but when I run it in tester, it seems to loop somewhere and doesn't give results.
Please, help!
Kind regards,
Rafal