PureBytes Links
Trading Reference Links
|
Thanks to you and Graham it now works like I wanted.
Your suggestion also pointed out some other errors in my coding as
well
Much appreciated
Rick
--- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxxx> wrote:
> You can't use IIF inside a loop. I'm surprised you aren't getting
> compiler errors. Try this instead:
>
> O_Bought = StochD(45,1) < 30 AND Ref(StochD(7,1),-1) < 10 AND
> StochD(7,1)> Ref(StochD(7,1),-1);
> O_Sold = StochD(45,1) > 70 AND Ref(StochD(7,1),-1) > 90 AND
> StochD(7,1) < Ref(StochD(7,1),-1);
>
> ExhInd = False; //When using loops, initialize the array.
>
> for( i = 1; i < BarCount; i++ )
> {
> if (O_Bought[i]) ExhInd[i] = 1;
> else if (O_Sold[i]) ExhInd[i] = -1;
> else ExhInd[i] = ExhInd[i-1];
> }
> --
> Terry
>
> | -----Original Message-----
> | From: amibroker@xxxxxxxxxxxxxxx
[mailto:amibroker@xxxxxxxxxxxxxxx] On
> | Behalf Of ricko8294_98
> | Sent: Sunday, June 26, 2005 22:45
> | To: amibroker@xxxxxxxxxxxxxxx
> | Subject: [amibroker] Creating a toggle switch
> |
> | Hello
> |
> | I have been unable to code a variable that will toggle between two
> | values (+1 and -1) and to hang onto the assigned values until the
> | other value is encountered.
> |
> | For example, I am trying to code a variable that will keep track
of
> | exhaustion points - first overbought, then oversold.
> |
> | I have the following code:
> |
> | O_Bought = StochD(45,1) < 30 AND Ref(StochD(7,1),-1) < 10 AND
> | StochD(7,1)> Ref(StochD(7,1),-1);
> | O_Sold = StochD(45,1) > 70 AND Ref(StochD(7,1),-1) > 90 AND
> | StochD(7,1) < Ref(StochD(7,1),-1);
> |
> | for( i = 1; i < BarCount; i++ )
> | {
> | ExhInd[i] = IIf(O_Bought[i],1,
> | IIf(O_Sold[i],-1,ExhInd[i-1]));
> | }
> |
> | I find that sometimes this code seems to work - but not always -
very
> | frustrating.
> |
> | If anyone can help solve this for me I would be mose appreciative
> |
> | Thanks
> | Rick
> |
> |
> |
> |
> | 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 other support material please check also:
> | http://www.amibroker.com/support.html
> |
> |
> | Yahoo! Groups Links
> |
> |
> |
> |
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 other support material please check also:
http://www.amibroker.com/support.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/
|