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

[amibroker] Re: Sell breaking previous peak



PureBytes Links

Trading Reference Links

Hi,

I can see a couple of problems.

1. You are plotting a ZigZag with a 4% change (second argument to 
Zig), but setting your conditions based on a a ZigZag with a 1% 
change (second argument to Peak/Trough).

2. You are passing in the result of the Zig indicator into 
Peak/Trough which is not correct. Peak/Trough automatically use Zig 
upon the array that you pass in. Therefore, you are doing a Zig of 
Zig!

You probably want to change your Peak and Trough function calls to 
pass the same array as you passed to Zig directly (i.e. Close), and 
you probably want to pass the same value that you used when calling 
Zig directly (i.e. 4).

By default the 3rd argument is already set to 1 which is what you 
wanted (i.e. 1 peak/trough ago). But, for the purposes of 
illustration, I'm adding it in.

e.g.

z=Zig(C,4);  // Peaks and troughs after 4% movement.
...
Condi1=C<Peak(C,4,1);    // 1 Peak ago based on 4% movement.
Condi2=C<Trough(C,4,1);  // 1 Trough ago based on 4% movement.
...

Note: I can't actually see your attachments. So, I'm guessing at the 
above based on reading your code.

Note: Use caution when working with the Zig indicator. It looks into 
the future! So, you cannot use it in a real system unless you delay 
your Buy/Sell until AFTER the signals could have been detected 
without seeing the future.

See the following for an example of trading VALID signals:

http://www.amibroker.com/library/detail.php?id=353&hilite=ZIG 

Mike

--- In amibroker@xxxxxxxxxxxxxxx, Waleed Khalil <waleedkhalil@xxx> 
wrote:
>
> Dear All
> I need to do a simple code for research purpose,which buy when close
> penetrate the previous peak , and sell if close break the previous
> bottom or break the previous peak .
> i wrote this code but i don't know what is wrong with it.
> 
> *z=Zig(C,4);
> Plot(C,"C",1,**64);
> Plot(z,"",colorRed,**styleThick)**;
> Condi1=C<Peak(**z,1);
> Condi2=C<Trough(**z,1);
> Buy=C>Peak(z,**1);
> Sell=Condi1 or Condi2 ;
> Buy = ExRem( Buy, Sell );
> Sell = ExRem( Sell, Buy );
> PlotShapes( IIf( Buy , shapeUpArrow , shapeNone ),colorGreen );
> PlotShapes( IIf( Sell, shapeUpArrow + shapePositionAbove, shapeNone
> ),colorRed );*
> 
> thanks in advance
> Waleed
>



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

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/