PureBytes Links
Trading Reference Links
|
Bill, it seems to me that you are dealing with a circular reference
situation. There is probably a PREV-based solution lurking there, but
it's not going to be pretty or easy to find.
jose '-)
http://www.metastocktools.com
--- In equismetastock@xxxxxxxxxxxxxxx, "wwflhp" <wwfarr@xxx> wrote:
>
> Jose, Thanks for your response. Your technique does not solve my
> problem because the "end" condition is not conditional. What I need to
> be able to do is set the TotalShares value back to zero after the
> SellSignal is generated. But the SellSignal is dependent on the Ave
> Price which is in turn dependent on the TotalShares, value. I can also
> compute the AvePrice using the number of BuySignal s, but the number of
> BuySignal s must also be cleared buy the SellSignal. I have thought of
> creating a data array of previous Ave Price s, but then I can't figure
> out how to determine how far to index back into the data array of
> previous Ave Price s, because that too requires me to know how many
> BuySignal s have occurred since the most recent SellSignal which is
> conditional on which AvePrice you choose which is dependent on .... I
> can't believe that this is not a common question and that it has been
> solved. Bill
> --- In equismetastock@xxxxxxxxxxxxxxx, "Jose Silva" <josesilva22@>
> wrote:
> >
> > Bill, maybe this indicator code can be of help:
> >
> >
> > ==================
> > Signal accumulator
> > ==================
> > ---8<----------------------------
> >
> > { Signal/Value accumulator v1.0
> > Accumulates & resets value count.
> > http://www.metastocktools.com }
> >
> > { Indicator output choice }
> > plot:=Input("plot: [1]Accumulation, [2]Signals",1,2,1);
> >
> > { Start count signal }
> > start:=TroughBars(1,C,5)=0;
> >
> > { End count signal }
> > end:=PeakBars(1,C,5)=0;
> >
> > { Start to End flag, clean signals }
> > init:=Cum(IsDefined(start+end))=1;
> > flag:=ValueWhen(1,start-end<>0 OR init,start);
> > start:=flag*(Alert(flag=0,2)
> > OR start*Cum(start)=1);
> > end:=(flag=0)*(Alert(flag,2)
> > OR end*Cum(end)=1);
> >
> > { Value to accumulate - Bars }
> > value:=1;
> >
> > { Accumulate values }
> > acc:=Cum(flag*value);
> > accVal:=acc-ValueWhen(1,end,acc);
> >
> > { Plot in own window }
> > If(plot=1,accVal,start-end)
> >
> > ---8<----------------------------
> >
> >
> > jose '-)
> > http://www.metastocktools.com
> >
> >
> >
> >
> > --- In equismetastock@xxxxxxxxxxxxxxx, "wwflhp" wwfarr@ wrote:
> > >
> > > Version Used 9.0
> > > Date: 12-9-06
> > > Subject: How do I generate a conditional clear signal for an average
> > > price?
> > > I want to have a sell signal that is conditional on the average
> price
> > > of pyramided buys. That is, the sell signal is only generated if
> the
> > > current closing price of a stock exceeds the average purchase price
> > > after several pyramided fixed $ amount buy signals. The problem is,
> > > how do I clear the total invested and total shares owned sum
> variables
> > > to zero only after the conditional sell signal is generated?
> > > Specifically;
> > >
> > > PurchaseAmount:=5000;
> > > BuySignal:= Cross(C,Mov(C,20,E));
> > > TotalInvested:= If(BuySignal,PREV+PurchaseAmount,PREV);
> > > TotalShares:= If(BuySignal,PREV+(PurchaseAmount/C),PREV);
> > > AvePrice:=TotalInvested/TotalShares;
> > > SellCondition:=Cross(Mov(C,20,E),C);
> > > SellSignal:=SellCondition AND (C>(AvePrice));
> > >
> > > How do I clear TotalInvested and TotalShares, to 0 only if sell
> signal
> > > is true?
> > > I tried many variations following the SellSignal including;
> > >
> > > If(SellSignal,TotalInvested=0,Ref(TotalInvested,-1));
> > > If(SellSignal,TotalShares=0,Ref(TotalShares,-1));
> > >
> > > I've also tried
> > >
> > > If(Ref(SellSignal,-1),TotalInvested=0,Ref(TotalInvested,-1));
> > > If(Ref(SellSignal,-1),TotalShares=0,Ref(TotalShares,-1));
> > >
> > > And I've tried
> > >
> > > If(Ref(SellSignal,-1),TotalInvested=0,
> > > TotalInvested=Ref(TotalInvested,-1));
> > > If(Ref(SellSignal,-1),TotalShares=0,
> TotalShares=Ref(TotalShares,-1));
> > >
> > > But I get strange results. I can't get TotalInvested and
> TotalShares
> > > to go to 0 after the SellSignal and to stay 0 until the next
> > > BuySignal. Thanks and Happy Holidays, Bill
------------------------ Yahoo! Groups Sponsor --------------------~-->
Transfer from your equities account.
Receive up to $1,000 from GFT. Click here to learn more.
http://us.click.yahoo.com/aZttyC/X_xQAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/equismetastock/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:equismetastock-digest@xxxxxxxxxxxxxxx
mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|