Techniques to detect indicator line cross - page 2

 

I'm perhaps going to regret this because I've not worked much with 3 line crossing, but would the following not do it?

int      fast=5;
int      med=10;
int      slo=20;

double   fastma=iMA(NULL,0,fast,0,MODE_SMA,PRICE_CLOSE,1);
double   medma=iMA(NULL,0,med,0,MODE_SMA,PRICE_CLOSE,1);
double   sloma=iMA(NULL,0,slo,0,MODE_SMA,PRICE_CLOSE,1);

double   prev_fastma=iMA(NULL,0,fast,0,MODE_SMA,PRICE_CLOSE,2);
double   prev_medma=iMA(NULL,0,med,0,MODE_SMA,PRICE_CLOSE,2);
double   prev_sloma=iMA(NULL,0,slo,0,MODE_SMA,PRICE_CLOSE,2);

if (fastma<prev_fastma && medma<prev_medma && sloma<prev_sloma) // if they all need to be sloping down
   {
   if (fastma <medma && fastma < sloma && (prev_fastma>= prev_medma || prev_fastma>=prev_sloma))
      {
      Alert("Crossed Down");
      }
   }  
   

Depending on whether the definition of cross is where they touch ar where the sepeparate will dictate where the "=" goes in the last if.

Does this not work effectively? What am I missing?

V

 
Viffer, interesting technique used there, I will check it out thanks!
 
Let me know how you go, I wouldn't mind perfecting this myself.
 
Viffer:

I'm perhaps going to regret this because I've not worked much with 3 line crossing, but would the following not do it?

Depending on whether the definition of cross is where they touch ar where the sepeparate will dictate where the "=" goes in the last if.

Does this not work effectively? What am I missing?

V

   if (fastma < prev_fastma && medma < prev_medma && sloma < prev_sloma) // if they all need to be sloping down
   {
      if (prev_fastma >= prev_medma && prev_medma >= prev_sloma) // if all must cross simultaneously
      }
         if (fastma < medma && medma < sloma)
         {
            Alert("Crossed Down");
         }
      }
   }  
I think these conditions might be difficult to fill.
 
Saidar:

Hey cameofx,

Actually it does not matter, I want to use it for both. If I use an indicator I wont be alerted with false alerts, if I use an EA, well, then it will be more profitable.

When you said it does not matter, then I would assume you don't have any trouble taking a snippet of code/ or a description & turn it into an indicator. Indicator need more work.

You state 3 line cross but the picture shows 4 lines. I'm gonna go with 3 line... let's call it line A, B & C

Correct me if I'm wrong : 

  • There are 3 state that involves any 1 pair of lines : A == B, A > B, A <  B. 
  • Note that A can interact with B, A with C and B with C and they do these simultaneously. 
  • you can completely analyze all states if you do permutation of all of the above combination. But that won't be too useful IMO. So you should narrow it down to what you think is useful as a strategy. For instance make the third line have much greater period. Check this first if it's a down slope for instance, then check if the other two is crossing the same direction.
  • You also need to use proper line-cross check. With Arrays or current & prev variables. search for it. 

Hope that helps
cameo 

 
engcomp:
I think these conditions might be difficult to fill.

I agree, notably if all three lines need to be sloping in the right direction at the moment of cross. Without that condition, I think it's pretty straight forward. It depends on the actual conditions needed by OP. EG if the cross happens before sloma slopes correctly, how many bars are you going to give it that it's still a valid cross. Expanding that would be fairly straight forward though by taking a time at the cross and then including an allowable period on ibarshift on the slope argument. IMHO the brief needs tightening up :).

V

 

Viffer,... what's OP? I heard that a lot. Open Price, Other Person?

 
cameofx:

Viffer,... what's OP? I heard that a lot. Open Price, Other Person?

Original Poster

http://www.urbandictionary.com/define.php?term=op

 
Never crossed my mind. :)) Thanks.
 

Also used interchangeably with "original post"...sometimes the OP themselves will refer back to the "OP" meaning the the first post in the thread. Context determines whether "OP" means poster or poster's post.

Reason: