Entries way off ??
I notice that the entries make no sense for some reason. When the first bar with a fresh MA and MACD cross closes we should be entering on close. Any ideas why the entries are so far off?( Up/down arrows on attached chart dictate where entries should be)
Also for some reason I can not edit the ea. The fast MA needs to be exp(which it is) but the slow needs to be simple and when i try to modify it i get access denied error.
Thanks again for the help and interest in this project, which at this point is way over my pointed head.
Ok-- I figured out how to edit the EA so 1 problem fixed. Must run editor "as administrator" to edit code.....for my fellow noobs
Also would it be possible to incorporate the attached MACD in place of the one currently used? Or will it just use whatever MACD is attached to the chart? The 2 line MACD is much easier to read at a glance.
What I would like to achieve is an EA that on longer tf's(daily and up) can be set to exit and re-enter at each cross only, without any risk or mm restrictions and on lower tf's can be used with risk, mm, stops, tp and trailing stops.
can the EA be set to simply exit and re-enter at each doublecross? I tried turning off tp and sl but it won't trade at all then
Just set CloseOnOpposite = True, it will ignore all TP n SL, it will close n open on the opposite direction. Dont forget to set trailing higher than the TP.
Or will it just use whatever MACD is attached to the chart?
It use Traditional MACD that came with default MT4 instalation
Open 2 chart of pair you trade, attach EA on both of them, with the setting you desire, dont forget to change the magic number.
Hope its help
Thanks again a1ra !!
Thank you again a1ra !! Do you have any idea why the entries are so far off? I can't make any sense of them. I've been studying the code since yesterday trying to figure out the entry rules and what may be wrong but have gotten nowhere yet. Entry/exit should be on the close of the bar that produces a double cross. Any ideas ?? Anyone? I posted a chart in a previous post that points out the discrepancies.
Thanks again everyone for taking the time to help a coder noob along .
YOU ALL ROCK !!!
What is and what should be
Ok-- The attached chart points out what is(red arrows/lines) and what should be(blue arrows). So the entries are apparently triggered when the MACD slow ma(red line) crosses the 0.00 line up or down and the MA's on the chart are crossed up or down.
This is unfortunately the wrong type entry. We enter when a bar closes with both the MACD MA's and the MA's on the chart(5ema, 15sma) crossed in the same direction as denoted by the blue arrows on the attached chart.
The MACD on the bottom is the one coded into the EA and the trigger would be the red MA and histogram crosses. The other MACD is the one I normally use with this strategy.
I am going to have another look at the code. Maybe if I can figure out where the entry parameters are I can figure out how to change them. Wish me luck..........I'm goin in
Narrowing it down--
Ok-- i believe the problem is here--
if (iMA(NULL, 0, Fast_MA, 0, Fast_MA_Mode, Fast_MA_Price, 0) > iMA(NULL, 0, Slow_MA, 0, Slow_MA_Mode, Slow_MA_Price, 0)
&& iMACD(NULL, 0, Fast_MACD, Slow_MACD, Signal_MACD, 0, 1, 0) > 0)
if (iMA(NULL, 0, Fast_MA, 0, Fast_MA_Mode, Fast_MA_Price, 0) < iMA(NULL, 0, Slow_MA, 0, Slow_MA_Mode, Slow_MA_Price, 0)
&& iMACD(NULL, 0, Fast_MACD, Slow_MACD, Signal_MACD, 0, 1, 0) < 0)
Unfortunately, I can understand the MA commands and how to edit them but I don't understand the MACD command. At the end of the MACD command line..... 0).....does the zero mean previous or current bar?
Could the "Signal_MACD" part of the line be eliminated so that it only pays attention to the "Fast_MACD" and "Slow_MACD?
Gonna have to think on this one for a bit The noob is a bit frazzled
1) The 0 at the end of the command line means: greater than or less than zero (0). For Buys - iMACD greater than > 0 (over the zero line)... For Sells - iMACD less than < 0 (under the zero line).
2) The iMACD formula as you show above gives the overall MACD value at the current time. The "Signal_MACD" is needed to get this value.
If you want to have more control of the iMACD, you can use the following to get MACD values and not use the Signal MACD if you don't want to:
CurrMain0 = iMACD(NULL,0,Pfast,Pslow,Psignal,PRICE_CLOSE,MODE_MAIN,0);
CurrSig0 = iMACD(NULL, 0 Pfast,Pslow,Psignal,PRICE_CLOSE,MODE_SIGNAL,0);
PrevMain1 = iMACD(NULL,0,Pfast,Pslow,Psignal,PRICE_CLOSE,MODE_MAIN,1);
PrevSig1 = iMACD(NULL, 0 ,Pfast,Pslow,Psignal,PRICE_CLOSE,MODE_SIGNAL,1);
You can vary the fast/slow/signal inputs and the price (open, close, etc) depending on what settings you want to work with.
Hope this helps,
First off, Thank you Robert for your much appreciated input.
Ok to begin with will I need to change the inputs here--
// Indicator setting
extern string Note1 = "MA cross setting";
extern int Fast_MA = 5;
extern int Fast_MA_Mode = 1;
extern int Fast_MA_Price = 0;
extern int Slow_MA = 15;
extern int Slow_MA_Mode = 0;
extern int Slow_MA_Price = 0;
extern string Note2 = "MACD setting";
extern int Fast_MACD = 12;
extern int Slow_MACD = 26;
extern int Signal_MACD = 9;
....to pfast, pslow etc or should i just change the phrasing in the line's you provided and will I need to add the PRICE_CLOSE and MODE_MAIN and MODE_SIGNAL and their values to this part of the code?
Once that is done it's not clear to me how to use the line's you provided. Will both the MODE_MAIN and MODE_SIGNAL lines have to be used and values set accordingly or would i just use the MODE_MAIN(assuming this is the value of the fast, slow MACD MA's) lines and eliminate the MODE_SIGNAL line's to disregard the signal?
Once that is taken care of (man, i'm in WAY over my head here ) then is it just a matter of using the previous bar values to detect the cross of the MACD MA's?
Geez, i hope someone can make sense of all of this . Thanks again everyone for all the help !!! You all Rock !! RESPECT !!!!
Funny how staring at the code long enough sheds light--
Ok i think i get this part from the last post-
"and will I need to add the PRICE_CLOSE and MODE_MAIN and MODE_SIGNAL and their values to this part of the code?"
CLOSE, MAIN and SIGNAL are the values so it doesn't refer to "// Indicator setting" for these values.?
So would it look something like this? --
if CurrMain0 = iMACD(NULL,0,Pfast,Pslow,Psignal,PRICE_CLOSE,MODE_ MAIN,0); > PrevMain1 = iMACD(NULL,0,Pfast,Pslow,Psignal,PRICE_CLOSE,MODE_ MAIN,1);
Or do both line's have to be there and if so how do I tell it to detect the fast, slow crosses and disregard signal crosses? Maybe if I keep staring I'll eventually figure it out.
Thanks again for the help !!!
Sorry for the zero cross ...
I played with the setting on M5, forgot to change it back
Please download it again on post 10