Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
I don't think this is referred to in the Formula Primer but it is definited referred to and used often throughout the MSTT newsletter resource (50 newsletters). There's a lot of other stuff about MetaStock that you won't find anywhere else either.
MetaStock is a purely sequential language, except for the possible exception of PREV. Whatever has already been defined in a formula is accptable as an input for subsequent definitions. My use of variable names more than once stems from the MetaStock limitation of just 20 names per formula. That limitation doesn't apply to the definitions, just the names used. When i use the name Signal for the second time the only Signal variable that MetaStock is aware of is the first definition. Therefore it happily creates a new definition for that name and writes it over the old definition once the new definition is complete.
Re-using variable names means that you can modify a variable to be slightly different (in this case without any N/A bars), or you can create something entirely new.
Roy
www.metastocktips.co.nz
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/23/2010(UTC) Posts: 60
|
mstt wrote:
Signal:=Ref(Mov(MP( ),5,S),2); Defined:=IsDefined(Signal); Signal:=ExtFml("Forum.Sum",Signal,1); If(Defined,Signal,Mid(C,5));
Roy
So the 2nd and 3rd line equations use the Signal Variable defined in the 1st line?
And the 4th line equation uses the Signal Variable defined in the 3rd line?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/23/2010(UTC) Posts: 60
|
Roy,
Thank you for your help.
Dennis
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/23/2010(UTC) Posts: 60
|
I rewrote the formula to make it easier to ask questions about it.
Signal a:= Fml( "mov87") ;
Defined:= IsDefined(Signal a);
Signal b:= ExtFml( "Forum20.Sum",Signal a,1);
Signal c:= Fml( "87Day Derived Avg");
If(Defined, Signal b ,Signal c )
The above formula works as written with Signal b plotted when Defined =1, and Signal c plotted when Defined=0.
Where I run into trouble is when I add an adjustment to Signal c
"Signal c+ Adjustment"
Day 99 is the last day Signal b is plotted.
Day 100 Signal c begins it's plot.
On day 100 I want to fetch the value of Signal b from the day before (day 99) and subtract Signal c from it and add that difference to Signal c as an adjustment. I calculated the Adjustment to be 21 and if I just add 21 to Signal c the plot is what I want. I just can't generate the number from an equation like;
Signal c + (Signal b-Signal c)
Ideas?
Thank's,
dlipter
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
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.