PureBytes Links
Trading Reference Links
|
I donšt follow exactly what you are trying to do, but I see some syntax
problems that may help you out. Please look in your code below for my
**notes**
However, I don't see your subscript out of range. It appears (without
running the code) to be inbounds.
--
Terry
From: socina@xxxxxxxxxxx
Reply-To: amibroker@xxxxxxxxxxxxxxx
Date: Sun, 17 Oct 2004 17:35:55 +0200
To: <amibroker@xxxxxxxxxxxxxxx>
Subject: [amibroker] Problem with an second values array.
Hallo,
maybe can you help me to solve the following problem:
For the i day:
- I calculate the High and Low for the last 5 days
- I calculate the difference between this values
As example:
iMax=150
iMin=100
Difference=iMax-iMin=50
What I need is an array[1..50].
All values are initial zero.
For the last 5 days I need to increase for every day the array value with 1,
if the price are between the High and Low of this day.
As example for Day 1:
High=120, Low=110
For i = 110 to 120 I must increase in the array the value at position i-100
with 1:
array[110-iMin] = array[110-iMin]+1;
...
array[120-iMin]=array[120-iMin]+1;
The same addition is to calculate for the values between Open and Close.
My AFL code as Formula is:
==========================
/*******************************************************************
gs Market Pivots
10.17.2004
*******************************************************************/
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows);
Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,
Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle |
ParamStyle("Style", styleCandle, maskPrice ) );
GraphXSpace=1;
_SECTION_END();
/*******************************************************************
Market Pivots
*******************************************************************/
_SECTION_BEGIN("MarketPivots");
nD=5; // Period
iMult=100; // Multiplier
// 1. Max, Min and Difference for the last nD days
............................
for (i=nD-1; i<BarCount; i++)
{
/* Maximum prices for the "i" day */
iMax[i]=H[i];
//
//**notes** you are setting iMax[I] = H[I]. You can do the same before the
loop and it runs faster: iMax = H; (no big deal)
for (j=1; j<nD; j++)
{
if ( H[i-j] > iMax[i] )
iMax[i] = H[i-j];
else
MaxOK = True;
//**notes** attempt at using numeric variable inside loop has always failed
for me...try MaxOK[I]
//**notes** also I don't see where you ever use MaxOK in which case no ELSE
portion is required.
}
/* Minimum prices for the "i" day */
iMin[i]=L[i];
for (j=1; j<nD; j++)
{
if ( L[i-j] < iMin[i] )
iMin[i] = L[i-j];
else
MinOK = True;
//**notes** attempt at using numeric variable inside loop has always
// failed for me...try MinOK[I]
//**notes** also I don't see where you ever use MinOK in which case no
// ELSE portion is required.
}
/* Difference maximum/minimum price for the "i" Day */
iDifference[i] = (iMult*(iMax[i] - iMin[i]) + 1);
//**notes* following code uses iDiff and not iDifference
//**notes** possible problem with iMult without [I]
// I know this should work, but it never works for me
}
Plot( iMax, "iMax", colorRed, styleNoTitle | styleLine) ;
Plot( iMin, "iMin", colorBlue, styleNoTitle | styleLine);
/* Number of appareances */
function ProfileAppareances(iDiff)
{
for (i=nD-1; i<BarCount; i++)
{
nDiff=iDiff[i];
//**notes** Diff not defined. You used Difference above
for (j=1; j<=nDiff; j++)
{
iApp[j]=0;
}
// ...
}
return iApp;
//
//**notes** iApp is an array, return outside of loop. Actually this is not
defined as a function so you cannot return a result. The result will just
"be there" after the loop is finished. I don't see where iApp is used
anywhere.
}
// Test plot:
Plot( ProfileAppareances(iDifference), "iDiff", colorYellow, styleNoTitle |
styleLine) ;
_SECTION_END();
=========================
- Because I become the message:
"Error 7.
Subscript out of range",
I can't continue with the code writing.
Regards
George
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
<http://us.ard.yahoo.com/SIG=12936tbj6/M=315388.5497957.6576270.3001176/D=g
roups/S=1705632198:HM/EXP=1098113764/A=2372354/R=0/SIG=12id813k2/*https://ww
w.orchardbank.com/hcs/hcsapplication?pf=PLApply&media=EMYHNL40F21004SS>
Yahoo! Groups Links
* To visit your group on the web, go to:
* http://groups.yahoo.com/group/amibroker/
*
* To unsubscribe from this group, send an email to:
* amibroker-unsubscribe@xxxxxxxxxxxxxxx
<mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
*
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|