Buy = Stochastic (15,3) > Ref(Stochastic(15,3),-1) AND Ref(Stochastic(15,3),-1) < Ref(Stochastic(15,3),-2)
AND ROC (EMA(C,50),5)>0.2|
** with this buy setup gets active…now buy should be triggered as soon as price goes above the bar that activated buy setup on same or subsequent bars .
** stop loss would be below buy setup activation BAR|
You did not specify how long the Buy Setup remains active. This statement is also ambiguous:
buy should be triggered as soon as price goes above the bar that activated buy setup on same or subsequent bars
If you mean that the High should be greater than the High of the Buy Setup bar, then it is impossible for that to happen on the same bar as the Setup as you have stated.
Stating your problem clearly will help others to help you. Also, have you made any attempt to solve this yourself? You might find the ValueWhen() and BarsSince() functions helpful.
Thanks sir for reply...
Buy setup activation = when above mentioned two conditions met .
Buy setup trigger = when close is greater than buy setup activation bar.
Bar to hold setup activated = 5 bar
Hmmm, code is perfect, and yet you didn't mark it as the solution or even "like" it? Perhaps you should go back and read TJ's posts on how to use this site.
As for your exit conditions, you can use the same AmiBroker functions and very similar logic to what's already been provided. Try to implement a solution using these tools, and if it doesn't work on the first try, then do some debugging with an Exploration or the built-in AmiBroker debugger. If you still can't get it, come back and show us your work, and someone will no doubt be happy to point you in the right direction.