MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

A B C D E F G H I J K L M N O P R S T U V W Y Z #

Signal/Value Accumulator by Jose Silva

From: wwflhp <wwfarr[at]>
To: equismetastock[at] <equismetastock[at]>
Date: Thursday, December 14, 2006, 8:48:46 PM
Subject: [EquisMetaStock Group] How do I generate a conditional clear signal for an average price?

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?

BuySignal:= Cross(C,Mov(C,20,E));
TotalInvested:= If(BuySignal,PREV+PurchaseAmount,PREV);
TotalShares:= If(BuySignal,PREV+(PurchaseAmount/C),PREV);
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;


I've also tried


And I've tried

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

From: Jose Silva <josesilva22[at]>
To: equismetastock[at] <equismetastock[at]>
Date: Thursday, December 14, 2006, 10:26:49 PM
Subject: [EquisMetaStock Group] Re: How do I generate a conditional clear signal for an average price?

Bill, maybe this indicator code can be of help:

Signal/Value Accumulator

{ Signal/Value accumulator v2.0
Accumulates & resets values between signals. }

{ Start count signal }

{ End count signal }

{ Value to accumulate - Volume }

{ Indicator output choice }
plot:=Input("plot: [1]Accumulation, [2]Signals",1,2,1);

{ Remove redundant interim start/end signals }
flag:=ValueWhen(1,start-end<>0 OR init,start);
OR start*Cum(start)=1);
OR end*Cum(end)=1);

{ Accumulate values }

{ Plot in own window }

Source / From: TOP

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!