NexusFi: Find Your Edge


Home Menu

 





Gann square of nine


Discussion in MultiCharts

Updated
    1. trending_up 2,868 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
wongj
Hong Kong
 
Posts: 2 since Oct 2018
Thanks Given: 0
Thanks Received: 0

Dears,

I am new to Multichart, i would like to use Gann square of nine as one of the strategy in multichart. I noted some codes in the net, but all are for other trading platforms/languages; therefore, i took reference and re-writed it in easy languages; however, i received "Array Bounds, Wrong index value: 1." when i put it into the chart. It compiled successfully in Powerlanguage Editor.

Anyone please can have a look and help if my code has something wrong?

 
Code
Var: 
Basenum(0),
sBelow (0),
sBelowi (0),
Sstop (0),
bstop (0),
babove (0),
bAboveI (0),
BuySignal (0),
ShortSignal (0),
BTgt1 (0),
BTgt2 (0),
BTgt3 (0),
BTgt4 (0),
BTgt5 (0),
BTgt6 (0),
STgt1 (0),
STgt2 (0),
STgt3 (0),
STgt4 (0),
STgt5 (0),
STgt6 (0),
RefOpen (0),
ShortProfitStop (0),
BuyProfitStop (0),
II(1),
ShowText (true);

// New day settings
if Date<>Date[1] then begin
//DateInFromTo= (Date>=iFromYYYMMDD and Date<=iToYYYMMDD);
if time=0930 then RefOpen = Open;

end;

BaseNum = (IntPortion(squareroot(RefOpen))-1);
sBelow = BaseNum + BaseNum;
sBelowI = 1;

//Calculate levels for GANN Square of Nine
array: GANN[](0);{ Declare Variables }

for II = 1 to 49

Begin

GANN [II] =(BaseNum * BaseNum);
BaseNum = BaseNum + 0.125;
if GANN[II] < RefOpen then sBelowI = II else sBelowI =1;
bAboveI = sBelowI + 1;
sBelow = IntPortion(GANN[sBelowI]);
babove = IntPortion(GANN[bAboveI]);
end;

// Resistance Levels (or Targets for Buy trade)
BTgt1 = 0.9995 * (Gann[bAboveI+1]);
BTgt2 = 0.9995 * (Gann[bAboveI+2]);
BTgt3 = 0.9995 * (Gann[bAboveI+3]);
BTgt4 = 0.9995 * (Gann[baboveI+4]);
BTgt5 = 0.9995 * (Gann[bAboveI+5]);
BTgt6 = 0.9995 * (Gann[baboveI+6]);
// Support Levels (or Targets for Short trade)
STgt1 = 1.0005 * (Gann[sBelowI-1]);
STgt2 = 1.0005 * (Gann[sBelowI-2]);
STgt3 = 1.0005 * (Gann[sBelowI-3]);
STgt4 = 1.0005 * (Gann[sbelowI-4]);
STgt5 = 1.0005 * (Gann[sBelowI-5]);
STgt6 = 1.0005 * (Gann[sBelowI-6]);

Sstop= babove-((babove-sbelow)/3) ;
bstop= sbelow+((babove-sbelow)/3) ;

If time>=0930 AND Close cross above babove then
Buy("Buysignal") Next bar at BuySignal Limit;
if bstop>Close then Sell ("Sell") Next bar at open;

If time>=0930 AND Sbelow Cross below Close then
SellShort ("Shortsell") Next bar at ShortSignal limit;

If bstop>close then buytocover ("Buytocover") Next bar at open;
If time > 0930 and Close cross above babove then BuySignal = Close;
if time > 0930 and sbelow cross below close then ShortSignal = close;

If (Low <=STgt1 and Close >STgt1) then ShortprofitStop = Stgt1 else
If (Low <=Stgt2 AND Close >Stgt2) then ShortprofitStop = Stgt2 else
If (Low <=Stgt3 AND Close >Stgt3) then ShortprofitStop = Stgt3 else
If (Low <=Stgt4 AND Close >Stgt4) then ShortprofitStop = STgt4 else
If (Low <=Stgt5 AND Close >Stgt5) then ShortprofitStop = STgt5 else
If (Low <=Stgt6 AND Close >Stgt6) then ShortprofitStop = STgt6;

If (High>=btgt1 AND Close<Btgt1) then BuyProfitStop = btgt1 else
If (High>=BTgt2 AND Close<Btgt2) then BuyProfitStop = btgt2 else
If (High>=BTgt3 AND Close<Btgt3) then BuyProfitStop = btgt3 else
If (High>=BTgt4 AND Close<Btgt4) then BuyProfitStop = btgt4 else
If (High>=BTgt5 AND Close<BTgt5) then BuyProfitStop = btgt5 else
If (High>=BTgt6 AND Close<Btgt6) then BuyProfitStop = btgt6;

Sstop= IntPortion(babove) ;
bstop= IntPortion(sbelow) ;

Thanks!
J


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Peace Expired NO: Ceasefire on Life Support, OPEC a …
Prediction Markets & Event Contracts
MegaETH Proves the Crowd Right: Prediction Markets Calle …
Prediction Markets & Event Contracts
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
TradingView Deploys AI to Monitor SEC Filings in Real Ti …
TradingView
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
23 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
Trying to learn Volume and price action correlation
5 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

wongj,

your code uses a dynamic array but doesn't appear to set a size for the array. Consequently you receive the error message that states that you are trying to write something out of the bounds of your array.
From the code it doesn't appear that you need a dynamic array, but could use a static array with a max index equal to the highest index that you write to (49 in your code).

Regards,

ABCTG


Follow me on X Reply With Quote
  #3 (permalink)
wongj
Hong Kong
 
Posts: 2 since Oct 2018
Thanks Given: 0
Thanks Received: 0


Thanks ABCTG,

When i change to

array: GANN[](0);{ Declare Variables }

The error message become : "Array Bounds, Wrong index value: -1."

Not sure if other parts go wrong......


Reply With Quote
  #4 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,447 since Apr 2013
Thanks Given: 493
Thanks Received: 1,639

wongj,

from what did you change it to?

The EasyLanguage Essentials PDF is a great resource in familiarizing yourself with the basics of EasyLanguage.
It also covers arrays and you can obtain a free copy from Tradestation here: https://uploads.tradestation.com:443/uploads/EasyLanguage-Essentials.pdf

Regards,

ABCTG


wongj View Post
Thanks ABCTG,

When i change to

array: GANN[](0);{ Declare Variables }

The error message become : "Array Bounds, Wrong index value: -1."

Not sure if other parts go wrong......


Follow me on X Reply With Quote




Last Updated on December 6, 2018


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts