PureBytes Links
Trading Reference Links
|
hi,
the error you get is because you use whole arrays
in the loop. So your exitcondition is probably defined as an array. For instance
if you define:
exitCondition = StochK(8) > 90;
then exitCondition is an array and in the loop you
have to specify the element using exitCondition[ i ]
For your second question I add an example. You see
that I have a j-loop within the i-loop. To
exit the j-loop is put j = BarCount. Before I do that I change i to the value I
want it to be. So the answer is yes one can change i within the
loop.
rgds, Ed
<FONT
color=#800000>procedure ttt(<FONT
color=#000000>Buy,<FONT
color=#000000>BuyPrice,<FONT
color=#000000>Open,<FONT
color=#000000>High,<FONT
color=#000000>Low,<FONT
color=#000000>Close<FONT face="Courier New"
color=#000000 size=2>,nbar) { <FONT face="Courier New"
color=#008000 size=2>/* Jul 2004 */<FONT
face="Courier New"> <FONT
color=#800000>global <FONT
color=#000000>Sell<FONT
size=2>; <FONT
color=#800000>global <FONT
color=#000000>SellPrice<FONT
face="Courier New">; <FONT
color=#800000>global<FONT
size=2> BuyAdjusted; <FONT
color=#800000>global<FONT
size=2> BuyPriceAdjusted; <FONT
color=#008000>// initialise arrays <FONT
color=#000000><FONT
color=#000000>SellPrice = <FONT
color=#000000>BuyPrice; <FONT
color=#000000>SellPrice = <FONT
color=#ff00ff>0<FONT
color=#000000>; Sell<FONT
color=#000000> = Buy<FONT
color=#000000>; Sell<FONT
color=#000000> = 0<FONT
face="Courier New">; BuyAdjusted =
Buy; BuyAdjusted =
0<FONT
size=2>; BuyPriceAdjusted = <FONT
color=#000000>BuyPrice; BuyPriceAdjusted =
0<FONT
size=2>; <FONT
color=#800000>for (i = <FONT
color=#ff00ff>0; i < <FONT
color=#000000>BarCount<FONT
size=2>; i++) { <FONT
color=#008000>// <FONT
face="Courier New" size=2> <FONT
face="Courier New">if<FONT
color=#000000> (Buy<FONT
color=#000000>[ i ] == 1<FONT
face="Courier New">) {
// buy at
open <FONT face="Courier New"
size=2> BuyAdjusted[ i ] =
1<FONT
face="Courier New">;
BuyPriceAdjusted[ i ] = <FONT
color=#000000>Open<FONT
size=2>[ i ];
// find a
sell position + sellprice <FONT
face="Courier New"
size=2> <FONT
face="Courier New">for<FONT
color=#000000> (j = i; j < <FONT
color=#000000>BarCount<FONT
size=2>; j++) {
<FONT
color=#008000>// nbar stop exit at the open <FONT
color=#000000><FONT face="Courier New"
size=2> <FONT
face="Courier New" color=#800000 size=2>if<FONT
face="Courier New"> ((j - i) == nbar) {
<FONT
color=#000000>Sell[ j ] = <FONT
color=#ff00ff>5<FONT
color=#000000>;
<FONT
color=#000000>SellPrice[ j ] = <FONT
color=#000000>Close<FONT
size=2>[ j ];
<FONT
color=#008000>// enter i-loop starting from the last sell
<FONT face="Courier New"
size=2> i
= j;
<FONT
face="Courier New" color=#008000 size=2>// escape from loop <FONT
color=#000000><FONT face="Courier New"
size=2> j
= <FONT face="Courier New" color=#000000
size=2>BarCount<FONT
color=#000000>;
}
}
}
} } // end procedure
<BLOCKQUOTE
>
OK, this compiler/interpreter behaviour is
confusing me:here is a part of my code that is generating compile
Error 3, "for, while, if statement can only use boolean or numeric
variables" etc.
The strange part is that the for loop is ok but the while
generates this error as shown AND also if I comment the (exitCond ==
False) part and uncomment the (n < BarCount) part. (error goes away if
I change BarCount to 10, e.g., with (exitCond == False) commented
out).2nd Question has to do with being able to change i in the middle
of the for loop, as I do in the last statement. Is this possible or will
i continue from where it left off????for (i = Length+1; i <
BarCount;
i++){
exitCond =
False;
n =
i;
inTrade = False;
while ((exitCond == False))// AND (n <
BarCount))
{
n = n +
1;
}//while
i = n;}// for
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
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 the Yahoo! Terms of Service.
|