[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: coding help request- higer values...



PureBytes Links

Trading Reference Links

Shahariar,

You will need to clarify what you mean by "when the value of this cond1 is greater than the last time when this cond1 occured".

cond1 is a binary result and will thus only ever have 2 values: 0 or 1. There will never be a case where a later cond1 was greater than a prior cond1 since for all instances that cond1 is true, they will all be 1.

If you mean that you want the difference between the two averages to be greater, then use that in the ValueWhen expression.

difference = ema(close,3) - ema(close,15)
cond1= differnece > 0;
Buy = cond1 AND difference > ValueWhen(cond1, difference, 2);

Similarly, if you mean either of ema(close,3) or ema(close,15), then use that in the ValueWhen expression.

ema3 = ema(close, 3);
ema15 = ema(close, 15);
difference = ema3 - ema15;
cond1= differnece > 0;
Buy = cond1 AND ema3 > ValueWhen(cond1, ema3, 2);

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "shahariar4" <shahariar4@xxx> wrote:
>
> Mike, thank you very much again for taking your time out...i have tried your indicated way but i think its not working and its not what i ment may be...may be my mention of pivots created the confusion.
> 
> suppose,
> 
> cond1= ema(clsoe,3)>ema(close,15);
> 
> now i want to add another condition to form the Buy when cond1 occurs and when the value of this cond1 is greater than the last time when this cond1 occured.
> 
> ----In a trending stock the price should go up and up creating waves; this way i would know that when the cond1(one of my buy criteria) has occured it is at a higer price then the previous time when it occured...and at higer place of the wave-----
> 
> Any last bit of help will be very nice of you.
> 
> Regards,
> 
> Shahariar
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> >
> > Well, you're question is actually a bit complicated. The direct answer would be:
> > 
> > Trigger = ...;
> > Buy = Trigger AND Close > ValueWhen(Trigger, Close, 2);
> > 
> > The above assumes that you wanted to buy on the trigger bar and that you would know immediately that that bar was in fact a trigger. We use a lookback of 2 since 1 would map to the current bar (which is also a trigger bar).
> > 
> > Where it gets complicated is that in your example you mentioned pivot low. You can never know whether a bar was a pivot low until one or more bars into the future. Therefore, you must alter the code to make the trigger be the point at which you can actually recognize the pivot low as being such (i.e. the bar one or more bars in the future from the actual pivot low at which point you are able to look back and say "yes, that was the pivot low"). See AFL Library for examples http://www.amibroker.com/library/detail.php?id=353
> > 
> > That being the case, you must use ValueWhen for both the Close of the current pivot low and of the one preceding it:
> > 
> > PivotLow = ...;
> > Trigger = ...;
> > 
> > Buy = Trigger AND ValueWhen(PivotLow, Close, 1) > ValueWhen(PivotLow, Close, 2);
> > 
> > Mike
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "shahariar4" <shahariar4@> wrote:
> > >
> > > Hi MIke:
> > > 
> > > Thanks for your correction. my basic idea is to suppose i have a buy signal; that buy signal's bar has to be of higher value that the last bar where anothe rbuy signal occured.
> > > 
> > > 
> > > suppose for example i want to buy on pivot low signal,but i want to add a codnition to it that if this pivot is of higer value than the last pivot low that occured;
> > > 
> > > 
> > > this way i would know if the stock is in short trend or not...as tredning stocks should create higer pivotlows in itsd way up....
> > > 
> > > so, i want to refence the last pivotlow
> > > 
> > > like we refer last clsoing pice as C>ref(c,-1) how it could be done for pivotlow Pivotlow>last pivotlow....
> > > 
> > > Any idea would be aprreciated and thanks in advance for you help.
> > > 
> > > Regards,
> > > 
> > > Shahariar
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> > > >
> > > > Your logic is flawed. Cond3 can never be true.
> > > > 
> > > > Note that Cross returns 1 or 0. So, there are 3 possible scenarios for any two sequential Cond1 values x,y where x is the previous bar value and y is the current bar value:
> > > > 
> > > > 0, 0 zero followed by a zero (no recent cross)
> > > > 0, 1 zero followed by a one (cross = true on current bar)
> > > > 1, 0 one followed by a zero (cross = true on previous bar)
> > > > 1, 1 (not possible since cross cannot happen twice in a row)
> > > > 
> > > > Now look at your Ref statement, Ref(Cond1, Cond1 - 1), for each scenario:
> > > > 
> > > > 0, 0 -> Ref(Cond1, 0 - 1) gives previous bar value of 0
> > > > 0, 1 -> Ref(Cond1, 1 - 1) gives current bar value of 1
> > > > 1, 0 -> Ref(Cond1, 0 - 1) gives previous bar value of 1
> > > > 
> > > > And your final logic of Cond1 > Ref(Cond1, Cond1 - 1)
> > > > 
> > > > 0, 0 -> 0 : 0 not greater than 0
> > > > 0, 1 -> 1 : 1 not greater than 1
> > > > 1, 0 -> 1 : 0 not greater than 1
> > > > 
> > > > 
> > > > Mike
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "shahariar4" <shahariar4@> wrote:
> > > > >
> > > > > Hi, All Memebrs,
> > > > > 
> > > > > Some little help in needed for the following idea.
> > > > > 
> > > > > I have tried a code as follows but it does not show any result or arrow...what am i making wrong?
> > > > > 
> > > > > Buy= when cond1 occurs and this cond1 has to be of higer value than the last cond1
> > > > > 
> > > > > 
> > > > > Cond1=Cross( ZLTyp, ZLHa );
> > > > > Cond2=Cross( ZLHa, ZLTyp );
> > > > > Cond3= Cond1> Ref(Cond1,Cond1 -1);
> > > > > 
> > > > > 
> > > > > Buy=IsTrue(Cond1 AND Cond3);
> > > > > 
> > > > > 
> > > > > // Suppose i am using a pivotlow as my buy signal, if the pivotlow my scan ditercts during scan, that pivotlow has to be at higer position than the previous pivotlow; so as like finding an uptrend with pivots........
> > > > >
> > > >
> > >
> >
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/