Thank you very much, I've compiled my EA but it seems not to be working, don't know why!
It is really simple, it uses RSI, 2 MAs and MACD, if someone could read the code and tell me why the program don't open position when it should do, I'd really appreciate it. My EA is here:
http://www.fileden.com/files/2007/2/7/745427/CowabungaEA.mq4
I'm coding starting from this indicator (that is not mine) and that you can download here:
http://www.fileden.com/files/2007/2/7/745427/Cowabunga.mq4
As you can see if you load both the indicator and the EA into MT4, and run the test, when the indicator correctly displays the up and down arrows, the EA doesn't work and do strange things like opening and closing position very quickly (I don't know why!). It seems really strange since the condition to open a position is really similar to the code into the indicator (I made a lot of copy and paste, only changed variabiles names).
For the moment I don't care regarding exits, but if you just could help me with this problem it would be great...
Sorry to make stupid questions, but I'm not an expert programmer...
It is really simple, it uses RSI, 2 MAs and MACD, if someone could read the code and tell me why the program don't open position when it should do, I'd really appreciate it. My EA is here:
http://www.fileden.com/files/2007/2/7/745427/CowabungaEA.mq4
I'm coding starting from this indicator (that is not mine) and that you can download here:
http://www.fileden.com/files/2007/2/7/745427/Cowabunga.mq4
As you can see if you load both the indicator and the EA into MT4, and run the test, when the indicator correctly displays the up and down arrows, the EA doesn't work and do strange things like opening and closing position very quickly (I don't know why!). It seems really strange since the condition to open a position is really similar to the code into the indicator (I made a lot of copy and paste, only changed variabiles names).
For the moment I don't care regarding exits, but if you just could help me with this problem it would be great...
Sorry to make stupid questions, but I'm not an expert programmer...
I think you have a typo in your
else if( MA5_15M_now < MA5_15M_prev && MA10_15M_now < MA10_15M_prev && MA5_15M_prev > MA10_15M_prev && MA5_15M_now > MA10_15M_now) MA_15M_Cross = 2;
...
You are using the current bar in your calculation. The indicators are not stable at the current bar because
price is fluctuating. Some experts do not take a signal until a stable signal appears, meaning, the signal is
calculated using only closed bars. averages/rsi/etc would be calculated uisng bar 1 and 2, not bar 0 and 1,
Since you are mixing timeframes, you would only get a fully stable signal at the beginning of a new 4 hour bar.
That "may" be another reason for unintended results.
---
Also, it is possible for you to have a SELL and BUY signal at the same time.
Study your code and see how that might occur.
else if( MA5_15M_now < MA5_15M_prev && MA10_15M_now < MA10_15M_prev && MA5_15M_prev > MA10_15M_prev && MA5_15M_now > MA10_15M_now) MA_15M_Cross = 2;
...
You are using the current bar in your calculation. The indicators are not stable at the current bar because
price is fluctuating. Some experts do not take a signal until a stable signal appears, meaning, the signal is
calculated using only closed bars. averages/rsi/etc would be calculated uisng bar 1 and 2, not bar 0 and 1,
Since you are mixing timeframes, you would only get a fully stable signal at the beginning of a new 4 hour bar.
That "may" be another reason for unintended results.
---
Also, it is possible for you to have a SELL and BUY signal at the same time.
Study your code and see how that might occur.
Thank you again, I've tried to use only bars 1 and 2 like suggested, but the problem is still the same, the expert open orders in a very strange way... I'm reading the code, hoping to find my mistakes!
Hmmm...
I might be mistaken about "Also, it is possible for you to have a SELL and BUY signal at the same time"
add the alert below and see if it occurs.
if((MA_15M_Cross == 1) && (RSI_15M > 50) && (Stoch_15M_Change == 1) && (MACD_Change == 1) && (Main_Trend == 1)) Buy_Signal = true;
if((MA_15M_Cross == 2) && (RSI_15M < 50) && (Stoch_15M_Change == 2) && (MACD_Change == 2) && (Main_Trend == 2)) Sell_Signal = true;
if((Buy_Signal == true) && (Sell_Signal == true)){
Alert("Buy and Sell Signals present simultaneously");
Print("Buy and Sell Signals present simultaneously");
}
I might be mistaken about "Also, it is possible for you to have a SELL and BUY signal at the same time"
add the alert below and see if it occurs.
if((MA_15M_Cross == 1) && (RSI_15M > 50) && (Stoch_15M_Change == 1) && (MACD_Change == 1) && (Main_Trend == 1)) Buy_Signal = true;
if((MA_15M_Cross == 2) && (RSI_15M < 50) && (Stoch_15M_Change == 2) && (MACD_Change == 2) && (Main_Trend == 2)) Sell_Signal = true;
if((Buy_Signal == true) && (Sell_Signal == true)){
Alert("Buy and Sell Signals present simultaneously");
Print("Buy and Sell Signals present simultaneously");
}
It seems it doesn't happens... I'm testing it with the strategy tester, it should give me alerts, right?
Thank you again :-)
Thank you again :-)
'/' - open parenthesis expected
1 errors, 0 warnings
helpppp please to finish my EA
THANKS
Forex Trader: OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"BUY",12345,0,Green);
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. I have moved this thread.
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
I need to code this situation: in case of long position, the EA should exit if:
* Bid is less of the first "lowest low" (the most recent "down swing") that you could find looking the bars starting from the last one;
OR
* we gained a certain amount of pips, let's call it "Pips_Amount"
Obviously the sell situation is the same "mirrored".
When I've opened the buy order (and the sell one is similar), I've used this function:
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"BUY",12345,0,Green);
I've not defined Stop Loss and Take Profit, because I think to use the condition explained above, I'm right?
Can you give me a hand with the exit functions? I have problems expecially with the pips question, using which function can I know the exact amount of pips gained/loosed?
Thank you :)