An example showing how to create a list of the top winners and losers 0

Posted on 17, June 2013

in Category SID


Description for TopBottom SID 649

An example showing how to create a list of the top winners and losers from a portfolio of stocks using the filter, rank and set functionality.

An example showing how to create a list of the top winners and losers/sid Notes for this Trading Account:

An example showing how to create a list of the top winners and losers/sid Rules for this Trading Account:

An example showing how to create a list of the top winners and losers/sid Notes for this Trading System:

An example showing how to create a list of the top winners and losers/sid Rules for this Trading System:

An example showing how to create a list of the top winners and losers/sid Bar event logic:

#See the End event for the code

An example showing how to create a list of the top winners and losers/sid End event logic:

#The number of symbols we'll include in the top and bottom 
my $number = 5;
#The path to save the HTML file
my $path='C:\Developement\TopBottom.html';

if (FirstNewBar) {
  #create the base set - we use the percentage change as the base for ranking.
  my $set= Filter { Percent(Close); };
  #we now create our top and bottom sets
  my $topfive = $set > $number;
  my $bottomfive = $set < $number;
  #Our HTML output string
  my $output = "<b>The top $number<b>".'<p><table border=1><tr><td>Symbol</td><td>Closing Price</td><td>Change</td><td>RSI</td></tr>';
  #we now run our filter on the top Set
  Filter { $output.='<tr><td>'.Symbol.'</td><td>'.Now(Close).
          '</td><td>'.Round(Now(Percent(Close)),2).
          '%</td><td>'.Round(Now(RSI(14)),2).'</td></tr>'; } $topfive;
  $output.='</table>';
  
  $output.= "<p><b>The bottom $number<b>".'<p><table border=1><tr><td>Symbol</td><td>Closing Price</td><td>Change</td><td>RSI</td></tr>';
  #we now run our filter on the bottom Set
  Filter { $output.='<tr><td>'.Symbol.'</td><td>'.Now(Close).
          '</td><td>'.Round(Now(Percent(Close)),2).
          '%</td><td>'.Round(Now(RSI(14)),2).'</td></tr>'; } $bottomfive;
  #finish the HTML
  $output.='</table>';

  #save the HTML - open a file  
  open (OUTPUT, "> $path") or die "can't open file $path";
  #print the output to the file
  print OUTPUT $output;
  close OUTPUT;
}


0 Comments

Leave a Message