Thread: Ask
View Single Post
  #2 (permalink)  
Old 12-31-2005, 02:20 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 986
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Alerts on ang_Amp_ZZ direction changing.

Quote:
Originally Posted by hua
Dear Codersguru, is it possible an alert when ''ang_Amp_ZZ'' changing direction?? Tks vm in advance.
Hi hua,
Happy new year!
Please try this code (I didn't test it because it's Saturday)

PHP Code:
#property  copyright "ANG3110@latchess.com"
//-------------ang_Amp_ZZ---------------
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LemonChiffon
#property indicator_color2 LemonChiffon 
#property indicator_color3 Blue
//--------------------------------
extern int d=40;
//---------------------------------
double ha[],la[],zz[];
double hi,li,hm,lm,di,j;
int f,f1,ai,bi,aii,bii,f0,aibar,bibar;
di=d*Point;
//----------------------------------------------
int init()  {   
SetIndexStyle(0,DRAW_LINE);   
SetIndexBuffer(0,ha);   
SetIndexBuffer(1,la);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(2,zz);
return(
0);  }
//================================
int start()  {   
//--------------------------------
int i,n,cb,cbi,cbn,fs,bar;
//------------------------
//cb=IndicatorCounted();
//if (cb<0) return (-1);
//if (cb>0) cb--;
//cbi=Bars-cb;
//if (Bars<bar | Bars-bar>1) fs=0; bar=Bars;
//if (fs==0) {cbi=Bars-1; cbn=Bars-1; if (cbi<0) return(0); fs=1;}
cbi=Bars-IndicatorCounted()-1;
//-----------------------
//cbi=cbi+1;
for(i=cbii>=0i--){                             
if (
i>=Bars-2) {hi=High[i]; li=Low[i];}      
//==============================================================
if (Low[i]>hi) {hi=Low[i]; if (hi>=li+dili=hi-di;}
if (
High[i]<li) {li=High[i]; if (li<=hi-dihi=li+di;}
//------------------------------------------------------------------------------------

if (High[i]>hi && Low[i]<li) {if (High[i]-hi>li-Low[i]) {f1=1;} else f1=2;} else f1=0;
if (
f==&& High[i]>hi) {hm=High[i]; ai=if=1;}
if (
f==&& Low[i]<li) {lm=Low[i]; bi=if=2;}

if (
f==&& High[i]>hi && f1!=2) {hm=High[i]; f=1f0=0; for (n=ain>=bin--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);} ai=i;}
if (
f==&& High[i]>hm && f1!=2) {hm=High[i]; ai=if0=0;}
if (
f==&& Low[i]<li && f1!=1) {lm=Low[i]; f=2f0=0; for (n=bin>=ain--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);} bi=i;}
if (
f==&& Low[i]<lm && f1!=1)  {lm=Low[i];  bi=if0=0;}
//---------------------------------------------
if (i==&& f0==0) {aibar=Bars-aibibar=Bars-bif0=1;} 
if (
f0==1) {ai=Bars-aibarbi=Bars-bibar;} 

if (
i==&& ai>bi) for (n=ain>=bin--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);}
if (
i==&& ai<bi) for (n=bin>=ain--) {zz[n]=High[ai]*(n-bi)/(ai-bi)+Low[bi]*(n-ai)/(bi-ai);}

if (
i==&& f==1) {for (n=ain>=0n--) {zz[n]=Close[0]*(n-ai)/(0-ai)+High[ai]*(n-0)/(ai-0);}}
if (
i==&& f==2) {for (n=bin>=0n--) {zz[n]=Close[0]*(n-bi)/(0-bi)+Low[bi]*(n-0)/(bi-0);}}
if (
i==&& bi==0) {for (n=ain>=0n--) {zz[n]=Low[0]*(n-ai)/(0-ai)+High[ai]*(n-0)/(ai-0); }}
if (
i==&& ai==0) {for (n=bin>=0n--) {zz[n]=High[0]*(n-bi)/(0-bi)+Low[bi]*(n-0)/(bi-0); }}
//--------------------------------------------
ha[i]=hi;
la[i]=li;

Print(
zz[i]);



//cbi=cbi-1;
}


static 
string last_direction "";
string current_dirction "";

if ( (
zz[1] - zz[0]) > current_dirction "down";
if ( (
zz[1] - zz[0]) < current_dirction "up";



if(
current_dirction != last_direction
{
      
Alert("Direction has been changed " current_dirction);
      
last_direction current_dirction;
}

 
//------------------------------------
return(0);  } 
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Reply With Quote