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

Re: [amibroker] Re: Sell breaking previous peak



PureBytes Links

Trading Reference Links

Thanks Mike for your help , i fixed it but still having problems , i guess there is a bug or something in the peak command, please check it your self, Condi2 is working perfectly with Trough , it should work the same with Peak but it does not.

z=Zig(C,3);
Plot(C,"C",1,64);
Plot(z,"",colorRed,styleThick);
Condi1=C<Peak(C,3,2);
Condi2=C<Trough(C,3,1);
Buy=C>Peak(C,3,1);
Sell=Condi2 OR Condi1;
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
PlotShapes( IIf( Buy , shapeUpArrow , shapeNone ),colorGreen );
PlotShapes( IIf( Sell, shapeUpArrow + shapePositionAbove, shapeNone),colorRed );

thanks again

Mike wrote:

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@xxxxxxxxxps.com, Waleed Khalil <waleedkhalil@...>
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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___