NexusFi: Find Your Edge


Home Menu

 





Gann square of nine


Discussion in MultiCharts

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




 
Search this Thread

Gann square of nine

  #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?
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

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 Twitter 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,434 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

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/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 Twitter Reply With Quote




Last Updated on December 6, 2018


© 2024 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 - Privacy Policy - Downloads - Top
no new posts