Hello to all
i am colombian, and i am learning a little of mql4 and english jejeje
i write here because i am doing a ea, basic ea, but i not advance in a part of code
me need te next:
is easy take the moment in that 2 EMAs cross, but i need that when happend the cross, wait 3 or 4 candles and in this moment do a sell or buy.
part of my code is this:
THEN, i need compare the actual time (in each new candle) with the time of the cross, but, with my code, each time that i quote the INT "timecrossBUY" or "timecrossSELL", the timecurrent is update and show the TIMECURRENT ACTUAL, and me need that the timecurrent is the time of the cross, an old timecurrent(), jejejei wait that you understand me, jejejeje
thanks to all, i need a help
you don't need to know the exact time of the cross if you want to wait 3 or 4 candels
you only have to check the values of the two MA's to see if MA crossed between two bars and at which bar
I confirm that if I need to know the time, because the OPBUY or OPSELL depends on the comparison of 2 times, and one of them is the "crossing time" and the other is a "later time" because if time is not after crossing, there should be OP BUYorSELL.
should be after crossing
so that expect 3 or 4 candles is indicative, can to be more candles. but really i need is the time,
can you help me?
is the 90 or 95% of the code, the rest is "trash" jejejj
but if not is the code complete, you can help me, because here is the code that need Adjust
part of my strategy is see the chart, jejejeje, and this can´t put in code jejejeje.
Thanks for help me, i wait you help
deveries, Thanks for responding
I confirm that if I need to know the time, because the OPBUY or OPSELL depends on the comparison of 2 times, and one of them is the "crossing time" and the other is a "later time" because if time is not after crossing, there should be OP BUYorSELL.
should be after crossing
so that expect 3 or 4 candles is indicative, can to be more candles. but really i need is the time,
can you help me?
really you don't need the time lines crossed i told you before
show how do you calculate the value of the two MA's at bar 0 ??
double MAR = iMA(NULL, 0, 12,....); double MAL = iMA(NULL, 0, 84,....);
i wanna see how you do it... before i explain more
Latino:
TimeCurrent() will be the correct time at the moment of the cross when you are working with live prices.
if ((MAL - MAR) >= 1 * Point) //Became bearish { datetime time = TimeCurrent(); //----- HERE NEED TAKE THE TIME AND NOW USE timecrossSELL (time); PrevCross =-1; }
deVries, thanks,
the code of calcule of cross of MA`s is this: no have more
and no understand how can to do it, without take the time, thanks
int PrevCross = 0; void CheckCross() { double MAR = iMA(NULL, 0, 12, 0, 1, PRICE_CLOSE, 0); double MAL = iMA(NULL, 0, 84, 0, 1, PRICE_CLOSE, 0); if (PrevCross == 0) //Was undefined { if ((MAR - MAL) >= 1 * Point) PrevCross = 1; //Bullish state else if ((MAL - MAR) >= 1 * Point) PrevCross = -1; //Bearish state return; } else if (PrevCross == 1) //Was bullish { if ((MAL - MAR) >= 1 * Point) //Became bearish { timecrossSELL(); PrevCross = -1; } } else if (PrevCross == -1) //Was bearish { if ((MAR - MAL) >= 1 * Point) //Became bullish { timecrossBUY(); PrevCross = 1; } } }
SDC, thanks, i not understand something, too by the language.
if ((MAL - MAR) >= 1 * Point) //Became bearish { datetime time = TimeCurrent(); //----- HERE NEED TAKE THE TIME AND NOW USE timecrossSELL (time); PrevCross =-1; }here, in this case, timecrossSELL is quote or not?
because, if i quote this INT "timecrossSELL", should be no a blank space between parentheses?? == timecrossSELL ();
timecrossSELL () // Missing function definition return type. datetime timecrossSell() { Timecurrent (); // Remove. Calls a function, throws the return value away. return (TimeCurrent()); // Can't return a value unless definition has a return type } // TimeCurrent is a datetime not an int.
if ((MAL - MAR) >= 1 * Point) //Became bearish { datetime time = TimeCurrent(); //----- HERE NEED TAKE THE TIME AND NOW USE timecrossSELL (time); // Function does not take a value // Function doesn't do anything. // Any return value is ignored. // DELETE the call. PrevCross =-1; }
function(); // Call the function function( ); // The same. function ( ); // the same.
deVries, thanks,
the code of calcule of cross of MA`s is this: no have more
and no understand how can to do it, without take the time, thanks
SDC, thanks, i not understand something, too by the language.
here, in this case, timecrossSELL is quote or not?because, if i quote this INT "timecrossSELL", should be no a blank space between parentheses?? == timecrossSELL ();
I was suggesting you pass the variable time to your timecrossSELL() function, I guess I thought you wanted to work with the time in that other function I must have been distracted while I was replying to your post. But anyway timecrossSELL is not a quote, it is a function call. There is nothing to be gained by creating a function just to call another function. TimeCurrent() is itself just another function call.
So unless you plan to do some more operations in timecrossSELL() there is no point to having it.
I was suggesting you pass the variable time to your timecrossSELL() function, I guess I thought you wanted to work with the time in that other function I must have been distracted while I was replying to your post. But anyway timecrossSELL is not a quote, it is a function call. There is nothing to be gained by creating a function just to call another function. TimeCurrent() is itself just another function call.
So unless you plan to do some more operations in timecrossSELL() there is no point to having it.
Thanks, I put TimeCurrent () in a functionbecause after, it is called by the BUY () or SELL () function, of which I put up an example in my first post,
then I ask you, can I call this TimeCurrent () the crossing without putting it in the function "timecrossSELL" or "timecrossBUY ()"??

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i am colombian, and i am learning a little of mql4 and english jejeje
i write here because i am doing a ea, basic ea, but i not advance in a part of code
me need te next:
is easy take the moment in that 2 EMAs cross, but i need that when happend the cross, wait 3 or 4 candles and in this moment do a sell or buy.
part of my code is this:
THEN, i need compare the actual time (in each new candle) with the time of the cross, but, with my code, each time that i quote the INT "timecrossBUY" or "timecrossSELL", the timecurrent is update and show the TIMECURRENT ACTUAL, and me need that the timecurrent is the time of the cross, an old timecurrent(), jejejei wait that you understand me, jejejeje
thanks to all, i need a help