[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Creating a toggle switch



PureBytes Links

Trading Reference Links

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

<*> 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/