Need value of previous high candle and current higher high candle

i am beginner in amibroker and done my work best of my knowledge.
I want to generate higher high code on current candle and catch the high value of both
candle(previous higher candle and current high)...
my code work some time but I do get many false signal

this is my code....

nhigh = Param( "Left Strength",10, 1, 50, 1 );

pk=HHV(High,nhigh)==High;

for( i = 0; i < 3; i++ )
{
    VarSet( "peak" + i, ValueWhen( pk, High, i ) );
 }
 
 Sell=peak1>peak2 AND High>=HHV(High,nhigh)

Need help to solve this.....

Thank you so much in advance for your help!

Moderator comment: Code tags should be applied to CODE only not to entire text. Corrected now. Next time use the EDIT button to correct mistakes on your own time and try not to waste other people time.

@manesh. You still have 13 min left.... to correct your post , there is one icon under your post and looks like a pencil

Hi @manesh,

Glad to see you found the code blocks for pasting your code. In future, try to just include code in there. Makes it much easier for us to grab and test.

So, let's talk ... I did a quick exploration to see what your code does and it looks good to me. So, what do you mean when you say "my code work some time but I do get many false signal"?

Are you saying the "SELL" signal is false? Or not when you want it?

As a newbie, you may not have read all of the great links like this one: How do I debug my formula?

So, to keep you going, take a look at the code below, and try it out in an Exploration (Analysis window). I set mine to run on the Current Symbol and on From To dates of 2018-01-03 to 2018-02-13.

Hope this helps.

// MANESH from AB

nhigh = Param( "Left Strength",10, 1, 50, 1 );

pk=HHV(High,nhigh)==High;

for( i = 0; i < 3; i++ )
{
    VarSet( "peak" + i, ValueWhen( pk, High, i ) );
 }
 
 checkSell=peak1>peak2 AND High>=HHV(High,nhigh);
yh = Ref(H,-1);

AddColumn(H, "High");
AddColumn(yH, "Yesterday");
AddColumn(pk, "Peak");
AddColumn(checksell, "Sell");
Filter = 1;
p1 = ValueWhen(pk, High, 1);
p2 = ValueWhen(pk, High, 2);
p3 = ValueWhen(pk, High, 3);
AddColumn(p1, "Peak 1");
AddColumn(p2, "Peak 2");
AddColumn(p3, "Peak 3");

Hi @snoopy.pa30

Thank U for the effort made by you..........

the above code is working in Exploration. gives unwanted signal
can you please help me to have the signal only pk=1 and checksell=1 and not zero..

And one more Question Can this code with HHV will help me out in live signal or it will create any problem.

Thank a lot for your help...

@manesh, Please don't use the Code Block ("</>") for your comments.

OK, so what SIGNAL are you referring to?

Show the exploration and point out what SIGNAL is "UNWANTED" and where it occurs.

As with all help you get here, you need to show your work. What can you do with the code I shared (based on your original code) that helps you get to what you want. Can you "code" the Signal that you are referring to? If you can, then you can change your code the way you want.

I don't know what "SIGNAL" you are referring to, or how you are generating or using it.

As to your additional question, again I don't understand your question. I work on End of Day data, and trading, so not sure what you mean by "live signal". Are you thinking hourly bars, 15 minute bars, 1 minute bars, or tick charts?

Again, it all depends on what you code, and how you code it. That is the benefit of using AmiBroker. YOU get to code what you want. That is also the drawback. It requires you to make the code. For non programmers, that can be a challenge, but if you are trying and showing what you are doing and what is not working, we can help you learn what you need to keep going.

So, try coding your "SIGNAL" and see where it works and where it doesn't. Then try to figure out what you can change in your code to get the signal results you want.