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

RE: [amibroker] Re: Expectation Analysis Code needed



PureBytes Links

Trading Reference Links




Pal, 
This was previously posted.
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2> See attached.
<FONT face=Arial color=#0000ff 
size=2> 
Mr 
Valley

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: palsanand 
  [mailto:palsanand@xxxxxxxxx]Sent: Friday, December 05, 2003 10:22 
  PMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] Re: 
  Expectation Analysis Code neededI'm able to copy the 
  code using Edit -> Select All.  I was just wondering if anybody 
  has any additional code/Interpretation/modifications/improvements to this 
  expectation analysis code...TIArgds, Pal--- In 
  amibroker@xxxxxxxxxxxxxxx, "palsanand" <palsanand@xxxx> wrote:> 
  Hi All,> > I'm tryin to do an Expectation Analysis describe by 
  > > <A 
  href="">http://www.amibroker.net/3rdparty/IntroToAtc.pdf  
  pages 29-32> > I'm not able to copy and paste the code from this 
  pdf file.  I was > wondering if anybody has this code.  I'm 
  trying to add to the > following code:> > /* your trading 
  system functions here */> ...> /*Buy and Sell rules here 
  */> > /*Buy = Cover = ...;> > Sell = Short = ...; 
  */> > Buy = ExRem(Buy,Sell);> > Sell = 
  ExRem(Sell,Buy);> > Short = ExRem(Short,Cover);> > 
  Cover = ExRem(Cover,Short);> > AddToComposite( Equity(), 
  "~CompositeEquity", "X" ); //Filter for > scan set to a list, e.g., 
  list0> > shape = Buy * shapeUpArrow + Sell * 
  shapeDownArrow;> PlotShapes(IIf> (Buy,shapeUpArrow,shapeNone) 
  ,colorBrightGreen,0,Graph0,-15); > 
  PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,Graph0,-15); 
  > PlotGrid(1);> PlotGrid(-1); > GraphXSpace=10; > 
  > ApplyStop(stopTypeTrailing, stopModePoint, 3*ATR(14), True, > 
  True ); /* Chandelier Exit - Actually I use 3BSMA stop but cant use > 
  this function for that */> > Equity(1); // THIS EVALUATES 
  STOPS> Title = Name() + ": " + Date() + " Open " + WriteVal> 
  (O,1.4) + " Hi " +WriteVal(H,1.4) + " Lo "> +WriteVal(L,1.4) + "  
  Close " + WriteVal(C,1.4);> > /* the following line uses Flip 
  function to get "1" after the buy > signal and reset it back to "0" 
  after sell appears. */> > in_trade = Flip( Buy, Sell );> 
  > AddToComposite( in_trade, "~OpenPosCount", "V" );> > /* 
  We use "~OpenPosCount" artificial ticker to store the results. > Again 
  we should run just Scan of the formula AND the "~OpenPosCount" > 
  ticker would become available. > > Use */ > > 
  Graph0 = Foreign( "~OpenPosCount", "V"); > > /* in Indicator 
  Builder after running the back-test to see the chart > of the 
  number of Open positions of your system. */> > e = 
  Equity(1);  // THIS EVALUATES STOPS> > tradeend1 = 
  Sell;> tradeend2 = Cover;> > profit1 = e - ValueWhen( 
  Buy, e );> profit2 = e - ValueWhen( Short, e);> > 
  endprofit1 = IIf( tradeend1 , profit1, 0 );> endprofit2 = IIf( 
  tradeend2 , profit2, 0 );> > LosingLongTrades = LastValue( Cum( 
  endprofit1 < 0 ) );> LosingShortTrades = LastValue( Cum( endprofit2 
  < 0 ) );> WiningLongTrades = LastValue( Cum( endprofit1 > 0 ) 
  );> WiningShortTrades = LastValue( Cum( endprofit2 > 0 ) );> 
  TotalLongTrades = LastValue( Cum( tradeend1 ) );> TotalShortTrades = 
  LastValue( Cum( tradeend2 ) );> > > AddColumn( 
  LosingLongTrades, "Losing Long trades", 1 );> AddColumn( 
  WiningLongTrades, "Wining Long trades", 1 );> AddColumn( 
  TotalLongTrades, "Total Long trades", 1 );> AddColumn( 
  LosingShortTrades, "Losing Short trades", 1 );> AddColumn( 
  WiningShortTrades, "Wining Short trades", 1 );> AddColumn( 
  TotalShortTrades, "Total Short trades", 1 );> > > Filter 
  = Status("lastbarinrange");> > // now we will count the number 
  of > // count trades winning in given $ ranges> NumRanges = 25; 
  // number of ranges to generate> RangeSize = 100; // controls $ size of 
  the range> > for( i = 0; i < NumRanges; i++ )> 
  {>   rangestart = i * RangeSize;>   rangeend 
  = (i+1)*RangeSize;>   if( i == NumRanges - 1 ) rangeend = 
  999999;>   AddColumn( >   LastValue( 100* 
  Cum( endprofit1 > rangestart AND endprofit1 < > rangeend ) 
  /TotalLongTrades ),>   "% with profit " + rangestart + ".." + 
  rangeend );> AddColumn( >   LastValue( 100* Cum( 
  endprofit2 > rangestart AND endprofit2 < > rangeend ) 
  /TotalShortTrades ),>   "% with profit " + rangestart + ".." 
  + rangeend );> > }> > for( i = 0; i < 
  NumRanges; i++ )> {>   rangestart = (-i - 1 ) * 
  RangeSize;>   rangeend = -i*RangeSize;>   
  if( i == NumRanges - 1 ) rangestart = -999999;>   AddColumn( 
  >   LastValue( 100* Cum( endprofit1 > rangestart AND 
  endprofit1 < > rangeend ) /TotalLongTrades ), >   " 
  % with loss " + rangeend + ".." + rangestart );> AddColumn( 
  >   LastValue( 100* Cum( endprofit2 > rangestart AND 
  endprofit2 < > rangeend ) /TotalShortTrades ), >   
  " % with loss " + rangeend + ".." + rangestart );> > }> 
  > TIA> rgds, palSend 
  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. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









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.



Attachment:
Expectation.afl

Attachment: Description: "Description: Binary data"