Jay OK just substitute your formula for Val...
Val = (EMA(C,30))/30; // or whatever you like. If you are trying to set a threshold based on Threshold = Close today - Val; and then looking back in time to when a Low of any preceding bar crossed that threshold, you will need Cross function, but ALSO if I understand you correctly you will likely also need to look into Looping. Looping still leaves me stumped but have a look at the files section for the articles Looping in Amibroker AFL.pdf and AFL Looping.pdf. Then just use Valuewhen to find the XM. Regards ChrisB jay_podda wrote: > > Chris, > > Thanks for replying so fast. > > In my case, Val is not constant, its array just like C. Also, L might > not be ref-1, it can be more than 1 bars ago. And I want to know value > of XM corrosponding to bar on which L is less than current bar's C- > Val. > > Thanks again, > --- In [EMAIL PROTECTED] ps.com > <mailto:amibroker%40yahoogroups.com>, ChrisB <[EMAIL PROTECTED] ..> wrote: > > > > Hi Jay > > > > See if this is what you are looking for: > > > > Val = Param("Val", 1.5 , 1, 3, 0.1); > > > > XM = High;//for argument's sake. > > > > CminusVal = Close - Val; > > Cond1 = Ref(L,-1) < (C-Val); > > myXM= ValueWhen ( Ref(L,-1) < (C -Val),XM); > > > > // run the Exploration to check you values > > Filter = 1; > > > > AddColumn(Val, "Val", 1.2); > > AddColumn( XM,"XM", 1.2); > > AddColumn (C, "close",1.2) ; > > AddColumn(Ref( L,-1),"ref L",1.2); > > AddColumn( CminusVal,"ClessVal ",1.2); > > AddColumn( Cond1, "Cond1", 1.2); > > AddColumn ( myXM, "my XM", 1.2); > > > > // Plot these to visually check > > Plot( myXm,"myXM", colorBlue,1) ; > > Plot( Cond1, "Cond1",colorRed, styleHistogram |styleOwnScale) ; > > > > Regards > > > > ChrisB > > > > jay_podda wrote: > > > > > > I want to find value of array XM when L of very first previous bar > is > > > VAL amount less then current bar C. > > > > > > The problem with me is when I use valuewhen, in expression if I > use > > > any array for comparision, I can't compare with current bar. That > is, > > > if current bar C is 49.50 and VAL is 1.50, I want to get value of > XM > > > array when that previous bar's L is less than 48. > > > >
