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

Re: [amibroker] Re: Trendline with Degree output for Moving Average



PureBytes Links

Trading Reference Links




<FONT face="Courier New" 
size=3>Gernot 
I posted this several days ago... Radians to 
Degrees....It uses Moving averages and gives the angle of Ascent or 
descent.
 


//Radians to Degrees
//Anthony Faragasso
//June 13,2003
ema1period=Param<FONT 
size=2>("ema1Period"<FONT 
size=2>,4<FONT 
size=2>,4<FONT 
size=2>,9<FONT 
size=2>,1);
EMA2period=Param<FONT 
size=2>("ema2Period"<FONT 
size=2>,9<FONT 
size=2>,9<FONT 
size=2>,20<FONT 
size=2>,1);
EMA3period=Param<FONT 
size=2>("ema3Period"<FONT 
size=2>,20<FONT 
size=2>,20<FONT 
size=2>,28<FONT 
size=2>,1);
SlopePeriods=Param<FONT 
size=2>("SlopePeriods"<FONT 
size=2>,10<FONT 
size=2>,2<FONT 
size=2>,25<FONT 
size=2>,1);
PI=3.14159;
Array=C;
Var1=EMA<FONT 
size=2>(array,EMA1period);
Var2=EMA<FONT 
size=2>(array,EMA2period);
Var3=EMA<FONT 
size=2>(array,EMA3period);
EMAFast=LinRegSlope<FONT 
size=2>(Var1,SlopePeriods);
EMAMedium=LinRegSlope<FONT 
size=2>(Var2,SlopePeriods);
EMASlow=LinRegSlope<FONT 
size=2>(Var3,SlopePeriods);
Radians=atan<FONT 
size=2>(EMAFast);//radians<FONT 
size=2>
Radians2=atan<FONT 
size=2>(EMAMedium);
Radians3=atan<FONT 
size=2>(EMASlow);
degrees=Radians*(180<FONT 
size=2>/PI);//Degrees
degrees2=Radians2*(180<FONT 
size=2>/PI);
degrees3=Radians3*(180<FONT 
size=2>/PI);
 
