help with time of cross - page 3

 
deVries:


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.
 
SDC:

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.
No apology needed, if you weren't trying to help there would be no possibility of making a small error
 
SDC:

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)

 
Hi all, again
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

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 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
      {
      //-----  HERE NEED TAKE THE TIME AND NOW USE
           timecrossSELL ();
              SELL();
           PrevCross =-1;
          
         
   }
   else if (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 ()
{
 static datetime  timecrossBUY = 0;
 timecrossBUY= Time[0];
 return (timecrossBUY);
}


int timecrossSELL ()
{
 static datetime  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 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()",
time is not an int it is a datetime
 


Latino:

when I compare the time int the "INT BUY()",


WHRoeder:

time is not an int it is a datetime

but it works well only if positive, need if negative, again making the comparison, with each new candle.

compare the TIMES, the diference,=

if (somethingtime()> timecrossBUY())
 
Latino:

learn to code .......

at this moment you are not able to read and understand simple mq4 language

Reason: