Help to identify peak and trough in a indicator

#1
hi all,
I'm a beginner amibroker user, I have difficulty to plot a value 1 when I found a peak in a zig plot in a correct way. Please pay attention (not peak related to High price bar but peak related to my zig formula): in metastock it's very easy in amibroker it seems to be triky.:annoyed:

in metastock the formula my zigplot indicator=Peak(1, my zigplot indicator ,1)
means to plot the value 1 each time that indicator has a peak. Very easy thing

In amibroker is it not the same thing. Where I'm wrong?:(
I also tried to use the function iif(----,1,0); but without success. An help it's appreciated.
thank you in adv. for your kindy support
 

KelvinHand

Well-Known Member
#2
hi all,
I'm a beginner amibroker user, I have difficulty to plot a value 1 when I found a peak in a zig plot in a correct way. Please pay attention (not peak related to High price bar but peak related to my zig formula): in metastock it's very easy in amibroker it seems to be triky.:annoyed:

in metastock the formula my zigplot indicator=Peak(1, my zigplot indicator ,1)
means to plot the value 1 each time that indicator has a peak. Very easy thing

In amibroker is it not the same thing. Where I'm wrong?:(
I also tried to use the function iif(----,1,0); but without success. An help it's appreciated.
thank you in adv. for your kindy support
It is not tricky, it is your problem. Blame yourself not taking a serious look at the help guide on Peak() function, otherwise, you can spot the different from the metastock.
 
Last edited:
#3
I have already consulted the manual and did not want to criticize the platform. (which I think is really good) I'm just starting to use it and I asked him just a little help, I do not seem to have been rude. That's all

I have no problem to simply plot a peak with price chart but with a zig chart

regards
 

KelvinHand

Well-Known Member
#4
I have already consulted the manual and did not want to criticize the platform. (which I think is really good) I'm just starting to use it and I asked him just a little help, I do not seem to have been rude. That's all

I have no problem to simply plot a peak with price chart but with a zig chart

regards
Then show the ms & afl code, let see why ?
 
#5
Then show the ms & afl code, let see why ?

Hi KelvinHand Thanks for your patience. Here you are a simple formula in metastock first and then my "conversion" in amibroker:

1st indicator
zig("my formula",10,PERCENT) // plot a zig zag of a generic indicator (please note //omitted)

2nd one
zigformula2:= Fml( "first indicator") ;
zigformula2=Peak(1,zigformula2,1) // plot 1 when a peak is found into the zigformula2, plot O is the condition is not accomplished. The same for trough conditions (omitted)

Amibroker:

1st indicator
"my formula"; \\omitted - doens't matter
plot(Zig( "my formula", 1 ),"zip 1st indicator",colorred,styleline);

2nd indicator

"my formula"; \\omitted - doens't matter
plot(Peak(Zig( "my formula", 1 ), 1,1),"peak 2nd indicator",coloryellow,styleline);

\\this indicator didn't what I want so I tried to add this strings to see the value 1 where a peak is available in my zig indicator see below:

percdiff = 1; /* this defines percentage threshold for detecting peaks */
//
PKd = Peak( H, percdiff, 1 ) == High;
//
// Now PK array will hold "1" for all bars when peaks occur and "0" elsewhere
// because high price is equal to the peak value only on the day when this
// peak occurs.

Plot(pkd, "my zig peak",colorYellow,styleLine);

\\this is better then before but it is related to price of the chart and not to my zigformula: if I use
pkd = Peak(Zig( "my formula", 1 ),percdiff, 1 ) == High; \\doesn't work again (no values).

I simply need a peak (or trough) of my zig indicator. I hope it's clear now.
I found this link that probably is what I meant but It's not clear to me how to use the string inside or the afl suggested. Please take a look:

ZIG peak and trough detection
http://www.mail-archive.com/[email protected]/msg45506.html :confused:
 
Last edited:

KelvinHand

Well-Known Member
#6
Hi KelvinHand Thanks for your patience. Here you are a simple formula in metastock first and then my "conversion" in amibroker:
1st indicator
zig("my formula",10,PERCENT) // plot a zig zag of a generic indicator (please note //omitted)

Are you sure this is correct in MS ?
According to SYNTAX Zig(Data Array, Change, % $)
Data Array should be OHLC, OR

zig(Fml("my formula"),10,PERCENT)

either it is a mistake OR your formula that you don't want to show.

If it is a function that return a data array, then anything related to Fml("...")
should be translated as

function my_formula()
{
data_array = close;
return data_array;
}

in amibroker

2nd one
zigformula2:= Fml( "first indicator") ;
zigformula2=Peak(1,zigformula2,1) // plot 1 when a peak is found into the zigformula2, plot O is the condition is not accomplished. The same for trough conditions (omitted)

Amibroker:

1st indicator
"my formula"; \\omitted - doens't matter
plot(Zig( "my formula", 1 ),"zip 1st indicator",colorred,styleline);
Here the amibroker "chance" parameter is in PERCENT by default.
In your MS above stated 10%, I don't understand why you change to 1% here
plot(Zig( my_formula(), 1 ),"zip 1st indicator",colorred,styleline);