Plot(Var1,<FONT color=#ff00ff 
size=2>"emaFast",colorRed,styleLine);<FONT 
color=#0000ff size=2>
Plot(Var2,<FONT color=#ff00ff 
size=2>"emaMedium",colorBlue,styleLine);<FONT 
color=#0000ff size=2>
Plot(Var3,<FONT color=#ff00ff 
size=2>"emaSlow",colorYellow,styleLine);<FONT 
color=#0000ff size=2>
Plot(C,<FONT color=#ff00ff 
size=2>"",colorBlack,styleLine);
Title=Name<FONT 
size=2>()+"..."<FONT 
size=2>+Date<FONT 
size=2>()+"\n"<FONT 
size=2>+"Based on ( "<FONT 
size=2>+WriteVal<FONT 
size=2>(slopeperiods,1<FONT 
size=2>)+" ) period LinearRegSlope of 
Variable "+<FONT color=#ff00ff 
size=2>"\n"+"The ( 
"+WriteVal<FONT 
size=2>(EMA1period,1<FONT 
size=2>)+ " ) period EMA is moving 
"+WriteIf<FONT 
size=2>(degrees > 0<FONT 
size=2>,"UP "<FONT 
size=2>,"Down "<FONT 
size=2>)+"( "<FONT 
size=2>+WriteVal<FONT 
size=2>(degrees,1<FONT 
size=2>)+" )"<FONT 
size=2>+" Degrees"<FONT 
size=2>+"\n"<FONT 
size=2>+"The ( "<FONT 
size=2>+WriteVal<FONT 
size=2>(EMA2period,1<FONT 
size=2>)+ " ) period EMA is moving 
"+WriteIf<FONT 
size=2>(degrees2 > 0<FONT 
size=2>,"UP "<FONT 
size=2>,"Down "<FONT 
size=2>)+"( "<FONT 
size=2>+WriteVal<FONT 
size=2>(degrees2,1<FONT 
size=2>)+" )"<FONT 
size=2>+" Degrees"<FONT 
size=2>+"\n"<FONT 
size=2>+"The ( "<FONT 
size=2>+WriteVal<FONT 
size=2>(EMA3period,1<FONT 
size=2>)+ " ) period EMA is moving 
"+WriteIf<FONT 
size=2>(degrees3 > 0<FONT 
size=2>,"UP "<FONT 
size=2>,"Down "<FONT 
size=2>)+"( "<FONT 
size=2>+WriteVal<FONT 
size=2>(degrees3,1<FONT 
size=2>)+" )" 
+" Degrees"<FONT 
size=2>;
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  taotra 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Wednesday, June 18, 2003 9:08 
  AM
  Subject: [amibroker] Re: Trendline with 
  Degree output
  Graham,I agree with your assessment of price 
  changes and slopes across many different stocks.  However, I daytrade 
  Forex (primarily 5 currency pairs) in real-time on 10-min charts.  A 
  degree angle of MAs would be very useful to me as a quick indicator of 
  where things are going because of the many minitrends, retracements, and 
  consolidations throughout a single trading day.Gernot--- 
  In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> wrote:> 
  As a genberal topic discussing relative moves of stock prices and 
  trend> strengths> I prefer to use price unit per time period 
  and through my investigation of> many charts I have found that this 
  "slope" varies between different stocks,> and within a stock for 
  the different price ranges. What might be normal> slope for one 
  stock could be either fast or slow for another. The strength> of 
  the move for a stock can also be dependant on the overall price> 
  behaviour. An example would be that if there has been a 
  considerable> accumulation pattern the initial move, when it does 
  happen, will often be> fast and short lived. Then as the "traders" 
  move out the investors will make> the moves and pace will slow 
  down. These moves can be either direction.> I have set up a small 
  line on my charts to give me what could be termed the> "average 
  slope" for that stock in recent times. I can then place the gann> 
  fan over this using the line as the 100% (1:1 line) and move the fan to 
  the> recent turning point to provide a visual aid on the progression of 
  the move.> This is in its own indicator chart panel for this 
  purpose.> > Cheers,> Graham> <A 
  href="">http://groups.msn.com/ASXShareTrading> 
  <A 
  href="">http://groups.msn.com/FMSAustralia> 
  > > -----Original Message-----> From: taotra 
  [mailto:ggoll@xxxx] > Sent: Wednesday, 18 June 2003 7:27 PM> To: 
  amibroker@xxxxxxxxxxxxxxx> Subject: [amibroker] Re: Trendline with 
  Degree output> > > Personally, I find the angle output 
  very useful because it's an easy > to understand indicator of trend 
  strength regardless of the time > frame.  For example, a 60 degree 
  angle of a trendline (strong trend) > on a 4-hour chart can look 
  almost flat on a 1-min chart (zoomed).  > The fact that the angle 
  remains the same, makes it easy when looking > across different 
  time periods.> > In addition, however, can't an angle measure be 
  useful with MAs as a > measure of trend strength or 
  consolidation?  Let's say a 20-period > MA is rising in a 
  stairstep fashion.  The average degree of that > rise (from an 
  imaginary horizontal zero line) over 10-, 20-, or 50 > periods would 
  show how strong the trend is.  Similarly, when in > consolidation 
  an MA may bounce around the flatline in a zigzag > fashion over x 
  periods.  A low average degree (of deviation from > zero) would 
  indicate consolidation.  Obviously, using angles with > MAs is 
  time-frame dependent.> > Gernot>  > --- In 
  amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" > <TSOKAKIS@xxxx> 
  wrote:> > Anthony,> > I agree, the angle output ( value ) 
  in the title will not change. The > > question is the further 
  use of the angle. The only purpose is> to > > know the angle, 
  it can not go further. If it is "attractive" to> know > > the 
  angle, it is OK, there is no need to change anything... Do the > 
  > readers think the same way ? Is it easy for the average> user 
  > > to hanlde a result angle=45 deg, the same moment he sees a 
  20deg> on > > his chart ? These are my personal hesitations 
  and I avoid using> angle > > at all. But, if you like it, no 
  problem at all !!> > DT> > --- In 
  amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso"> <ajf1111@xxxx> 
  > > wrote:> > > Dimitri,> > > > 
  > > Thank you for the input...( actually I was hoping for your> 
  > comments , Thank you) ....I will make the adjustment to the> 
  formula > > and re-post.....> > > > > > As 
  for the angle view in respect to the zoom factor...Granted ,> on 
  > > the screen , when zoomed in or out  the angle 
  perspective  will> > change  .....But ...the angle output 
  ( value ) in the title will > not > > change when the chart 
  is zoomed in or out.....Therefore, the angle> of > > 
  ascent or descent will be known......( is this a correct> > 
  assumption ) .> > > > > > Anthony> > 
  >   ----- Original Message ----- > > >   
  From: DIMITRIS TSOKAKIS > > >   To: 
  amibroker@xxxxxxxxxxxxxxx > > >   Sent: Tuesday, June 
  17, 2003 7:19 PM> > >   Subject: [amibroker] Re: 
  Trendline with Degree output> > > > > > > 
  > >   Anthony,> > >   you do not really 
  need LinRegSlope.> > >   In the straight line 
  equation> > >   trendline = aS * ( x -endbar ) + 
  bS;> > >   aS is the slope, ie the tangent of the angle 
  [in radians] and> > >   atan(aS) would be directly your 
  "myradian"> > >   myradian=atan(aS);> > 
  >   Then you may transform it to deg.> > 
  >   As for the use : We do not read real angles in 
  amibroker> charts, > > a> > >   pi/3 
  angle will look like pi/4  or pi/6 according to zoom.> > 
  >   aS alone could do the job, ie aS1>0 for positive slope 
  or> aS1>aS2> > for> > >   
  correlations [useful for wedges, for example...].> > 
  >   aS is the tangent function of the angle and, from a 
  math> > property,> > >   angle inequalities 
  go 1 to 1 with tangent inequalities,> > consequently> > 
  >   you will miss nothing .> > >   --- In 
  amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso"> > 
  <ajf1111@xxxx>> > >   wrote:> > 
  >   > Thanks Mark.....I am looking into it.....> > 
  >   > > > >   > Anthony> > 
  >   >   ----- Original Message ----- > > 
  >   >   From: MarkF2 > > >   
  >   To: amibroker@xxxxxxxxxxxxxxx > > >   
  >   Sent: Tuesday, June 17, 2003 3:20 PM> > 
  >   >   Subject: [amibroker] Re: Trendline with 
  Degree output> > >   > > > 
  >   > > > >   >   Anthony- 
  really nice, but I think there's a bug > somewhere.  > > 
  >   Comparing> > >   >   QQQ 
  with NDX, I got slopes of 4 and 72 degrees > respectively, > 
  > even> > >   >   though both 
  trendlines were 27 days and the slopes looked > the > > 
  >   same.> > >   > > > 
  >   >   Mark> > >   > 
  > > >   >   --- In 
  amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso" > > >   
  <ajf1111@xxxx>> > >   >   
  wrote:> > >   >   > //Automatic Support 
  Trendline With Degrees> > >   >   > 
  > > >   >   > //Anthony Faragasso, 
  2003> > >   >   > > > 
  >   >   > x = Cum(1);> > 
  >   >   > > > >   
  >   > per =Param("Percent",2,0.01,3,0.01);// Sensitivity 
  > setting> > >   >   > > 
  > >   >   > s1=L;//Array> > 
  >   >   > > > >   
  >   > EndValue1 = LastValue( Trough( s1, per, 1 ) );> 
  > >   >   > > > >   
  >   > startvalue = LastValue( Trough( s1, per, 2 ) );> 
  > >   >   > > > >   
  >   > endbar = LastValue( ValueWhen( s1 == EndValue1, x, 1 
  ) );> > >   >   > > > 
  >   >   > startbar = LastValue( ValueWhen( s1 == 
  startvalue, x, > 1 ) );> > >   >   
  > > > >   >   > aS = 
  (EndValue1-startvalue)/(endbar-startbar);> > >   
  >   > > > >   >   > bS 
  = EndValue1;> > >   >   > > > 
  >   >   > trendline = aS * ( x -endbar ) + 
  bS;> > >   >   > > > 
  >   >   > 
  //-----------------------------------//> > >   
  >   > > > >   >   > 
  //      Conversion to 
  Degrees              
  //> > >   >   > > > 
  >   >   > 
  //-----------------------------------//> > >   
  >   > > > >   >   > 
  pi=4*atan(1);> > >   >   > > 
  > >   >   > time=endbar-startbar;> > 
  >   >   > > > >   
  >   > myslope=LinRegSlope(trendline,time);> > 
  >   >   > > > >   
  >   > myradian=atan(myslope);> > >   
  >   > > > >   >   > 
  mydegree=myradian*(180/PI);//Degrees> > >   
  >   > > > >   >   > 
  //-------------------------------------//> > >   
  >   > > > >   >   > 
  Plot(C,"close",colorBlack,styleCandle);> > >   
  >   > > > >   >   
  >> > >   >   
  Plot(IIf(x>startbar-5,trendline,-> > >   
  1e10),"Trendline",colorYellow,styleLine);> > >   
  >   > > > >   >   > 
  direction=WriteIf(mydegree >= 0 AND mydegree <= > 
  0.99,"Flat> > >   >   > 
  ",WriteIf(mydegree > 0 ,"Rising ",WriteIf(mydegree < > > 
  >   0 , "Falling ",> > >   
  >   "")));> > >   >   > 
  > > >   >   > 
  DirectionColor=LastValue(IIf(mydegree >> > >   
  >   0,colorBrightGreen,IIf(mydegree < 0,> > 
  >   >   > colorRed,IIf(mydegree >= 0 AND 
  mydegree <= > > >   0.99 
  ,colorYellow,Null))));> > >   >   > 
  > > >   >   > 
  Title=Name()+"..."+Date()+"\n"+"TRENDLINE is> > >   
  >   > 
  "+EncodeColor(directioncolor)+direction+EncodeColor> > 
  (colorBlack)> > >   +"at> > >   
  >   "+"( "+> > >   >   > 
  WriteVal(mydegree,1)+" )"+" Degrees";> > >   
  >   > > > >   >   > 
  > > >   >   > > > 
  >   >   > //plotting ( x, y ) grid> > 
  >   >   > > > >   
  >   > Plot> 
  (startbar==x,"",colorRed,styleHistogram|styleOwnScale);> > 
  >   >   > > > >   
  >   > 
  Plot(ValueWhen(startbar==x,Low),"",colorRed,styleLine);> > 
  >   >   > > > >   
  >   > //-----------------------------------//> > 
  >   >   > > > >   
  >   > // Automatic Anlaysis window Output //> > 
  >   >   > > > >   
  >   > //-----------------------------------//> > 
  >   >   > > > >   
  >   > // Settings : //> > >   
  >   > > > >   >   > // 
  n last quotations and n=1 //> > >   >   
  > > > >   >   > // explore 
  //> > >   >   > > > 
  >   >   > 
  //-----------------------------------//> > >   
  >   > > > >   >   > 
  Filter=mydegree > 0 OR mydegree <0;> > >   
  >   > > > >   >   > 
  AddColumn(mydegree,"Degree",1);> > >   >   
  > > > >   >   > > > 
  >   >   > > > >   
  >   > > > >   >   > 
  ---> > >   >   > Outgoing mail is 
  certified Virus Free.> > >   >   > 
  Checked by AVG anti-virus system > (<A 
  href="">http://www.grisoft.com).> > 
  >   >   > Version: 6.0.489 / Virus Database: 288 
  - Release Date: > > 6/10/2003> > >   > 
  > > >   > > > >   
  >         Yahoo! Groups Sponsor 
  > > >   >        
  > > >   >        
  > > >   > > > >   > 
  > > >   >   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 
  > > >   > > > >   
  >   Your use of Yahoo! Groups is subject to the Yahoo! Terms 
  > of > > >   Service. > > 
  >   > > > >   > > > 
  >   >   ---> > >   
  >   Outgoing mail is certified Virus Free.> > 
  >   >   Checked by AVG anti-virus system (<A 
  href="">http://www.grisoft.com).> > 
  >   >   Version: 6.0.489 / Virus Database: 288 - 
  Release Date: > > 6/10/2003> > > > > > 
  > > >         Yahoo! 
  Groups Sponsor > > 
  >               
  ADVERTISEMENT> > 
  >              
  > > >        > > 
  >        > > > > 
  > > > > >   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> 
  > > > > >   Your use of Yahoo! Groups is subject 
  to the Yahoo! Terms of> > Service.> > > > > 
  > > > >   ---> > >   Outgoing 
  mail is certified Virus Free.> > >   Checked by AVG 
  anti-virus system (<A 
  href="">http://www.grisoft.com).> > 
  >   Version: 6.0.490 / Virus Database: 289 - Release 
  Date:> 6/16/2003> > > > 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 
  > > Your use of Yahoo! Groups is subject to <A 
  href="">http://docs.yahoo.com/info/terms/
  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 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 
  
<BLOCKQUOTE 
><FONT 
  face="Courier New">---Outgoing mail is certified Virus 
  Free.Checked by AVG anti-virus system (<A 
  href="">http://www.grisoft.com).Version: 6.0.490 
  / Virus Database: 289 - Release Date: 
6/16/2003






Yahoo! Groups Sponsor












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



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.