you wanna check when happend the cross, wait 3 or 4 candles and in this moment do a sell or buy.
this function i give...
When someone is a beginner learning to code I thought it better to point them in the right direction with small code snippets that they might learn from and understand, rather than hand them a completed function that they probably wouldn't.
When someone is a beginner learning to code I thought it better to point them in the right direction with small code snippets that they might learn from and understand, rather than hand them a completed function that they probably wouldn't.
i didn't gave him directly the solution,
but the help you were giving him made him more confuse about how i thought to make it....
i told it was not needed to know time of the cross
now you see why...
(ofcours you are free giving also help and you might give better help then i can do, so it doesn't matter to me you do)
after tryingforMYNEEDScodesthatyou have helpedme, I usedtoputtheSDC,because,as I said,isthat fitswhat I need,
mycodeso far,goes like this,full
Remember that somethintime() variablesare setby hand oreye,lol
int PrevCross = 0;
int LastBars=0;
void CheckCross()
{
double MAR = iMA(NULL, 0, 12, 0, 1, 0, 0);
double MAL = iMA(NULL, 0, 84,0, 1, 0, 0);
if (PrevCross == 0) //Was undefined
{
if ((MAR - MAL) >= 1 * Point) PrevCross = 1; //Bullish stateelseif ((MAL - MAR) >= 1 * Point) PrevCross = -1; //Bearish statereturn;
}
elseif (PrevCross == 1) //Was bullish
{
if ((MAL - MAR) >= 1 * Point) //Became bearish
{
//----- HERE NEED TAKE THE TIME AND NOW USE
timecrossSELL ();
SELL();
PrevCross =-1;
}
elseif (PrevCross == -1) //Was bearish
{
if ((MAR - MAL) >= 1 * Point) //Became bullish
{
//---- HERE NEED TAKE THE TIME AND NOW USE
timecrossBUY();
BUY();
PrevCross = 1;
}
}
}
int timecrossBUY ()
{
staticdatetime timecrossBUY = 0;
timecrossBUY= Time[0];
return (timecrossBUY);
}
int timecrossSELL ()
{
staticdatetime timecrossSELL = 0;
timecrossSELL= Time[0];
return (timecrossSELL);
}
int somethingtime ()
{
int A= 1388446600;
return (A);
}
int BUY ()
{
if (somethingtime()> timecrossBUY())
{
ordersend.....OP_BUY.......etc}
}
int SELL()
{
if (somethingtime()> timecrossBUY())
{
ordersend.. OP_SELL......etc}
}
int start()
{
//----if (12 == 84)
{
Print("MA periods should differ.");
return;
}
//Wait for the new Bar in a chart.if (LastBars == Bars) return;
else LastBars = Bars;
if ((Bars < MAL) || (IsTradeAllowed() == false)) return;
CheckCross();
//----return(0);
}
but I have anew problem,and that is thatwhen I comparethe time int the "INT BUY()",and if it iscorrect,=ordersend OP_BUY() orrdersend OP_SELL(), but if not, nothing happens, and I needsothat whenifnot, returnwith each newcandlecomparethe rule:
if (somethingtime()> timecrossBUY())
{
ordersend.....ETC}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
The code of SDC is not needed
you wanna check when happend the cross, wait 3 or 4 candles and in this moment do a sell or buy.
this function i give...
When someone is a beginner learning to code I thought it better to point them in the right direction with small code snippets that they might learn from and understand, rather than hand them a completed function that they probably wouldn't.
That was my fault I apologize I didnt check that code I just typed it into the src box and forgot about the intialization rule.
When someone is a beginner learning to code I thought it better to point them in the right direction with small code snippets that they might learn from and understand, rather than hand them a completed function that they probably wouldn't.
i didn't gave him directly the solution,
but the help you were giving him made him more confuse about how i thought to make it....
i told it was not needed to know time of the cross
now you see why...
(ofcours you are free giving also help and you might give better help then i can do, so it doesn't matter to me you do)
and thank you all for trying to help
after trying for MY NEEDS codes that you have helped me, I used to put the SDC, because, as I said, is that fits what I need,
my code so far, goes like this, full
Remember that somethintime() variables are set by hand or eye, lol
but I have a new problem, and that is that when I compare the time int the "INT BUY()", and if it is correct, = ordersend OP_BUY() or rdersend OP_SELL(), but if not, nothing happens, and I need so that when if not, return with each new candle compare the rule:
if (somethingtime()> timecrossBUY()) { ordersend.....ETC} }I could not do
can you help me
THANKS
Latino:
when I compare the time int the "INT BUY()",
WHRoeder:
time is not an int it is a datetimebut it works well only if positive, need if negative, again making the comparison, with each new candle.
compare the TIMES, the diference,=
learn to code .......
at this moment you are not able to read and understand simple mq4 language