rohitb Posted July 15, 2012 Share Posted July 15, 2012 hello friends im making gann level calculator for my website http://www.technitrade.co.in managed to do some basic coding which prints the Gann square of nine now i want to add recommendations like buy if the stock price is above particular price for targets as per gann calculations and sell if stock price is below particular price eg if in the box **ENTER CURRENT MARKET PRICE** u enter **50** u should get a table showing u different values. now our entered price is in between 49 and 50.77 so in recommendations section i shuld be able to print **Buy At/Above 50.77 for Targets 52.56, 54.39, 56.25, 58.14, 60.06** and **Sell At/Below 49 for Targets 47.27,45.56,43.89,42.25,40.64** below is my code <html> <body> <center> <h2> Gann Levels Calculator! </h2> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <b>Enter Current Market Price<input type="text" name="num1" /> <T><br><input type="submit" value="Calculate Gann Levels ->>" /> </form> <?php $num1 = $_POST["num1"]; $square_root=ceil(sqrt($num1)); $one_num_below=$square_root-1; $two_num_below=$square_root-2; $one_num_above=$square_root+1; $two_num_above=$square_root+2; $center_value=$two_num_below*$two_num_below; $value_one=$two_num_below+0.125; $value_one_fin=round($value_one*$value_one,2); $value_two=$value_one+0.125; $value_two_fin=round($value_two*$value_two,2); $value_three=$value_two+0.125; $value_three_fin=round($value_three*$value_three,2); $value_four=$value_three+0.125; $value_four_fin=round($value_four*$value_four,2); $value_five=$value_four+0.125; $value_five_fin=round($value_five*$value_five,2); $value_six=$value_five+0.125; $value_six_fin=round($value_six*$value_six,2); $value_seven=$value_six+0.125; $value_seven_fin=round($value_seven*$value_seven,2); $value_eight=$value_seven+0.125; $value_eight_fin=round($value_eight*$value_eight,2); $value_nine=$value_eight+0.125; $value_nine_fin=round($value_nine*$value_nine,2); $value_ten=$value_nine+0.125; $value_ten_fin=round($value_ten*$value_ten,2); $value_eleven=$value_ten+0.125; $value_eleven_fin=round($value_eleven*$value_eleven,2); $value_twelve=$value_eleven+0.125; $value_twelve_fin=round($value_twelve*$value_twelve,2); $value_thirteen=$value_twelve+0.125; $value_thirteen_fin=round($value_thirteen*$value_thirteen,2); $value_fourteen=$value_thirteen+0.125; $value_fourteen_fin=round($value_fourteen*$value_fourteen,2); $value_fifteen=$value_fourteen+0.125; $value_fifteen_fin=round($value_fifteen*$value_fifteen,2); $value_sixteen=$value_fifteen+0.125; $value_sixteen_fin=round($value_sixteen*$value_sixteen,2); $value_seventeen=$value_sixteen+0.125; $value_seventeen_fin=round($value_seventeen*$value_seventeen,2); $value_eighteen=$value_seventeen+0.125; $value_eighteen_fin=round($value_eighteen*$value_eighteen,2); $value_nineteen=$value_eighteen+0.125; $value_nineteen_fin=round($value_nineteen*$value_nineteen,2); $value_twenty=$value_nineteen+0.125; $value_twenty_fin=round($value_twenty*$value_twenty,2); $value_twentyone=$value_twenty+0.125; $value_twentyone_fin=round($value_twentyone*$value_twentyone,2); $value_twentytwo=$value_twentyone+0.125; $value_twentytwo_fin=round($value_twentytwo*$value_twentytwo,2); $value_twentythree=$value_twentytwo+0.125; $value_twentythree_fin=round($value_twentythree*$value_twentythree,2); $value_twentyfour=$value_twentythree+0.125; $value_twentyfour_fin=round($value_twentyfour*$value_twentyfour,2); echo "<table cellpadding='5' cellspacing='2' border='0'>"; //depending on your own parameters of course, but the values must be in single quotes echo "<tr><td bgcolor=#FF0099><font size=1 face=verdana>$value_eighteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_nineteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_twenty_fin</td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_ten_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_eleven_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_twelve_fin</td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_two_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_three_fin</td><td bgcolor=#FF0099><font size=1 face=verdana>$value_four_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#CC0066><font size=1 face=verdana>$value_seventeen_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_nine_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_one_fin</td><td bgcolor=#FF3399><font size=1 face=verdana>$center_value</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_five_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_thirteen_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_twentyone_fin</td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_eight_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_seven_fin</td><td bgcolor=#FF0099><font size=1 face=verdana>$value_six_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_sixteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_fifteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_fourteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#FF0099><font size=1 face=verdana>$value_twentyfour_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_twentythree_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_twentytwo_fin</td></tr>"; echo "</table>"; //this ends your table echo "<br><br>"; echo "<table cellpadding='5' cellspacing='2' border='0'>"; //depending on your own parameters of course, but the values must be in single quotes echo "<tr><td bgcolor=#FF6633><font size=1 face=verdana>R1</td><td bgcolor=#FF6633><font size=1 face=verdana>R2</td><td bgcolor=#FF6633><font size=1 face=verdana>R3</td><td bgcolor=#FF6633><font size=1 face=verdana>R4</td><td bgcolor=#FF6633><font size=1 face=verdana>R5</td></tr>"; echo "<tr><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#FF6633><font size=1 face=verdana>S1</td><td bgcolor=#FF6633><font size=1 face=verdana>S2</td><td bgcolor=#FF6633><font size=1 face=verdana>S3</td><td bgcolor=#FF6633><font size=1 face=verdana>S4</td><td bgcolor=#FF6633><font size=1 face=verdana>S5</td></tr>"; echo "<tr><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td><td bgcolor=#FF6633><font size=1 face=verdana></td></tr>"; echo "</table>"; echo "<br><br>"; function findClosest($sortedArray,$value) { $numberOfElements = count($sortedArray); $middle = floor($numberOfElements/2); if($sortedArray[$middle] == $value || $numberOfElements == 1) return $sortedArray[$middle]; elseif($sortedArray[$middle] < $value) { #upperhalf $half = array_slice($sortedArray,$middle); } else { #lowerhalf $half = array_slice($sortedArray,0,$middle); } $closestHalf = findClosest($half,$value); return (abs($value - $sortedArray[$middle]) < abs($value - $closestHalf)) ? $sortedArray[$middle] : $closestHalf; } $sortedArray = array($value_one_fin,$value_two_fin,$value_three_fin,$value_four_fin,$value_five_fin,$value_six_fin,$value_seven_fin,$value_eight_fin,$value_nine_fin,$value_ten_fin,$value_eleven_fin,$value_twelve_fin,$value_thirteen_fin,$value_fourteen_fin,$value_fifteen_fin,$value_sixteen_fin,$value_seventeen_fin,$value_eighteen_fin,$value_nineteen_fin,$value_twenty_fin,$value_twentyone_fin,$value_twentytwo_fin,$value_twentythree_fin,$value_twentyfour_fin); $result=findClosest($sortedArray,$num1); print findClosest($sortedArray,$num1); echo "<table cellpadding='5' cellspacing='2' border='0'>"; echo "<tr><td bgcolor=#FF6633><font size=1 face=verdana>Recomendations</td></tr>"; echo "<tr><td bgcolor=#FF6633><font size=1 face=verdana>Buy At/Above for Targets"</td></tr>"; echo "<tr><td bgcolor=#FF6633><font size=1 face=verdana>Sell At/Below for Targets</td></tr>"; echo "</table>"; ?> </center> </body> </html> Pls help me how should i print the values For Buy and Sell we can't hardcode as user can enter any number Quote Link to comment Share on other sites More sharing options...
ignace Posted July 15, 2012 Share Posted July 15, 2012 $value_one=$two_num_below+0.125; $value_one_fin=round($value_one*$value_one,2); $value_two=$value_one+0.125; $value_two_fin=round($value_two*$value_two,2); $value_three=$value_two+0.125; $value_three_fin=round($value_three*$value_three,2); $value_four=$value_three+0.125; $value_four_fin=round($value_four*$value_four,2); $value_five=$value_four+0.125; $value_five_fin=round($value_five*$value_five,2); $value_six=$value_five+0.125; $value_six_fin=round($value_six*$value_six,2); $value_seven=$value_six+0.125; $value_seven_fin=round($value_seven*$value_seven,2); $value_eight=$value_seven+0.125; $value_eight_fin=round($value_eight*$value_eight,2); $value_nine=$value_eight+0.125; $value_nine_fin=round($value_nine*$value_nine,2); $value_ten=$value_nine+0.125; $value_ten_fin=round($value_ten*$value_ten,2); $value_eleven=$value_ten+0.125; $value_eleven_fin=round($value_eleven*$value_eleven,2); $value_twelve=$value_eleven+0.125; $value_twelve_fin=round($value_twelve*$value_twelve,2); $value_thirteen=$value_twelve+0.125; $value_thirteen_fin=round($value_thirteen*$value_thirteen,2); $value_fourteen=$value_thirteen+0.125; $value_fourteen_fin=round($value_fourteen*$value_fourteen,2); $value_fifteen=$value_fourteen+0.125; $value_fifteen_fin=round($value_fifteen*$value_fifteen,2); $value_sixteen=$value_fifteen+0.125; $value_sixteen_fin=round($value_sixteen*$value_sixteen,2); $value_seventeen=$value_sixteen+0.125; $value_seventeen_fin=round($value_seventeen*$value_seventeen,2); $value_eighteen=$value_seventeen+0.125; $value_eighteen_fin=round($value_eighteen*$value_eighteen,2); $value_nineteen=$value_eighteen+0.125; $value_nineteen_fin=round($value_nineteen*$value_nineteen,2); $value_twenty=$value_nineteen+0.125; $value_twenty_fin=round($value_twenty*$value_twenty,2); $value_twentyone=$value_twenty+0.125; $value_twentyone_fin=round($value_twentyone*$value_twentyone,2); $value_twentytwo=$value_twentyone+0.125; $value_twentytwo_fin=round($value_twentytwo*$value_twentytwo,2); $value_twentythree=$value_twentytwo+0.125; $value_twentythree_fin=round($value_twentythree*$value_twentythree,2); $value_twentyfour=$value_twentythree+0.125; $value_twentyfour_fin=round($value_twentyfour*$value_twentyfour,2); Can all be replaced with: $value = $two_num_below; $names = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', ..); // up to twentyfour //alternatively use pear/Number_Words //$nw = new Number_Words; for ($i = 1; $i <= 24; $i++) { $value += 0.125; //$word = str_replace('-', '', $nw->toWord($i)); ${'value_' . $names[$i - 1]} = $value; ${'value_' . $names[$i - 1] . '_fin'} = round($value * $value, 2); //${'value_' . $word} = $value; //${'value_' . $word . '_fin'} = round($value * $value, 2); } Quote Link to comment Share on other sites More sharing options...
rohitb Posted July 15, 2012 Author Share Posted July 15, 2012 this is a working example http://niftypivots.stockforyouindia.com/p/gann-trading-system.html Quote Link to comment Share on other sites More sharing options...
rohitb Posted July 15, 2012 Author Share Posted July 15, 2012 $value_one=$two_num_below+0.125; $value_one_fin=round($value_one*$value_one,2); $value_two=$value_one+0.125; $value_two_fin=round($value_two*$value_two,2); $value_three=$value_two+0.125; $value_three_fin=round($value_three*$value_three,2); $value_four=$value_three+0.125; $value_four_fin=round($value_four*$value_four,2); $value_five=$value_four+0.125; $value_five_fin=round($value_five*$value_five,2); $value_six=$value_five+0.125; $value_six_fin=round($value_six*$value_six,2); $value_seven=$value_six+0.125; $value_seven_fin=round($value_seven*$value_seven,2); $value_eight=$value_seven+0.125; $value_eight_fin=round($value_eight*$value_eight,2); $value_nine=$value_eight+0.125; $value_nine_fin=round($value_nine*$value_nine,2); $value_ten=$value_nine+0.125; $value_ten_fin=round($value_ten*$value_ten,2); $value_eleven=$value_ten+0.125; $value_eleven_fin=round($value_eleven*$value_eleven,2); $value_twelve=$value_eleven+0.125; $value_twelve_fin=round($value_twelve*$value_twelve,2); $value_thirteen=$value_twelve+0.125; $value_thirteen_fin=round($value_thirteen*$value_thirteen,2); $value_fourteen=$value_thirteen+0.125; $value_fourteen_fin=round($value_fourteen*$value_fourteen,2); $value_fifteen=$value_fourteen+0.125; $value_fifteen_fin=round($value_fifteen*$value_fifteen,2); $value_sixteen=$value_fifteen+0.125; $value_sixteen_fin=round($value_sixteen*$value_sixteen,2); $value_seventeen=$value_sixteen+0.125; $value_seventeen_fin=round($value_seventeen*$value_seventeen,2); $value_eighteen=$value_seventeen+0.125; $value_eighteen_fin=round($value_eighteen*$value_eighteen,2); $value_nineteen=$value_eighteen+0.125; $value_nineteen_fin=round($value_nineteen*$value_nineteen,2); $value_twenty=$value_nineteen+0.125; $value_twenty_fin=round($value_twenty*$value_twenty,2); $value_twentyone=$value_twenty+0.125; $value_twentyone_fin=round($value_twentyone*$value_twentyone,2); $value_twentytwo=$value_twentyone+0.125; $value_twentytwo_fin=round($value_twentytwo*$value_twentytwo,2); $value_twentythree=$value_twentytwo+0.125; $value_twentythree_fin=round($value_twentythree*$value_twentythree,2); $value_twentyfour=$value_twentythree+0.125; $value_twentyfour_fin=round($value_twentyfour*$value_twentyfour,2); Can all be replaced with: $value = $two_num_below; $names = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', ..); // up to twentyfour //alternatively use pear/Number_Words //$nw = new Number_Words; for ($i = 1; $i <= 24; $i++) { $value += 0.125; //$word = str_replace('-', '', $nw->toWord($i)); ${'value_' . $names[$i - 1]} = $value; ${'value_' . $names[$i - 1] . '_fin'} = round($value * $value, 2); //${'value_' . $word} = $value; //${'value_' . $word . '_fin'} = round($value * $value, 2); } thanks for ur code its working fine how will i put it in the respective table row n column Quote Link to comment Share on other sites More sharing options...
rohitb Posted July 16, 2012 Author Share Posted July 16, 2012 any guru to help me Quote Link to comment Share on other sites More sharing options...
rohitb Posted July 17, 2012 Author Share Posted July 17, 2012 sombody pls help me im so near but so far Quote Link to comment Share on other sites More sharing options...
mikosiko Posted October 17, 2012 Share Posted October 17, 2012 looking this post and the other related one, is easy to see that your code is incomplete and partially wrong... go to this website http://pivottrading.50webs.com/pivot/pivot/gann.html and download the help document right there in the table ("Help Document")... read it fully and you should be able to figure out what part of the logic you are missing just looking (and trying to understand the examples)... last page is a HUGE hint. good luck Quote Link to comment Share on other sites More sharing options...
darshini Posted March 22, 2014 Share Posted March 22, 2014 (edited) sombody pls help me im so near but so far hi,i used ur code n made sme changes.pls try this out. <html> <body> <center> <h2> Gann Levels Calculator! </h2> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <b>Enter Current Market Price</b><input type="text" name="num1" value="<?php if(isset($_POST['num1'])){echo $_POST['num1'];} ?>"> <T><br><br><input type="submit" value="Calculate Gann Levels ->>" style="background-color:#F69; font: lighter" /> </form> <br><br> <?php if(isset($_POST['num1'])) { $num1 = $_POST["num1"]; $square_root=ceil(sqrt($num1)); $one_num_below=$square_root-1; $two_num_below=$square_root-2; $one_num_above=$square_root+1; $two_num_above=$square_root+2; $center_value=$two_num_below*$two_num_below; /* $value = $two_num_below; $names = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty','twentyone','twentytwo','twentythree','twentyfour'); // up to twentyfour //alternatively use pear/Number_Words //$nw = new Number_Words; for ($i = 1; $i <= 24; $i++) { $value += 0.125; //$word = str_replace('-', '', $nw->toWord($i)); ${'value_' . $names[$i - 1]} = $value; ${'value_' . $names[$i - 1] . '_fin'} = round($value * $value, 2); //${'value_' . $word} = $value; //${'value_' . $word . '_fin'} = round($value * $value, 2); } */ $lowvals = $highvals = array(); $names_arr = array(); $value = $two_num_below; $names = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty','twentyone','twentytwo','twentythree','twentyfour'); // up to twentyfour //alternatively use pear/Number_Words //$nw = new Number_Words; for ($i = 1; $i <= 24; $i++) { $value += 0.125; //$word = str_replace('-', '', $nw->toWord($i)); ${'value_' . $names[$i - 1]} = $value; ${'value_' . $names[$i - 1] . '_fin'} = round($value * $value, 2); $names_arr[$i-1] = $list_vals = ${'value_' . $names[$i - 1] . '_fin'}; if($list_vals < $num1) $lowvals[$i-1] = $list_vals; if($list_vals > $num1) $highvals[$i-1] = $list_vals; //${'value_' . $names[$i - 1] . '_fin'} = round(${'value_' . $names[$i - 1] . '_fin'} ); //${'value_' . $word} = $value; //${'value_' . $word . '_fin'} = round($value * $value, 2); } $lcnt = count($lowvals)-1; $hcnt = $lcnt + 1; //to get values of resistance $resis_arr = array(); $resis_arr = array_values($highvals); $resis_arr = array_splice($resis_arr,0,6); //to get values of support $supp_arr = array(); $supp_arr = array_reverse($lowvals); $supp_arr = array_splice($supp_arr,0,6); $b4_ltp = ${'value_' . $names[$lcnt] . '_fin'}; $after_ltp = ${'value_' . $names[$hcnt] . '_fin'}; //echo $value_eleven_fin;exit(0); echo "<div><table cellpadding='8' cellspacing='1' border='1' bgcolor='#FFCC99'><tr><td><font size=1 face=verdana><b>LTP : $num1</b></td></tr></table>"; //gann grid starts here echo "<table cellpadding='10' cellspacing='1' border='1'>"; //depending on your own parameters of course, but the values must be in single quotes echo "<tr><td bgcolor=#FF0099><font size=1 face=verdana>$value_eighteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_nineteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_twenty_fin</td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_ten_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_eleven_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_twelve_fin</td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_two_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_three_fin</td><td bgcolor=#FF0099><font size=1 face=verdana>$value_four_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#CC0066><font size=1 face=verdana>$value_seventeen_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_nine_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_one_fin</td><td bgcolor=#FF3399><font size=1 face=verdana>$center_value</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_five_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_thirteen_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_twentyone_fin</td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_eight_fin</td><td bgcolor=#CC0066><font size=1 face=verdana>$value_seven_fin</td><td bgcolor=#FF0099><font size=1 face=verdana>$value_six_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_sixteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_fifteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_fourteen_fin</td><td bgcolor=#990033><font size=1 face=verdana></td></tr>"; echo "<tr><td bgcolor=#FF0099><font size=1 face=verdana>$value_twentyfour_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#CC0066><font size=1 face=verdana>$value_twentythree_fin</td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#990033><font size=1 face=verdana></td><td bgcolor=#FF0099><font size=1 face=verdana>$value_twentytwo_fin</td></tr>"; echo "</table>"; //this ends your table echo "</div>"; echo "<br><br>"; echo "<table cellpadding='8' cellspacing='1' border='1' bgcolor='#FFCC99'>"; //depending on your own parameters of course, but the values must be in single quotes echo "<tr><td><font size=1 face=verdana>R1</td><td><font size=1 face=verdana>R2</td><td><font size=1 face=verdana>R3</td><td><font size=1 face=verdana>R4</td><td><font size=1 face=verdana>R5</td></tr>"; echo "<tr><td><font size=1 face=verdana>$resis_arr[1]</td><td><font size=1 face=verdana>$resis_arr[2]</td><td><font size=1 face=verdana>$resis_arr[3]</td><td><font size=1 face=verdana>$resis_arr[4]</td><td><font size=1 face=verdana>$resis_arr[5]</td></tr>"; echo "<tr><td><font size=1 face=verdana>S1</td><td><font size=1 face=verdana>S2</td><td><font size=1 face=verdana>S3</td><td><font size=1 face=verdana>S4</td><td><font size=1 face=verdana>S5</td></tr>"; echo "<tr><td><font size=1 face=verdana>$supp_arr[1]</td><td><font size=1 face=verdana>$supp_arr[2]</td><td><font size=1 face=verdana>$supp_arr[3]</td><td><font size=1 face=verdana>$supp_arr[4]</td><td><font size=1 face=verdana>$supp_arr[5]</td></tr>"; echo "</table>"; echo "<br><br>"; function findClosest($sortedArray,$value) { $numberOfElements = count($sortedArray); $middle = floor($numberOfElements/2); if($sortedArray[$middle] == $value || $numberOfElements == 1) return $sortedArray[$middle]; elseif($sortedArray[$middle] < $value) { #upperhalf $half = array_slice($sortedArray,$middle); } else { #lowerhalf $half = array_slice($sortedArray,0,$middle); } $closestHalf = findClosest($half,$value); return (abs($value - $sortedArray[$middle]) < abs($value - $closestHalf)) ? $sortedArray[$middle] : $closestHalf; } $sortedArray = array($value_one_fin,$value_two_fin,$value_three_fin,$value_four_fin,$value_five_fin,$value_six_fin,$value_seven_fin,$value_eight_fin,$value_nine_fin,$value_ten_fin,$value_eleven_fin,$value_twelve_fin,$value_thirteen_fin,$value_fourteen_fin,$value_fifteen_fin,$value_sixteen_fin,$value_seventeen_fin,$value_eighteen_fin,$value_nineteen_fin,$value_twenty_fin,$value_twentyone_fin,$value_twentytwo_fin,$value_twentythree_fin,$value_twentyfour_fin); $result=findClosest($sortedArray,$num1); //print findClosest($sortedArray,$num1); echo "<table cellpadding='7' cellspacing='1' border='1' bgcolor='#FFCC99'>"; echo "<tr><td><font size=1 face=verdana><h3>Recomendations</h3></td></tr>"; echo "<tr><td><font size=1 face=verdana><b>Buy At/Above : $resis_arr[0]</b> for <b>Targets : ".($resis_arr[1]-0.01)." - ".($resis_arr[2]-0.01)." - ".($resis_arr[3]-0.01)." - ".($resis_arr[4]-0.01)." </b></td></tr>"; echo "<tr><td><font size=1 face=verdana><b>Stoploss : </b> $supp_arr[0]</td></tr>"; echo "<tr><td><font size=1 face=verdana><b>Sell At/Below : $supp_arr[0]</b> for <b>Targets : $supp_arr[1] - $supp_arr[2] - $supp_arr[3] - $supp_arr[4]</b></td></tr>"; echo "<tr><td><font size=1 face=verdana><b>Stoploss : </b> $resis_arr[0]</td></tr>"; echo "</table>"; } ?> </center> </body> </html> Edited March 22, 2014 by darshini Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.