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

[amibroker] Re: Excel Spread-sheet to AmiBroker ... Code ?



PureBytes Links

Trading Reference Links




thanks for your efforts, both Hans and 
aequalsz,
 
I checked the version of aequalsz and found that 
the loop needs to start at 0 instead of 1. I made 
a function of it see below. So if all the other code is accurate this should 
work. Please correct me if I am wrong,
 
rgds, Ed
 
 
function<FONT 
face="Courier New"> ProjOsc(n) { 
// Slope of High {n period regression line of 
High)}<FONT 
color=#000000> SlopeHigh = ((n * (Sum<FONT 
color=#000000>( Cum<FONT 
color=#000000>(1) * 
High, n))) - 
(Sum( <FONT 
color=#0000ff>Cum(<FONT 
color=#ff00ff>1<FONT 
color=#000000>),n) * ( Sum<FONT 
color=#000000>(High<FONT 
color=#000000>, n)))) / ((n * Sum<FONT 
color=#000000>( Cum<FONT 
color=#000000>(1) ^ 
2 , n)) - (<FONT 
color=#0000ff>Sum(<FONT 
color=#0000ff>Cum(<FONT 
color=#ff00ff>1<FONT 
color=#000000>),n) ^ 2<FONT 
face="Courier New">)); <FONT 
color=#008000>//Slope of Low {n period regression line of 
Low}<FONT 
color=#000000> SlopeLow = ((n * (Sum<FONT 
color=#000000>( Cum<FONT 
color=#000000>(1) * 
Low, n))) - 
(Sum( <FONT 
color=#0000ff>Cum(<FONT 
color=#ff00ff>1<FONT 
color=#000000>), n) * ( Sum<FONT 
color=#000000>(Low, 
n)))) / ((n * Sum( 
Cum(<FONT 
color=#ff00ff>1)^ <FONT 
color=#ff00ff>2, n)) - ( <FONT 
color=#0000ff>Sum(<FONT 
color=#0000ff>Cum(<FONT 
color=#ff00ff>1<FONT 
color=#000000>),n) ^ 2<FONT 
face="Courier New">)); <FONT 
color=#008000>//Upper Projection Band<FONT 
face="Courier New"> UpProjBand = 
0<FONT 
size=2>; <FONT 
color=#800000>for (i=<FONT 
color=#ff00ff>0; i<n-<FONT 
color=#ff00ff>1<FONT 
color=#000000>; i++) { UpProjBand = <FONT 
color=#0000ff>Max(<FONT 
color=#0000ff>Max(<FONT 
color=#0000ff>Ref(<FONT 
color=#000000>High<FONT 
color=#000000>,-i)+i*slopehigh,Ref<FONT 
color=#000000>(High<FONT 
color=#000000>,-i-1<FONT 
color=#000000>)+(i+1<FONT 
face="Courier New">)*slopehigh),UpProjBand); 
} //Lower Projection 
Band<FONT 
color=#000000> LoProjBand = <FONT 
color=#ff00ff>10000<FONT 
size=2>; <FONT 
color=#800000>for (i=<FONT 
color=#ff00ff>0; i<n-<FONT 
color=#ff00ff>1<FONT 
color=#000000>; i++) { LoProjBand = <FONT 
color=#0000ff>Min(<FONT 
color=#0000ff>Min(<FONT 
color=#0000ff>Ref(<FONT 
color=#000000>Low,-i)+i*slopelow,<FONT 
color=#0000ff>Ref(<FONT 
color=#000000>Low,-i-<FONT 
color=#ff00ff>1)+(i+<FONT 
color=#ff00ff>1<FONT 
color=#000000>)*slopelow),LoProjBand); } <FONT 
color=#008000>//Projection Oscillator<FONT 
face="Courier New"> ProOsc = <FONT 
color=#ff00ff>100 * (<FONT 
color=#000000>Close<FONT 
size=2> - LoProjBand) / (UpProjBand - LoProjBand); 
return<FONT 
size=2> ProOsc; } 

