<?php
if (isset($nh)) 
  echo "<body text='#000000' bgcolor='#FFFFFF'>"; ?>
<?php
 if (!isset($user_dir)) $user_dir='.';
 if (!isset($nh)) {
  if ($opt =='0') {
   exit();
  } else {
   echo "<html>
    <head><meta name=robots content=noindex,nofollow>
    <title>4.11 Trading resistance levels</title>
    </head><body text='#000000' bgcolor='#FFFFFF'>
    <table border=0 bgcolor=#dcdcdc cols=10 cellpadding=5 width=800 cellspacing=0>
     <tr align=bottom><td nowrap>
      <a href=javascript:history.go(-1) onMouseover=\"window.status=' # previous'; return true\"
             ><img src='../IMAGES/nav_previous.png' border=0 align=bottom></a>
      <a href=javascript:history.go(-2) onMouseover=\"window.status=' # 2 previous'; return true\"
             ><img src='../IMAGES/nav_up.png' border=0 align=bottom></a>
     <img src='../IMAGES/nav_next_gr.png' border=0 align=bottom>
      <a href='".$user_dir."/../../SYL/node1.php' onMouseover=\"window.status=' # course'; return true\"
            ><img src='../IMAGES/nav_contents.png' border=0 align=bottom></a>
      &nbsp;&nbsp;<b><font size=+1>4.11 Trading resistance levels</font></b></td><td>&nbsp;</td>
     </tr></table><br clear=both><br>";
     # Creates problems with reload  echo "<table border=0 width=800><td>";
  }
 }; ?>
                 
 
<p>
                                                                             
<font color="#0000FF">
<em>Rather than showing a complete solution, the teacher decided here to give you his 
own applet and guide you through a series of experiments illustrating the effect of
resistance / support levels. To complete this exercise, your task will be to implement 
your own scheme in the applet and discuss what you observe.</em>
<font color="#000000">

<p>
First check <a href="../../edu/SRC/assign.php">assignment 2.03</a> for a description of a 
market parametrized with a <em>Drift=0.03</em>, a <em>Volatility=0.3</em>, taking account
of the price dynamics with a resistance / support level at <em>Barrier=10.0</em> and an
intensity <em>UserDouble=0.02</em>.
A Monte-Carlo sampling of the underlying can now be used to calculate the expected
value for a European put option with a <em>StrikePrice=9.0</em> for up to 9 months or 
<em>RunTime=0.75</em> years before the expiry and is discounted back to prevent time 
assuming a risk free <em>SpotRate=0.03</em>.

<ol type="1"><p>
<li> Study the payoff dynamics obtained with (<em>UserInteger=2</em>) and without 
      (<em>UserInteger=1</em>) resistance / support level.</li>
<p>
<li> Click inside the plot area to measure the price in-the-money, at-the money 
      and out-of-the money. Which option is is most affected?</li>
<p>
<li> Formulate a trading strategy exploiting the presence of a support level in the 
      underlying, assuming that this has not already been priced into the derivatives
      market. 
      Edit the parameters to acquire an intuition for the situations when such a 
      strategy may exceed the transaction costs.</li>
</ol>
</font></font><br><p><applet codebase="<?php echo $user_dir ?>/applet/" code=vmarket align=center width=660 height=390>
       <param name=topic               value="Exercise">
       <param name=scheme              value="Exercise 4.11">
       <param name=ic                  value="Put">
       <param name=method              value="Monte-Carlo">
       <param name=RunTime             value=0.75>
       <param name=Drift               value=0.06>
       <param name=SpotRate            value=0.03>
       <param name=Volatility          value=0.4>
       <param name=LogNkappa           value=1.01>
       <param name=MeshLength          value=16.>
       <param name=MeshPoints          value=17>
       <param name=Walkers             value=500>
       <param name=TimeStep            value=0.00397>
       <param name=StrikePrice         value=9.>
       <param name=Barrier             value=10.>
       <param name=UserInteger         value=2>
       <param name=UserDouble          value=0.2>
</applet><br><p><br>
<a href="<?php echo $user_dir ?>/applet/version/help_tag.php">VMarket applet</a>: press <B>START/STOP</B> 
for execution.

        
        
        
        <br><p><hr><b>Numerical scheme in Java:</b><pre>
double timeStep= runData.getParamValue("TimeStep"); // Run parameters
double mu      = runData.getParamValue("Drift");
double sigma   = runData.getParamValue("Volatility");
int    type    = runData.getParamValueInt("UserInteger");

if (type == 1) { // Log-normal walk for stock prices (no modification required)

  for(int j=0; j&lt;f.length; j++) {
    for(int k=0; k&lt;numberOfRealisations; k++){
      currentState[k][j] += currentState[k][j] * 
        ( mu*timeStep +
          sigma*random.nextGaussian()*Math.sqrt(timeStep) );
    } // (for realisations)
  } // for (initial conditions)

} else if (type == 2) { // Simulate resistance/support levels (please modify)

  double barrier   = runData.getParamValue("Barrier"); // Extra parameters
  double intensity = runData.getParamValue("UserDouble");
  double width     = 0.1*barrier;
  double odds      = 2*intensity-1; 

// Examples of useful functions in Java
// double uniform01  = Math.random();         // random number in U(0,1)
// double gaussian01 = random.nextGaussian(); // random number in N(0,1)
// double e   = Math.exp(1.);
// double one = Math.log(e);
// System.out.println("Debug: type="+type);   // print to browser Java-console

  for(int j=0; j&lt;f.length; j++) {

      // Insert her your code from assignment 2.03, substituting 
      //   currentState[k][0] -> currentState[k][j]

  } // for (initial conditions)

} // if (type)
        </pre><?php
  echo "<br><p><address>
    <table border=0 bgcolor=#dcdcdc cols=10 cellpadding=5 width=800 cellspacing=0>
     <tr align=bottom><td nowrap>
      <a href=javascript:history.go(-1) onMouseover=\"window.status=' # previous'; return true\"
             ><img src='../IMAGES/nav_previous.png' border=0 align=bottom></a>
      <a href=javascript:history.go(-2) onMouseover=\"window.status=' # 2 previous'; return true\"
             ><img src='../IMAGES/nav_up.png' border=0 align=bottom></a>
    <img src='../IMAGES/nav_next_gr.png' border=0 align=bottom>
      <a href='".$user_dir."/../../SYL/node1.php' onMouseover=\"window.status=' # course'; return true\"
             ><img src='../IMAGES/nav_contents.png' border=0 align=bottom></a></td>
     <td nowrap>Copyright&nbsp;&copy;&nbsp;Doc Andre Jaun &amp; 
      <a href='http://localhost/opt/' onMouseover=\"window.status=' # home'; return true\"
    >Lifelong-Learners/opt</a> at  06:53:57,  May 05th, 2004   </td></tr></table>
    </address></body></html>"; ?>
