Need Help for simple code!

Hi there,

I use Buy = L < Ref (LLV (L, PeriodDays), -1); and when price still going down for example like - 5%, I want to buy more, but when i use SigScaleIn or BarSince for second buy, it come a lot of buy signal when i plot it with arrow.

Buy1  = L < Ref (LLV (L, PeriodDays), -1);
Buy2  = (Buy1 / 1.05);
Buy1  = exrem (buy1, buy2);
Sell    = H > Ref (LLV (L, PeriodDays), -1);

Sell = ExRem (Sell, Buy );

Check out this page for scaling in

Thanks codejunkie

But its different from my case, its buy everytime up. I use sigscalein already

I know. :roll_eyes:

In your first post you do not use it.

I mention it use SigScaleIn and BarSince buat not write inside the code cz i still confuse

But it is hard for anyone to help you with your code unless you post it. If you're already using SigScaleIn() then let us see it.


@ibenxs Perhaps I am confused but your code does not make any sense to me.

Buy1  = L < Ref (LLV (L, PeriodDays), -1);
Buy2  = (Buy1 / 1.05);
Buy1  = exrem (buy1, buy2);

Buy1 will return a one when the condition is true and then a zero if the condition is untrue.
Buy2 will equal 0.95 every time Buy1 is true.

What are you accomplishing with exrem (buy1, buy2) ??? You do know what exrem does don’t you?

“removes excessive signals:
returns 1 on the first occurrence of "true" signal in Array1 then returns 0 until Array2 is true even if there are "true" signals in Array1”

But the way you are using it, Buy2 is always true (has a non-zero value) on the same bar that Buy1 is true.

Also the title of your post is AWFUL. This forum is searchable so later when someone is looking for help with a problem of Scale Trading with AmiBroker it would be nice if your thread had a title like “need help with Scaling In” not some useless title like “need help”. Don’t take this personally as there are numerous posters who use that very useless title to start their forum discussion thread.

And lastly there are many resources for learning about scale trading on this forum, in the official Knowledge Base and in the user library. Post your full code attempts and maybe you can find some help here on the forum.


Thanks for the fast respon and sory for the title of discussion.

How to make it true ? I just want to SigScaleIn when price is going down -5% from buy1.

Thanks for the respon.

Can you make for me ?!

Buy1 = L < Ref (LLV (L, PeriodDays), -1);
Buy2 = buy more when price is going down -5% from buy1.
Sell = H > Ref (LLV (L, PeriodDays), -1);

@ibenxs - You need to make more of an effort! This forum is not a free coding service.

Did you read this?

So this is my effort bro, I undestand....just want to know some opinion, i am new with AB and try mybest.

My name is not "bro"!

No you don't!

Once again, did you read this!

apologize Mr. TrendSurfer

here mycode

Buy1    = L < Ref (LLV (L, PeriodDays), -1);
Buy1Val = ValueWhen(Buy1, L) ;
Buy2    = L < buy1val/1.05 ;
Exit    = H > Ref (LLV (L, PeriodDays), -1);

Buy2    = ExRem(buy2, Exitl); // Remove subsequent buy2 signals until Exit

Buy = IIf(Buy1 , 1, IIf(Buy2, sigScaleIn, 0<br>));

Sell = ExitSignal;
Buy  = entry1 OR entry2;
Sell = exrem (Sell,Buy );

Buy1 = ExRem(buy1,sell);
Buy2 = ExRem(buy2,sell);

This is the current status of your code!

I'm happy to help you but really...


1 Like

PeriodDays its like PeriodDays = Param( "Periods", 3, 1, 5, 1 );

you can add with your own days for experiment, I give just "focus on the problem"

maybe somebody can help.!

Before you obtain Buy1Val you need to ExeRem Buy1, otherwise Buy1Val will change for each new low

Buy1    = L < Ref (LLV (L, PeriodDays), -1);
Sell = ExitSignal;
Buy1    = exrem(Buy1, Sell);
Buy1Val = ValueWhen(Buy1, L) ;

This is what I call Solution ! Thanks alot :smile: