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

[amibroker] Re: plz correct this stoploss formula


  • Date: Tue, 08 Dec 2009 06:49:27 -0000
  • From: "hjansenvanrensburg" <hjansenvanrensburg@xxxxxxxxx>
  • Subject: [amibroker] Re: plz correct this stoploss formula

PureBytes Links

Trading Reference Links

The Iif function does not work in the way that you have used it. Iif only returns a value for each item in the array. You should probably use If ... else flow control statement, which means that you will have to use your own for loop to iterate through the items in your array.

It will probably be something like this:

for (i = 0; i < BarCount; i++) {
  if (hhhh > 1.04 * hy) {
    ApplyStop( 0, 1, 0, 1, volatile = False, ReEntryDelay = 0 );
  } else {
    ApplyStop( 0, 1, 2, 1, volatile = False, ReEntryDelay = 0 )
  }
}

I'm not expert though, so it would be good of someone more knowledgeable than be can confirm.



--- In amibroker@xxxxxxxxxxxxxxx, rink <boyrinku@xxx> wrote:
>
> Hi
> i tried to create a stoploss formula but there is something wrong please 
> correct it
> 
> buy=cross macd, sell =cross signal
> initail stoploss is 2% but when prices up 4% stoploss move to breakeven 
> buyprice
> 
> 
> *Buy* = Cross( MACD(), Signal() );
> *Sell* = Cross( Signal(), MACD() );
> 
> rink=(ApplyStop( 0, 1, 0, 1, volatile = False, ReEntryDelay = 0 ));
> 
> rin=(ApplyStop( 0, 1, 2, 1, volatile = False, ReEntryDelay = 0 ));
> 
> Hy=ValueWhen(Buy,C,1);
> hhhh=HighestSince( Buy,H,1);
> IIf((Hhhh> (1.04*Hy)),rink,rin);
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/