logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
BillyB  
#1 Posted : Wednesday, March 14, 2007 12:21:34 PM(UTC)
BillyB

Rank: Newbie

Groups: Registered, Registered Users
Joined: 4/27/2005(UTC)
Posts: 5

Version Used 9.0

Date: 3-14-07

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. 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?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 adding many variations following the SellSignal including;

If(SellSignal,TotalInvested=0,Ref(TotalInvested,-1));

If(SellSignal,TotalShares=0,Ref(TotalShares,-1));

And I’ve also tried adding;

If(Ref(SellSignal,-1),TotalInvested=0,Ref(TotalInvested,-1));

If(Ref(SellSignal,-1),TotalShares=0,Ref(TotalShares,-1));

And I’ve tried adding;

If(Ref(SellSignal,-1),TotalInvested=0, TotalInvested=Ref(TotalInvested,-1));

If(Ref(SellSignal,-1),TotalShares=0, TotalShares=Ref(TotalShares,-1));

And I’ve tried adding;

TotalInvested:= If(SellSignal,0,If(BuySignal,PREV+PurchaseAmount,PREV));

TotalShares:= If(SellSignal,0,If(BuySignal,PREV+(PurchaseAmount/C),PREV));

But I get strange results. I have also created an array of past average prices, but I can’t figure out how to index back into the array. Aren’t there other Sell signals that are conditional on the average price of pyramided buys? Bill

wabbit  
#2 Posted : Wednesday, March 14, 2007 6:03:01 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
BillyB...

You could try emplying a Sum&Reset code, like:

condition:={SharesPurchased};
counter:=Cum(condition);
reset:={Sell}
TotalShares:=counter-ValueWhen(1,reset,counter);


Hope this helps.

wabbit [:D]

Users browsing this topic
Guest (Hidden)
Similar Topics
How do I generate a conditional clear signal for an average price? (MetaStock)
by BillyB 12/14/2006 1:08:57 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.