Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Square of Nine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Square of Nine

    Has anyone programmed this indicator for NinjaTrader charts?

    #2
    Do you have any explanation, code?, something? regarding the indicator.

    Comment


      #3
      Square of Nine

      I have it programmed in TradeStation. Wouyld that help?

      Comment


        #4
        Yes, may be here in the community someone could help translate to Ninja.

        Comment


          #5
          Here is the 1st 1/2 of code; it is not elegant but it works in TradeStation

          Square of Nine Lines

          [LegacyColorValue = true];

          Inputs: YestDate(1030321);

          Arrays: Zero[50](0), FortyFive[50](0), Ninety[50](0),
          OneThirtyFive[50](0), OneEighty[50](0),
          TwoTwentyFive[50](0), TwoSeventy[49](0),
          ThreeFifteen[49](0);
          variables: counter(0), ID(-1);


          Zero[0] = 2;
          Zero[1] = 11;
          Zero[2] = 28;
          Zero[3] = 53;
          Zero[4] = 86;
          Zero[5] =127;
          Zero[6] =176;
          Zero[7] =233;
          Zero[8] =298;
          Zero[9] =371;
          Zero[10] = 452;
          Zero[11] =541;
          Zero[12] =638;
          Zero[13] =743;
          Zero[14] =856;
          Zero[15] =977;
          Zero[16] = 1106;
          Zero[17] =1243;
          Zero[18] = 1388;
          Zero[19] =1541;
          Zero[20] = 1702;
          Zero[21] =1871;
          Zero[22] = 2048;
          Zero[23] =2233;
          Zero[24] = 2426;
          Zero[25] =2627;
          Zero[26] = 2836;
          Zero[27] =3053;
          Zero[28] = 3278;
          Zero[29] =3511;
          Zero[30] = 3752;
          Zero[31] =4001;
          Zero[32] = 4258;
          Zero[33] =4523;
          Zero[34] = 4796;
          Zero[35] =5077;
          Zero[36] = 5366;
          Zero[37] =5663;
          Zero[38] = 5968;
          Zero[39] =6281;
          Zero[40] = 6602;
          Zero[41] =6931;
          Zero[42] = 7268;
          Zero[43] =7613;
          Zero[44] = 7966;
          Zero[45] =8327;
          Zero[46] = 8696;
          Zero[47] =9073;
          Zero[48] = 9458;
          Zero[49] =9851;

          FortyFive[0] =3;
          FortyFive[1] =13;
          FortyFive[2] =31;
          FortyFive[3] =57;
          FortyFive[4] = 91;
          FortyFive[5] =133;
          FortyFive[6] = 183;
          FortyFive[7] =241;
          FortyFive[8] = 307;
          FortyFive[9] =381;
          FortyFive[10] = 463;
          FortyFive[11] = 553;
          FortyFive[12] = 651;
          FortyFive[13] = 757;
          FortyFive[14] = 871;
          FortyFive[15] = 993;
          FortyFive[16] = 1123;
          FortyFive[17] = 1261;
          FortyFive[18] = 1407;
          FortyFive[19] = 1561;
          FortyFive[20] = 1723;
          FortyFive[21] = 1893;
          FortyFive[22] = 2071;
          FortyFive[23] = 2257;
          FortyFive[24] = 2451;
          FortyFive[25] = 2653;
          FortyFive[26] = 2863;
          FortyFive[27] = 3081;
          FortyFive[28] = 3307;
          FortyFive[29] = 3541;
          FortyFive[30] = 3783;
          FortyFive[31] = 4033;
          FortyFive[32] = 4291;
          FortyFive[33] = 4557;
          FortyFive[34] = 4831;
          FortyFive[35] = 5113;
          FortyFive[36] = 5403;
          FortyFive[37] = 5701;
          FortyFive[38] = 6007;
          FortyFive[39] = 6321;
          FortyFive[40] = 6643;
          FortyFive[41] = 6973;
          FortyFive[42] = 7311;
          FortyFive[43] = 7657;
          FortyFive[44] = 8011;
          FortyFive[45] = 8373;
          FortyFive[46] = 8743;
          FortyFive[47] = 8121;
          FortyFive[48] = 8507;
          FortyFive[49] = 9901;


          Ninety[0] = 4;
          Ninety[1] = 15;
          Ninety[2] = 34;
          Ninety[3] = 61;
          Ninety[4] = 96;
          Ninety[5] = 139;
          Ninety[6] = 190;
          Ninety[7] = 249;
          Ninety[8] = 316;
          Ninety[9] = 391;
          Ninety[10] = 474;
          Ninety[11] =565;
          Ninety[12] = 664;
          Ninety[13] =771;
          Ninety[14] = 886;
          Ninety[15] =1009;
          Ninety[16] = 1140;
          Ninety[17] =1279;
          Ninety[18] = 1426;
          Ninety[19] =1581;
          Ninety[20] = 1744;
          Ninety[21] =1915;
          Ninety[22] = 2094;
          Ninety[23] =2281;
          Ninety[24] = 2476;
          Ninety[25] =2679;
          Ninety[26] = 2890;
          Ninety[27] =3109;
          Ninety[28] = 3336;
          Ninety[29] =3571;
          Ninety[30] = 3814;
          Ninety[31] =4065;
          Ninety[32] = 4324;
          Ninety[33] =4591;
          Ninety[34] = 4866;
          Ninety[35] =5149;
          Ninety[36] = 5440;
          Ninety[37] =5739;
          Ninety[38] = 6046;
          Ninety[39] =6361;
          Ninety[40] = 6684;
          Ninety[41] =7015;
          Ninety[42] =7354;
          Ninety[43] =7701;
          Ninety[44] = 8056;
          Ninety[45] =8419;
          Ninety[46] = 8790;
          Ninety[47] =9169;
          Ninety[48] = 9556;
          Ninety[49] =9951;


          OneThirtyFive[0] =5;
          OneThirtyFive[1] =17;
          OneThirtyFive[2] =37;
          OneThirtyFive[3] =65;
          OneThirtyFive[4] = 101;
          OneThirtyFive[5] =145;
          OneThirtyFive[6] = 197;
          OneThirtyFive[7] =257;
          OneThirtyFive[8] = 325;
          OneThirtyFive[9] =401;
          OneThirtyFive[10] = 485;
          OneThirtyFive[11] = 577;
          OneThirtyFive[12] = 677;
          OneThirtyFive[13] = 785;
          OneThirtyFive[14] = 901;
          OneThirtyFive[15] = 1025;
          OneThirtyFive[16] = 1157;
          OneThirtyFive[17] = 1297;
          OneThirtyFive[18] = 1445;
          OneThirtyFive[19] = 1601;
          OneThirtyFive[20] = 1765;
          OneThirtyFive[21] = 1973;
          OneThirtyFive[22] = 2117;
          OneThirtyFive[23] = 2305;
          OneThirtyFive[24] = 2501;
          OneThirtyFive[25] = 2705;
          OneThirtyFive[26] = 2917;
          OneThirtyFive[27] = 3137;
          OneThirtyFive[28] = 3365;
          OneThirtyFive[29] = 3601;
          OneThirtyFive[30] = 3845;
          OneThirtyFive[31] = 4097;
          OneThirtyFive[32] = 4357;
          OneThirtyFive[33] = 4625;
          OneThirtyFive[34] = 4901;
          OneThirtyFive[35] = 5185;
          OneThirtyFive[36] = 5477;
          OneThirtyFive[37] = 5777;
          OneThirtyFive[38] = 6085;
          OneThirtyFive[39] = 6401;
          OneThirtyFive[40] = 6725;
          OneThirtyFive[41] = 7057;
          OneThirtyFive[42] = 7397;
          OneThirtyFive[43] = 7745;
          OneThirtyFive[44] = 8101;
          OneThirtyFive[45] = 8465;
          OneThirtyFive[46] = 8837;
          OneThirtyFive[47] = 9217;
          OneThirtyFive[48] = 9605;
          OneThirtyFive[49] = 10001;


          OneEighty[0] =6;
          OneEighty[1] =19;
          OneEighty[2] =40;
          OneEighty[3] =69;
          OneEighty[4] = 106;
          OneEighty[5] =151;
          OneEighty[6] = 204;
          OneEighty[7] =265;
          OneEighty[8] = 334;
          OneEighty[9] =411;
          OneEighty[10] =496;
          OneEighty[11] = 589;
          OneEighty[12] = 690;
          OneEighty[13] = 799;
          OneEighty[14] = 916;
          OneEighty[15] = 1041;
          OneEighty[16] = 1174;
          OneEighty[17] = 1315;
          OneEighty[18] = 1464;
          OneEighty[19] = 1621;
          OneEighty[20] = 1786;
          OneEighty[21] = 1959;
          OneEighty[22] = 2140;
          OneEighty[23] = 2329;
          OneEighty[24] = 2526;
          OneEighty[25] = 2731;
          OneEighty[26] = 2944;
          OneEighty[27] = 3165;
          OneEighty[28] = 3394;
          OneEighty[29] = 3631;
          OneEighty[30] = 3876;
          OneEighty[31] = 4129;
          OneEighty[32] = 4390;
          OneEighty[33] = 4659;
          OneEighty[34] = 4936;
          OneEighty[35] = 5221;
          OneEighty[36] = 5514;
          OneEighty[37] = 5815;
          OneEighty[38] = 6124;
          OneEighty[39] = 6441;
          OneEighty[40] = 6766;
          OneEighty[41] = 7099;
          OneEighty[42] = 7440;
          OneEighty[43] = 7789;
          OneEighty[44] = 8146;
          OneEighty[45] = 8511;
          OneEighty[46] = 8884;
          OneEighty[47] = 9265;
          OneEighty[48] = 9654;
          OneEighty[49] = 10051;

          Comment


            #6
            and the pother 1/2

            TwoTwentyFive[0] =7;
            TwoTwentyFive[1] =21;
            TwoTwentyFive[2] = 43;
            TwoTwentyFive[3] =73;
            TwoTwentyFive[4] = 111;
            TwoTwentyFive[5] =157;
            TwoTwentyFive[6] = 211;
            TwoTwentyFive[7] =273;
            TwoTwentyFive[8] = 343;
            TwoTwentyFive[9] =421;
            TwoTwentyFive[10] = 507;
            TwoTwentyFive[11] = 601;
            TwoTwentyFive[12] = 703;
            TwoTwentyFive[13] = 813;
            TwoTwentyFive[14] = 931;
            TwoTwentyFive[15] = 1057;
            TwoTwentyFive[16] = 1191;
            TwoTwentyFive[17] = 1333;
            TwoTwentyFive[18] = 1483;
            TwoTwentyFive[19] = 1641;
            TwoTwentyFive[20] = 1807;
            TwoTwentyFive[21] = 1981;
            TwoTwentyFive[22] = 2163;
            TwoTwentyFive[23] = 2353;
            TwoTwentyFive[24] = 2551;
            TwoTwentyFive[25] = 2757;
            TwoTwentyFive[26] = 2971;
            TwoTwentyFive[27] = 3193;
            TwoTwentyFive[28] = 3423;
            TwoTwentyFive[29] = 3661;
            TwoTwentyFive[30] = 3907;
            TwoTwentyFive[31] = 4161;
            TwoTwentyFive[32] = 4423;
            TwoTwentyFive[33] = 4693;
            TwoTwentyFive[34] = 4971;
            TwoTwentyFive[35] = 5257;
            TwoTwentyFive[36] = 5551;
            TwoTwentyFive[37] = 5853;
            TwoTwentyFive[38] = 6163;
            TwoTwentyFive[39] = 6481;
            TwoTwentyFive[40] = 6807;
            TwoTwentyFive[41] = 7141;
            TwoTwentyFive[42] = 7483;
            TwoTwentyFive[43] = 7833;
            TwoTwentyFive[44] = 8191;
            TwoTwentyFive[45] = 8557;
            TwoTwentyFive[46] = 8931;
            TwoTwentyFive[47] = 9313;
            TwoTwentyFive[48] = 9703;
            TwoTwentyFive[49] = 10101;


            TwoSeventy[0] = 8;
            TwoSeventy[1] = 23;
            TwoSeventy[2] = 46;
            TwoSeventy[3] = 77;
            TwoSeventy[4] = 116;
            TwoSeventy[5] = 163;
            TwoSeventy[6] = 218;
            TwoSeventy[7] = 281;
            TwoSeventy[8] = 352;
            TwoSeventy[9] = 431;
            TwoSeventy[10] = 518;
            TwoSeventy[11] =613;
            TwoSeventy[12] = 716;
            TwoSeventy[13] =827;
            TwoSeventy[14] = 946;
            TwoSeventy[15] =1073;
            TwoSeventy[16] = 1208;
            TwoSeventy[17] =1351;
            TwoSeventy[18] = 1502;
            TwoSeventy[19] =1661;
            TwoSeventy[20] = 1828;
            TwoSeventy[21] =2003;
            TwoSeventy[22] = 2186;
            TwoSeventy[23] =2377;
            TwoSeventy[24] = 2576;
            TwoSeventy[25] =2783;
            TwoSeventy[26] = 2998;
            TwoSeventy[27] =3221;
            TwoSeventy[28] = 3452;
            TwoSeventy[29] =3691;
            TwoSeventy[30] = 3938;
            TwoSeventy[31] =4193;
            TwoSeventy[32] = 4456;
            TwoSeventy[33] =4727;
            TwoSeventy[34] = 5006;
            TwoSeventy[35] =5293;
            TwoSeventy[36] = 5588;
            TwoSeventy[37] =5891;
            TwoSeventy[38] = 6202;
            TwoSeventy[39] =6521;
            TwoSeventy[40] = 6848;
            TwoSeventy[41] =7183;
            TwoSeventy[42] = 7526;
            TwoSeventy[43] =7877;
            TwoSeventy[44] = 8236;
            TwoSeventy[45] =8603;
            TwoSeventy[46] = 8978;
            TwoSeventy[47] =9361;
            TwoSeventy[48] = 9752;



            ThreeFifteen[0] =9;
            ThreeFifteen[1] =25;
            ThreeFifteen[2] = 49;
            ThreeFifteen[3] =81;
            ThreeFifteen[4] = 121;
            ThreeFifteen[5] =169;
            ThreeFifteen[6] = 225;
            ThreeFifteen[7] =289;
            ThreeFifteen[8] = 361;
            ThreeFifteen[9] =441;
            ThreeFifteen[10] = 529;
            ThreeFifteen[11] =625;
            ThreeFifteen[12] = 729;
            ThreeFifteen[13] =841;
            ThreeFifteen[14] = 961;
            ThreeFifteen[15] =1089;
            ThreeFifteen[16] = 1225;
            ThreeFifteen[17] =1369;
            ThreeFifteen[18] = 1521;
            ThreeFifteen[19] =1681;
            ThreeFifteen[20] = 1849;
            ThreeFifteen[21] =2025;
            ThreeFifteen[22] = 2209;
            ThreeFifteen[23] =2401;
            ThreeFifteen[24] = 2601;
            ThreeFifteen[25] =2809;
            ThreeFifteen[26] =3025;
            ThreeFifteen[27] =3249;
            ThreeFifteen[28] = 3481;
            ThreeFifteen[29] =3721;
            ThreeFifteen[30] = 3969;
            ThreeFifteen[31] =4225;
            ThreeFifteen[32] = 4489;
            ThreeFifteen[33] =4761;
            ThreeFifteen[34] = 5041;
            ThreeFifteen[35] =5329;
            ThreeFifteen[36] = 5625;
            ThreeFifteen[37] =5929;
            ThreeFifteen[38] = 6241;
            ThreeFifteen[39] =6561;
            ThreeFifteen[40] = 6889;
            ThreeFifteen[41] =7225;
            ThreeFifteen[42] = 7569;
            ThreeFifteen[43] =7921;
            ThreeFifteen[44] = 8281;
            ThreeFifteen[45] =8649;
            ThreeFifteen[46] = 9025;
            ThreeFifteen[47] =9409;
            ThreeFifteen[48] = 9801;

            counter = 0;

            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 49 begin
            value1 = TL_New(YestDate, 1100, Zero[Counter], YestDate, 1200,Zero[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, Zero[counter]+1, NumToStr(Zero[Counter], 0) + " - 0 Degrees");
            end;
            end;

            counter = 0;
            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 49 begin
            value1 = TL_New(YestDate, 1100, FortyFive[Counter], YestDate, 1200,FortyFive[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, FortyFive[counter]+1, NumToStr(FortyFive[Counter], 0) + " - 45 Degrees");
            end;
            end;

            counter = 0;
            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 49 begin
            value1 = TL_New(YestDate, 1100, Ninety[Counter], YestDate, 1200,Ninety[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, Ninety[counter]+1, NumToStr(Ninety[Counter], 0) + " - 90 Degrees");
            end;
            end;

            counter = 0;
            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 49 begin
            value1 = TL_New(YestDate, 1100, OneThirtyFive[Counter], YestDate, 1200,OneThirtyFive[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, OneThirtyFive[counter]+1, NumToStr(OneThirtyFive[Counter], 0) + " - 135 Degrees");
            end;
            end;

            counter = 0;
            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 49 begin
            value1 = TL_New(YestDate, 1100, OneEighty[Counter], YestDate, 1200,OneEighty[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, OneEighty[counter]+1, NumToStr(OneEighty[Counter], 0) + " - 180 Degrees");
            end;
            end;

            counter = 0;
            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 49 begin
            value1 = TL_New(YestDate, 1100, TwoTwentyFive[Counter], YestDate, 1200,TwoTwentyFive[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, TwoTwentyFive[counter]+1, NumToStr(TwoTwentyFive[Counter], 0) + " - 225 Degrees");
            end;
            end;

            counter = 0;
            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 48 begin
            value1 = TL_New(YestDate, 1100, TwoSeventy[Counter], YestDate, 1200,TwoSeventy[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, TwoSeventy[counter]+1, NumToStr(TwoSeventy[Counter], 0) + " - 270 Degrees");
            end;
            end;

            counter = 0;
            If Date = YestDate and Time = 1200 then
            begin
            For Counter = Counter to 48 begin
            value1 = TL_New(YestDate, 1100, ThreeFifteen[Counter], YestDate, 1200,ThreeFifteen[counter]);
            TL_SetExtRight(Value1, True);
            TL_SetExtLeft(Value1, True);
            ID = Text_New(Date, Time, ThreeFifteen[counter]+1, NumToStr(ThreeFifteen[Counter], 0) + " - 315 Degrees");
            end;
            end;

            Comment


              #7
              Can you post a screen shot?, I'm not very good programming but I try and maybe another from the community can continue if I get stuck.

              Regards,

              I'll post my findings.

              Comment


                #8
                I have done some work on Gann Square of Nine.

                The attached indicator was written for my own trading, there are several places where it can be improved, but for my use it is fine. If it suits your needs, then I'm glad to have helped. If it just does not work for you then you have some base code to work with

                Square Nine is a mathematical progression of numbers produced by incrementing each value by a step size (usually 1) in a spiral fashion, with a "seed" number in the center of the spiral.

                From what I gather in reading articles on the net, this technique was intended by Gann to be based off of a recent Swing Hi/Lo, where the price at that Swing would be the "seed" value for the center of the Spiral.

                Well, I did not program it that way. My exposure to Square of 9, came from Gio at tradingelements.com. Her use of Square of 9, always used a seed value of 1.

                When used in this way an issues rises.
                1) for Instruments that trade with small whole number values, like the Euro, and other currencies, and a lot of stocks, the SQ9 values, calculated as above, are too far apart to be of practical use in trading.

                to compensate for this, a power of 10 factor must be used to shift the values outward in the spiral, to arrive at SQ9 values that are more meaningful for trading. I call these synthetic Square of 9. I can find no reference in Gann material supporting this, it is just the way I learned it.

                When transitioning to the next level of the spiral , one gets a large jump in value, from (level n, angle 270), to (level n+1, angle 0). To avoid this jump the increase between levels is evenly distributed on angles between 270 and 0/360, thereby creating a smoother transition.

                This indicator calculates the Major Squares at (0,90,180,270 degrees) and plots them with a Blue dashed line, it also calculates the minor Squares at angles divisible by 22.5 degrees, plotting them as magenta lines

                The indicator finds a SQ9 value which is close to the Symbol value being charted. It then plots 15 SQ9 lines below, and 15 lines above that value. It uses lines because they are not included in the chart scaling calculations, so that lines not close to price do not skew the displayed chart. It repeats this at the beginning or each new trading day, which works well for what I trade. (Stock Index)

                Using this on daily charts, will produce odd looking charts.

                As price advances about half way to the next SQ9 value, the chart's "white space" is adjusted to bring the next SQ9 line onto the chart, this allows using Chart Trader to place/move target orders around the SQ if so desired.
                Attached Files
                Last edited by tquinn; 09-03-2007, 10:37 AM.

                Comment


                  #9
                  Sq9 Screen Shot

                  See attached. Screen shot is for Daily ER(AB) mini

                  Comment


                    #10
                    I honestly don't know anything about the SQofNine Lines so I monitored it for a couple days on how prices react to it. Very interesting and impressive. It seems to fit well with my method. I just need to learn more about it though. I have attached some trades on ER2 last Friday and I hope some of you guys who are knowledgeable about SQ9 can comment on it and maybe expound more on how you use it. Thanks.
                    Attached Files

                    Comment


                      #11
                      squre of 9

                      by this,we can create very strong support and resistance levels on the chart.i saw this a guy using this but not want to explain.any how,we need to develop this for ninja.any body can help and come forward,,,plz,help us to develop and understande this.
                      thanks...

                      Comment


                        #12
                        squre of 9

                        hi,
                        after a long research,i find this software.calculating sq of 9 manually.all u need to insert data and u will get calculations.it will calculate fibbonacci #s as well.i m trying to attach this with ninja::thats may work automatic,,
                        let see what result come out..

                        Comment


                          #13
                          square of nine

                          any body ever get this programmed thanks

                          Comment


                            #14
                            tquinn

                            did you program the square of nine indicator that works on ninja

                            Comment


                              #15
                              This is the thread about the Square of Nine indicator being developed by the community. It would appear to have some issues so maybe you could ask tquinn for an update.

                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X