Creating an Array

 

Hello,


I need some help to create a simple Array(I guess thats what I need). When I get a signal I have stored the time of the signal like this:

datetime TimeofCross;

TimeOfCross = TimeCurrent();

I get the time of the current signal but I would also like to get the time from the previous signal. How could I do that?


Regards

Kenneth

 
kenned45900:
  1. I need some help to create a simple Array(I guess thats what I need).
  2. I would also like to get the time from the previous signal.

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Don't guess - think. Why do you need an array when you only want two values.
  3. static datetime crossLast, crossPrev;
    if(isCross){ crossPrev = crossLast; crossLast = TimeCurrent(); }
 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

Thanx, bur I useed a bad example since I can use iMAOnArray to get the time from previous crosses. Its not a MA cross but like in this example. When I get a buy signal i get TimeCurrent () for current signal. How can I get the time from the previous signal? I guess I need an array?

         if(BuySignal == 1) 
                           
         {
         TimeOfSignal = TimeCurrent(); 
         }
 
Asked and answerer.
You Posted
if(BuySignal == 1){ TimeOfSignal = TimeCurrent(); }
I Posted.
static datetime crossLast, crossPrev;
if(isCross){ crossPrev = crossLast; 
             crossLast = TimeCurrent(); }
What's the difference?
 
WHRoeder:
Asked and answerer.
You Posted
I Posted.
What's the difference?

Thanx again:-) It works but what if i want TimeCurrent() for the third or fourth signal?
Reason: