Hi Alan
 
please try this code it may help serve your purpose
--------------------------------------------------------------------------------
 
//The following code will return a 1 when the negative DMI crosses above the 
positive DMI.
mdmi = MDI(13);
pdmi = PDI(13);
NEGdmicrossing = Cross(mdmi,pdmi);
POSITIVEdmicrossing = Cross(pdmi,mdmi);
Buy=POSITIVEdmicrossing ;
Sell =NEGdmicrossing;
BarsSince( POSITIVEdmicrossing ) ; 
BarsSince( NEGdmicrossing ) ; 
 
Filter=Buy OR Sell;
AddColumn(Buy,"BUY",format=1.2);
AddColumn(Sell,"SELL",format=1.2);
AddColumn ((BarsSince( POSITIVEdmicrossing )), "uptrend ",format=1.0);
AddColumn ((BarsSince( NEGdmicrossing )), "downtrend ",format=1.0);
 
 
//- bars since Trading system toolbox  reference 

//SYNTAX BarsSince( ARRAY ) 
//RETURNS ARRAY 
//function Calculates the number of bars (time periods) that have passed since 
ARRAY was True (OR 1) 
//EXAMPLE BarsSince( MACD() < 0 ) 
 
 
---------------------------------------------------------------------------------------------------------------------------------------------------
 
 
 
 
regards
rvlv
-------------------------------

--- On Sat, 11/21/09, Alan <[email protected]> wrote:


From: Alan <[email protected]>
Subject: [amibroker] Days since DMI crossover
To: [email protected]
Date: Saturday, November 21, 2009, 2:51 PM


The following code will return a 1 when the negative DMI crosses above 
the positive DMI.

mdmi = MDI(13);
pdmi = PDI(13);
dmicrossing = Cross(mdmi,pdmi);

However, what I want to know is how many days have passed since the 
negative DMI crossed above the positive DMI.  I have looked through the 
AFL formulas for a Days Since Crossing function but did not find one. 
Can anyone help me with the code to perform this function?

Thanks,
Alan


------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links






      

Reply via email to