PDA

View Full Version : Square of Nine


Maven
08-16-2007, 04:43 PM
Has anyone programmed this indicator for NinjaTrader charts?

PrTester
08-17-2007, 08:29 PM
Do you have any explanation, code?, something? regarding the indicator.

Maven
08-20-2007, 07:16 AM
I have it programmed in TradeStation. Wouyld that help?

PrTester
08-20-2007, 06:49 PM
Yes, may be here in the community someone could help translate to Ninja.

Maven
08-21-2007, 08:13 AM
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;

Maven
08-21-2007, 08:14 AM
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;

PrTester
08-21-2007, 02:03 PM
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.

tquinn
08-21-2007, 07:25 PM
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.

Maven
08-22-2007, 06:49 AM
See attached. Screen shot is for Daily ER(AB) mini

crisscruiser
08-27-2007, 12:57 AM
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.

alfa123
09-02-2007, 02:53 PM
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...

alfa123
09-03-2007, 12:58 PM
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..
:) :) :)

drakebauer
10-27-2007, 02:26 PM
any body ever get this programmed thanks

drakebauer
10-27-2007, 02:40 PM
did you program the square of nine indicator that works on ninja

NinjaTrader_Josh
10-27-2007, 02:48 PM
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.

http://www.ninjatrader-support.com/vb/showthread.php?t=3068

jazzy
03-23-2009, 01:44 AM
HI there

Im new to the forum, can anyone tell me if there is a Gann Swing Chart available for ninja.
thanks heaps

jazzy

NinjaTrader_Bertrand
03-23-2009, 02:20 AM
Hi jazzy welcome to the NinjaTrader support forums! I'm not aware of indicators for Gann's swing charts, however you could try this one - http://www.ninjatrader-support2.com/vb/local_links.php?action=jump&id=38&catid=1

mccullek
01-27-2010, 02:00 PM
There is a Square of 9 indicator posted in the indicator section and it works and I really like it with one exception. Soon after adding it, I found that my charts were hanging and slowing dramatically after running for an hour or so. It took me a while to determine it was the Sq of 9 indicator, but as soon as I deleted it, my charts were working beautifully again.

I'd really like to add it back if someone knows how to correct the CPU overload issue that this indicator caused on my computer. Anyone else experience this problem or have any idea how to correct it?

alfa123
01-27-2010, 02:15 PM
if u have a computer with less rams,,it may be the cause of your problem.i do not have any kind of issue like this. 1G (minimum)required for running charts smoothly.if u are using zen fire data,then may be 3+ needed.And u need a real high speed internet 7 or 8 G cable or DSL as well.
good luck.

mccullek
01-27-2010, 02:54 PM
After more research, I found there are two of these indicators posted. They appear to be the same with the exception of one was created in NT version 6.0 and the other in 6.5. I added the 6.5 version and put it back on my charts and now NO problems. Evidently the older version is not compatible with vers 6.5. I was glad to find this out, as I really like this indicator! Kudos to the creator and thanks for making it available to us.

Also, I have a current dual core CPU with 8 megs of Ram, so if you have the wrong version, it will slow the charts on even a fast computer with lots of memory.

mccullek
01-30-2010, 11:38 AM
Even the 6.5 version starts to slow performance dramatically over time. It takes much longer than the 6.0 version, but it still affects performance for some reason. Once the charts start dragging and getting sticky, you can remove the indicator, and performance immediately returns to normal. Maybe it's just my machine, but it definitely creates performance issues for me.

NinjaTrader_Ben
01-30-2010, 12:37 PM
Hello,

Have you reviewed these tips:
http://www.ninjatrader-support.com/HelpGuideV6/PerformanceTips1.html