PureBytes Links
Trading Reference Links
|
Might be b/c BarIndex actually returns an array. Try to mess around
with "bi".
--- In amibroker@xxxxxxxxxxxxxxx, "Barry Scarborough"
<razzbarry@xxxx> wrote:
>
> I keep having trouble when using barindex. The following porogram
> gives me an error stating that I have to use a number with an if
> statement. I sure think I am using a number but the compiler does
> not think so. What an I doing wrong?
>
> The lines it does not like are:
> if (myBuy[bi] == 1)
> if (myBuy[BarIndex()] == 1)
> and
> LastCross = tMacd[bi];
> tMacd and myBuy are arrays and bi is the barindex.
> What is wrong with this?
>
> thanks,
> Barry
>
> // constants
> mfast = Optimize( "MACD Fast", 12, 8, 16, 1 );
> mslow = Optimize("MACD Slow", 26, 17, 30, 1 );
> sigavg = Optimize( "Signal line", 9, 2, 20, 1 );
> bi = BarIndex();
>
> // vars
> LastCross = 0.0;
>
> // risk management
> range = IIf(H < Ref(L,-1), Ref(C,-1) - L, IIf(L > Ref(H, -1), H -
Ref
> (C,-1), H-L));
> range15 = MA(range,15);
>
> // ema filter
> emaFilter = EMA(C, mslow );
> tMacd = MACD( mfast, mslow );
> tSignal = Signal( mfast, mslow, sigavg );
>
> myBuy = IIf(Cross(tMacd , tSignal), 1, 0 );
> mySell = IIf(Cross(tSignal ,tMacd), 1, 0 );
> // if this is the first signal after macd went below zero ignore it
> if (myBuy[bi] == 1) // the compile does not like this line
> {
> if (LastCross >= 0)
> LastCross = tMacd[bi]; // and it does not like this line
> }
>
> Cover = Buy = ExRem(myBuy ,mySell );
> Short = Sell = ExRem(mySell ,mybuy );
> Plot (emaFilter, "EMA Filter", colorBlue);
> Plot (Buy * emaFilter , "Buy", colorGreen);
> Plot (Sell * emaFilter , "Sell", colorRed);
------------------------ Yahoo! Groups Sponsor --------------------~-->
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/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/
|