Gann Square of nine-VBForums

# Thread: Gann Square of nine

1. ## Gann Square of nine

hello friends im making gann level calculator for my website http://www.technitrade.co.in managed to do some basic coding which prints the 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

PHP 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 can i print values in Buy and Sell recommendations

remember we cant hardcode as user can enter any value

2. ## Re: Gann Square of nine

From these two lines(from your code):
Code:
```//...

\$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);

//...```
you will get all the generated values in \$sortedArray array and the closest amount will be available in the variable \$result

So, you could loop through the array to echo out <49 and >50.77 values.

3. ## Re: Gann Square of nine

Originally Posted by akhileshbc
From these two lines(from your code):
Code:
```//...

\$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);

//...```
you will get all the generated values in \$sortedArray array and the closest amount will be available in the variable \$result

So, you could loop through the array to echo out <49 and >50.77 values.

this is a working example http://niftypivots.stockforyouindia....ng-system.html

4. ## Re: Gann Square of nine

ne one pls help

5. ## Re: Gann Square of nine

Originally Posted by rohitb
ne one pls help
And your question is ?

6. ## Re: Gann Square of nine

Originally Posted by akhileshbc
From these two lines(from your code):
Code:
```//...

\$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);

//...```
you will get all the generated values in \$sortedArray array and the closest amount will be available in the variable \$result

So, you could loop through the array to echo out <49 and >50.77 values.

how to do this as im bit new in php

7. ## Re: Gann Square of nine

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•