<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  aequalsz 
  
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Sunday, March 14, 2004 5:18 
PM
  Subject: [amibroker] Re: Projection 
  Oscillator
  Here's a variable period Projection Oscillator.  Seems 
  to work butit's not been thoroughly checked 
  out.a--------------------------------------------------------------n 
  = Param("Periods",14,5,50,1);// Slope of High {n period regression 
  line of High)}SlopeHigh = ((n * (Sum( Cum(1) * High, n))) - (Sum( 
  Cum(1),n) * (Sum(High, n)))) / ((n * Sum( Cum(1) ^ 2 , n)) - 
  (Sum(Cum(1),n) ^2));//Slope of Low {n period regression line of 
  Low}SlopeLow = ((n * (Sum( Cum(1) * Low, n))) - (Sum( Cum(1), n) * 
  (Sum(Low, n)))) / ((n * Sum( Cum(1)^ 2, n)) - ( Sum(Cum(1),n) 
  ^2));//Upper Projection BandUpProjBand = 0;for (i=1; 
  i<n-1; i++){UpProjBand 
  =Max(Max(Ref(High,-i)+i*slopehigh,Ref(High,-i-1)+(i+1)*slopehigh),UpProjBand);}//Lower 
  Projection BandLoProjBand = 10000;for (i=1; i<n-1; 
  i++){LoProjBand 
  =Min(Min(Ref(Low,-i)+i*slopelow,Ref(Low,-i-1)+(i+1)*slopelow),LoProjBand);}//Plot(Close,"",colorBlack,styleCandle);//Plot(LoProjBand,"LPB",colorRed,styleLine);//Plot(UpProjBand,"UPB",colorRed,styleLine);//Projection 
  OscillatorProOsc = 100 * (Close - LoProjBand) / (UpProjBand - 
  LoProjBand);Graph0 = ProOsc;Graph1 = EMA(ProOsc,9);  
  ------------------------------------------------------------------ 
  In amibroker@xxxxxxxxxxxxxxx, "Hans" <hansib@xxxx> wrote:> Thanks 
  for the information I think now the code is OK for Ami.> > Here 
  follows code:> > // Slope of High {14 period regression line of 
  High)}> SlopeHigh = ((14 * (Sum( Cum(1) * High, 14))) - (Sum( 
  Cum(1),14) * ( > Sum(High, 14)))) / ((14 * Sum( Cum(1) ^ 2 , 14)) - 
  (Sum(Cum(1),14) ^ > 2));> > > //Slope of Low {14 
  period regression line of Low}> SlopeLow = ((14 * (Sum( Cum(1) * Low, 
  14))) - (Sum( Cum(1), 14) * ( > Sum(Low, 14)))) / ((14 * Sum( Cum(1)^ 
  2, 14)) - ( Sum(Cum(1),14) ^ > 2));>    
  >   > //Upper Projection Band> > 
  UpProjBand= Max(High, > Max( Ref(High,-1) + 1 * SlopeHigh, > 
  Max( Ref(High,-2) + 2 * SlopeHigh, > Max( Ref(High,-3) + 3 * SlopeHigh, 
  > Max( Ref(High,-4) + 4 * SlopeHigh, > Max( Ref(High,-5) + 5 * 
  SlopeHigh, > Max( Ref(High,-6) + 6 * SlopeHigh, > Max( 
  Ref(High,-7) + 7 * SlopeHigh, > Max( Ref(High,-8) + 8 * SlopeHigh, 
  > Max( Ref(High,-9) + 9 * SlopeHigh, > Max( Ref(High,-10) + 10 * 
  SlopeHigh,> Max( Ref(High,-11) + 11 * SlopeHigh,> Max( 
  Ref(High,-12) + 12 * SlopeHigh,> Ref(High,-13) + 13 * 
  SlopeHigh)))))))))))));> >   > //Lower 
  Projection Band> > LoProjBand=Min(Low,> Min( Ref(Low,-1) 
  + 1 * SlopeLow,> Min( Ref(Low,-2) + 2 * SlopeLow,> Min( 
  Ref(Low,-3) + 3 * SlopeLow,> Min( Ref(Low,-4) + 4 * SlopeLow,> 
  Min( Ref(Low,-5) + 5 * SlopeLow,> Min( Ref(Low,-6) + 6 * 
  SlopeLow,> Min( Ref(Low,-7) + 7 * SlopeLow,> Min( Ref(Low,-8) + 
  8 * SlopeLow,> Min( Ref(Low,-9) + 9 * SlopeLow,> Min( 
  Ref(Low,-10) + 10 * SlopeLow,> Min( Ref(Low,-11) + 11 * 
  SlopeLow,> Min( Ref(Low,-12) + 12 * SlopeLow,> Ref(Low,-13) + 13 
  * SlopeLow)))))))))))));>    >   
  > //Projection Oscillator> ProOsc = 100 * (Close - LoProjBand) / 
  (UpProjBand - LoProjBand);> > Graph0 = ProOsc;> Graph1 = 
  EMA(ProOsc,9);> > /***************> regards,> 
  Hans> > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
  <amibroker@xxxx> > wrote:> > Power function in AB is 
  not necessary because AB has ^ operator:> > > > MS Power( 
  X, Y ) call translates simply to  X ^ Y> > > > Best 
  regards,> > Tomasz Janeczko> > amibroker.com> > 
  ----- Original Message ----- > > From: "Hans" 
  <hansib@xxxx>> > To: <amibroker@xxxxxxxxxxxxxxx>> 
  > Sent: Sunday, March 14, 2004 10:40 AM> > Subject: [amibroker] 
  Projection Oscillator> > > > > > > I would 
  like to develop the "Projection Oscillator" for IB in > AFL.> 
  > > Some people indicate this oscillator as a very good one.> 
  > > > > > On Internet I have only found formula in 
  Metastock at > > > <A 
  href="">http://trader.online.pl/MSZ/e-w-Projection_Oscillator.html> 
  > > > > > I tried to use similar code by modifying it for 
  Amibroker, but I > > > have problems to do it while translating 
  function "PWR" of > metastock > > > and alse because I do 
  not know Metastock at all.> > > > > > Is anybody of 
  this group so kind to help me building this > oscillator?> > 
  > > > > many thanks> > > > > > 
  Hans> > > > > > > > > > > 
  > > > > > > > > > > Send BUG REPORTS 
  to bugs@xxxx> > > Send SUGGESTIONS to suggest@xxxx> > 
  > -----------------------------------------> > > Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx > > > 
  (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)> 
  > > --------------------------------------------> > > Check 
  group FAQ at: > <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  > > > Yahoo! Groups Links> > > > > > 
  > > > > > >  > > > > > 
  >Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
  SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Sponsor


  ADVERTISEMENT 












Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.