PureBytes Links
Trading Reference Links
|
I don't think you need the for loop or iif(...).
you can use logic statements something like this:
buy = sell = short = cover = False;
// LONGS
buy = di AND uptrend AND !dwtrend;
Sell= u1 and uptrend AND !dwtrend;
// SHORTS
Short = u1 AND dwtrend AND !uptrend;
Cover = d1 AND dwtrend AND !uptrend;
// BOTH
Buy = Cover = di AND uptrend AND dwtrend;
Sell= Short = u1 AND uptrend AND dwtrend;
Barry
--- In amibroker@xxxxxxxxxxxxxxx, "DrazenStricek12" <dstricek12@xxx>
wrote:
>
> Hello,
>
> Im building system:
> 1. that goes long only ie. buys down bar in uptrend
> 2. that goes short only ie. shorts up bar in downtrend
> 3. goes long and short when both trends are present
>
> The problem is that it signals error because IF loop has to be
numeric and not aray.
> Could anyone point me to where I can find solution for this
problem ?
>
>
>
> It goes like this
>
> // CODE BEGINN ********** 3 in 1 EOD system
>
> p=20;
>
> uptrend=RSI(p) >55;
> dwtrend=RSI(p) < 45;
> DIR=IIf( uptrend,5 ,IIf( dwtrend,4 ,7)); // direction up down both
>
> u1=C >O;// trigger
> d1=C < O;
>
>
> if( dir==5)
> {
> // LONGS
> Buy=d1* dir==5;
> Sell=u1*dir==5;
> Short=0;
> Cover=0;
> }
>
> if( dir==4)
> {
> // SHORTS
> Buy=0;
> Sell=0;
> Short=u1*dir==4;
> Cover=d1*dir==4;
> }
> if( dir==7)
> {
> // BOTH
> Buy=d1* dir==7;
> Sell=u1*dir==7;
> Short=u1*dir==7;
> Cover=d1*dir==7;
> } else;
>
> //
> // *****************END CODE
>
>
> I tried this combination but it is not working:
>
>
> p=20;
>
> uptrend=RSI(p) >55;
> dwtrend=RSI(p) < 45;
> DIR=IIf( uptrend,5 ,IIf( dwtrend,4 ,7)); // direction up down both
>
> u1=C >O;// trigger
> d1=C < O;
>
> for(i=1;i<BarCount;i++)
> {
> if (dir[i]==5)
> Buy=d1* dir==5;
> Sell=u1*dir==5;
> Short=0;
> Cover=0;
>
>
>
> if (dir[i]==4)
> Buy=0;
> Sell=0;
> Short=u1*dir==4;
> Cover=d1*dir==4;
>
> if (dir[i]==7)
> // BOTH
> Buy=d1* dir==7;
> Sell=u1*dir==7;
> Short=u1*dir==7;
> Cover=d1*dir==7;
> }
>
------------------------------------
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
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|