[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: first 120 day high in 60 days


  • Date: Mon, 30 Nov 2009 02:12:52 -0000
  • From: "r22mark" <mtf_79@xxxxxxx>
  • Subject: [amibroker] Re: first 120 day high in 60 days

PureBytes Links

Trading Reference Links


It gets more complex when you try to identify the first high. The code for it is below. The only US stock in the S&P 1500 that meets your requirements (1st 120 day high in last 60 days) is UMPQ. I have written explore and indicator code. To find todays stocks, explore n = 1 days. Because the markets are down, only UMPQ comes up. To check my code, run an explore over n = 10 days. You should now get a dozen or so stocks. Make sure the "Sync chart on select" box is ticked. Click on a result and the stock loads automatically. If you press "Apply indicator" from within AFL Editor a new pane should open. Click on a bar. The j count tells you how many bars ago this is. You have to add 1 to the count as array counting starts at 0. The rest you will probably figure out. I set the values as parameters so they can be adjusted within the indicator and the explore. The indicator is also useful for seeing when the first high occurred on any stock. If you find any errors let me know.

Mark


HD = Param("HHV # of days", 120, 5, 252, 5);   // up to 1 year
LND = Param("1st HHV last # of days", 60, 5, 200, 5);

Cond1 = H >= HHV(H,HD);

x = Null; xa = Null; j = Null; ja = Null; 

for(i=1; i<BarCount; i++)
{
  if(i == BarCount-LND) {
    j = LND; 
    ja[i] = j[i];  
  }
  j--; ja[i] = j[i]; 
  if(i >= BarCount-LND AND Cond1[i]) {
    x[i] = 1;
    xa[i] = x[i];  
    break;
  }
}

// INDICATOR CODE
Plot(xa, "1st "+WriteVal(HD,1.0)+" Day H", colorRed, styleLine);
Plot(ja, "j count, add 1", colorBlue, styleLine);
Plot(Cond1, WriteVal(HD,1.0)+" Day H", colorBlack, styleLine);
PlotShapes(x*shapeUpArrow, colorGreen,0,0,0);

// EXPLORE CODE
Filter = x;
AddColumn(x, "1st "+WriteVal(HD,1.0)+" Day H", 1.2);
AddColumn(Cond1, WriteVal(HD,1.0)+" Day H?", 1.2);



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

**** 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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/