\\this indicator didn't what I want so I tried to add this strings to see the value 1 where a peak is available in my zig indicator see below:
percdiff = 1; /* this defines percentage threshold for detecting peaks */
//
PKd = Peak( H, percdiff, 1 ) == High;
//
// Now PK array will hold "1" for all bars when peaks occur and "0" elsewhere
// because high price is equal to the peak value only on the day when this
// peak occurs.

Plot(pkd, "my zig peak",colorYellow,styleLine);
it did shown 1 and 0 once your solved the Fml("") issue

\\this is better then before but it is related to price of the chart and not to my zigformula: if I use
pkd = Peak(Zig( "my formula", 1 ),percdiff, 1 ) == High; \\doesn't work again (no values).

I simply need a peak (or trough) of my zig indicator. I hope it's clear now.
I found this link that probably is what I meant but It's not clear to me how to use the string inside or the afl suggested. Please take a look:

ZIG peak and trough detection
http://www.mail-archive.com/[email protected]/msg45506.html :confused:
No matter how you hide "my formula", still it had to be price related.
So still your problem and you confused yourself and channel to wrong direction.
 
Last edited:
#7


This is what I meant and I want to simply create also with amibroker.
1st line: my indicator
2nd line: zig of that indicator zig(Fml("my formula"),10,PERCENT)
3 line: peak of the zig of that indicator Peak(1,fml("zig my formula",1)

For Kelvinhand: Of course correct syntax is zig(Fml("my formula"),10,PERCENT)

and related to amibroker I have no issue to create the zig indicator like as in the metastock picture (line 2) my problem is to plot the peak indicator up the candlestik chart (third line). If I use Peak( H, percdiff, 1 ) == High; Amibroker plot 1 but related to High peak of the candlestik and not the peak of the zig in the middle: this is the part that I miss and I need help. Please!

I hope it's clear now.:)
 

KelvinHand

Well-Known Member
#8


This is what I meant and I want to simply create also with amibroker.
1st line: my indicator
2nd line: zig of that indicator zig(Fml("my formula"),10,PERCENT)
3 line: peak of the zig of that indicator Peak(1,fml("zig my formula",1)

For Kelvinhand: Of course correct syntax is zig(Fml("my formula"),10,PERCENT)

and related to amibroker I have no issue to create the zig indicator like as in the metastock picture (line 2) my problem is to plot the peak indicator up the candlestik chart (third line). If I use Peak( H, percdiff, 1 ) == High; Amibroker plot 1 but related to High peak of the candlestik and not the peak of the zig in the middle: this is the part that I miss and I need help. Please!

I hope it's clear now.:)
I assume your 1st, 2nd n 3rd lines are metastock chart.
I already told you any thing related to Fml("") must converted to function Fml()...etc
So there is no issue.

1st line:
function my_formula()
{
....
return my_data_array;
}


2nd line: zig of that indicator zig(Fml("my formula"),10,PERCENT)
function zig_my_formula(data_array, chance)
{
my_data_array = Zig(data_array, chance);
return my_data_array;
}



3 line: peak of the zig of that indicator Peak(1,fml("zig my formula",1)

should be
Peak(zig_my_formula( my_formula(), 10) ; //should be the peak of your zig.
 
Last edited:
#9
unfortunaltey the last peak formula returns error 31 syntax error, unespected ';', expecting ')' or ',' :(

then in the previous conversion you wrote:

function zig_my_formula(data_array, chance)
{
my_data_array = Zig(data_array, chance);
return my_data_array;
}

I think that you meant "change" instead of "chance" :confused:

could you please create a complete example to avoid misunderstanding? If you want I can send my formula privatelly to you so we can solve definitely the problem together.
thanks for your time
 

KelvinHand

Well-Known Member
#10
unfortunaltey the last peak formula returns error 31 syntax error, unespected ';', expecting ')' or ',' :(

then in the previous conversion you wrote:

function zig_my_formula(data_array, chance)
{
my_data_array = Zig(data_array, chance);
return my_data_array;
}

I think that you meant "change" instead of "chance" :confused:

could you please create a complete example to avoid misunderstanding? If you want I can send my formula privatelly to you so we can solve definitely the problem together.
thanks for your time


I merely show you the concept, not the exact function here, i did not verify in the amibroker, if i verified, i likely will enclosed in the
Code:
.
Whether syntax 'chance' or 'change' is not the issue. they are just function parameter. 

the last peak formula returns error 31 syntax error, unespected ';', expecting ')' or ',' :( is very easy, it told you what the cause.
you need to patiently figure out and correct it. 

You are suppose to solve your problem, not me. I merely provide some help to you.
If you face problem and just give up and throw the problem to me. then i quit.

Come this stage, 99% of the problem had surfaced up because you think amibroker should follow what metastock is doing.
What you need is just a little push to yourself to complete the job.
 
Last edited:

Similar threads