PureBytes Links
Trading Reference Links
|
You need to initialise the variables before the loop eg Buy = sell = 0;
Also within the loop the variables you are using and defining all arrays, so should have bar identifier
Buy[i] =
Close[i]
>R[i]
;
Sell
[i] = Close
[i]
<S[i]
; -- Cheers Graham Kav AFL Writing Service http://www.aflwriting.com
On 27/08/07, Don Lindberg <dlindber@xxxxxxxxxxxxx> wrote:
Mohammed,
There has to be a difference in your
code. I have pasted my code below, copy it and try again.
Donald F Lindberg
-------------------------- Begin Code
---------------------------------
_SECTION_BEGIN
("multiplication
factor");
/*Writed & composed by Tudor Marcelin - Art Invest*/
SetChartOptions
(
0,chartShowDates|chartShowArrows
|chartLogarithmic|chartWrapTitle);
k=
1;
/* multiplication factor*/
n=
Optimize(
"n",
8,
3,
15,
1);
/*period*/
f=
ATR(n);
R[
0] = Close[
0];
S[
0] = C[
0];
for
( i = 11
; i < BarCount; i++ )
{
R[i]=R[i-
1];
S[i]=S[i-
1];
if
( C[i-1
] >R[i-1
] )
{
r[i] = C[i-
1]+k*f[i-
1];
s[i]= C[i-
1]-k*f[i-
1];
}
if
( C[i-1
] <S[i-1
] )
{
r[i] = C[i-
1]+k*f[i-
1];
s[i]= C[i-
1]-k*f[i-
1];
}
Buy
= Close>R;
Sell
= Close<S;
Cump=
IIf(Close>R,
1,
0);
Vanz=
IIf(Close<S,
1,
0);
}
Plot
(Close,"Close"
,colorBlack,styleCandle);
Plot
(R, "Resistance:"
,colorGreen,styleDots|styleNoLine);
Plot
(S, "Support:"
,colorRed,styleDots|styleNoLine);
Buy
= ExRem
( Buy, Sell );
//Elimina semnalele buy
consecutive
Sell
= ExRem
( Sell, Buy );
//Elimina semnalele sell
consecutive
shape = Buy * shapeUpArrow
+ Sell * shapeDownArrow;
fig=Cump*shapeHollowUpArrow
+ Vanz*shapeHollowDownArrow;
PlotShapes
( fig, IIf
( Cump, colorPaleGreen , colorPink),
0,
IIf(
Cump, Low-
1, High+
1
)); //Pentru a vizualiza semnalele consecutive eliminate de ExRem
PlotShapes
( shape, IIf
( Buy, colorGreen,
colorRed ), 0
, IIf
( Buy, Low-
1
, High+1
));
//AlertIf( Buy, "", "Experiment", 1 );
//AlertIf( Sell, "", "Experiment",2);
GraphXSpace
= 10
;
Dev = C - S;
Title
=EncodeColor
(colorBlue)+"ATR Trading System with Restance and Support"
+
EncodeColor(colorBlack)+
"
Open
:"+O+"
High:"+H+"
Low:"+L+"
Close:
"+C+
EncodeColor
(colorGreen)+" Resistance:"
+R+
EncodeColor
(colorRed)+" Support:"
+S+
EncodeColor
(colorBlack)+" Dev:"
+Dev+
EncodeColor
(colorBlue)+
" \nDate: "
+EncodeColor
(colorRed)+Date
();
_SECTION_END
();
Filter
= 1
;
AddColumn
(S,"Support"
,1.4
);
AddColumn
(R,"Resistance"
,1.4
);
AddColumn
(Close,"Close"
,1.4
);
AddColumn
(Dev,"Dev"
,1.2
);
------------------------ End Code --------------------------
I do upgrade to Ver: 4.99 and I got the seam error to.
This is the capture for what I got
Capture
--- In amibroker@xxxxxxxxxps.com,
"Mohammed" <softnews2003@xxx> wrote:
>
> Hi Donald F Lindberg;
>
> Thank you for your reply,
>
> I'm using AmiBroker Professional ver 4.96. And I get the Error I
> posted before. I didn't change anything in the code.
>
> I will upgrade new to ver 4.99 and see.
>
> Thanks again.
>
>
> --- In amibroker@xxxxxxxxxps.com,
"Don Lindberg" dlindber@ wrote:
> >
> > Mohammed,
> >
> > Not sure what your problem is, but it is not the code. I copied
> the code,
> > checked syntax, and ran as both Scan and Exploration. It ran fine.
> I am
> > using AmiBroker Professional ver 4.99.
> >
> >
> >
> > Donald F Lindberg
> >
> > _____
> >
> > From: amibroker@xxxxxxxxxps.com
[mailto:amibroker@xxxxxxxxxxxxxxx]
> On Behalf
> > Of Mohammed
> > Sent: Sunday, August 26, 2007 10:34 AM
> > To: amibroker@xxxxxxxxxps.com
> > Subject: [amibroker] Error 29
> >
> >
> >
> > Hi All;
> >
> > I get this code from the net, but when I do scan it give an
> > Error as showing bellow.
> >
> > --------
> > Plot(S, "Sup:",colorRed,styleDots|styleNoLine);
> >
> > Buy = ExRem( Buy,
> > ----------------^
> >
> > Error 29.
> > Variable 'buy' used without having been initialized.
> > ---------
> >
> > Any one can help to solve this error.
> >
> > With the advance regards,
> >
> > /////// CODE ///////
> >
> > _SECTION_BEGIN("multiplication factor");
> >
> > /*Writed & composed by Tudor Marcelin - Art Invest*/
> ! >
> > SetChartOptions
> > (0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
> >
> > k=1; /* multiplication factor*/
> > n=Optimize("n",8,3,15,1); /*period*/
> > f=ATR(n);
> >
> >
> > R[0] = Close[0];
> >
> > S[0] = C[0];
> > for( i = 11; i < BarCount; i++ )
> > {
> >
> > R[i]=R[i-1];
> > S[i]=S[i-1];
> >
> > if ( C[i-1] >R[i-1] )
> > {
> > r[i] = C[i-1]+k*f[i-1];
> > s[i]= C[i-1]-k*f[i-1];
> > }
> > if ( C[i-1] <S[i-1] )
> > {
> > r[i] = C[i-1]+k*f[i-1];
> > s[i]= C[i-1]-k*f[i-1];
> > }
> >
> > Buy = Close>R;
> > Sell = Close<S;
> >
> > Cump=IIf(Close>R,1,0);
> > Vanz=IIf(Close<S,1,0);
> > }
> > Plot(Close,"Close",colorBlack,styleCandle);
> > Plot(R, "Rez:",colorGreen,styleDots|styleNoLine);
> > Plot(S, "Sup:",colorRed,styleDots|styleNoLine);
> >
> > Buy = ExRem( Buy, Sell ); //Elimina semnalele buy consecutive
> > Sell = ExRem( Sell, Buy ); //Elimina semnalele sell consecutive
> >
> > shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
> >
> > fig=Cump*shapeHollowUpArrow + Vanz*shapeHollowDownArrow;
> >
> > PlotShapes( fig, IIf( Cump, colorPaleGreen , colorPink), 0, IIf(
> > Cump, Low-1, High+1)); //Pentru a vizualiza semnalele consecutive
> > eliminate de ExRem
> > PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy,
> Low-
> > 1, High+1));
> >
> > AlertIf( Buy, "", "Experiment", 1 );
> > AlertIf( Sell, "", "Experiment",2);
! > > ;
> > GraphXSpace = 10;
> >
> > Dev = C - S;
> >
> > Title=EncodeColor(colorBlue)+"Experiment"+EncodeColor(colorBlack)
> + "
> > Open:"+O+" High:"+H+" Low:"+L+"
Close:"+C+
> > EncodeColor(colorGreen)+" Rez:"+R+
> > EncodeColor(colorRed)+" Sup:"+S+
> > EncodeColor(colorBlack)+" Dev:"+Dev+
> > EncodeColor(colorBlue)+
> > " \nDate: "+EncodeColor(colorRed)+Date();
> > _SECTION_END();
> >
> > Filter = 1;
> > AddColumn(S,"S",1.4);
> > AddColumn(R,"R",1.4);
> > AddColumn(Close,"Close",1.4);
> > AddColumn(Dev,"Dev",1.2);
> >
> > /// END OF CODE ////
> >
>
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
__,_._,___
|