Discussions
»
Product and Service Development
»
Formula Assistance
»
help to code a formula from PRO REALTIME to METASTOCK
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 9/18/2008(UTC) Posts: 37
|
HI,
I VE THIS PROREAL TIME SCRIPT:
//New Money index
NewMoney=cumsum(close*(volume-volume[1]))
Return NewMoney as "NewMoney"
//Old Profit index
OldProfit=cumsum(volume[1]*(close-close[1]))
Return OldProfit coloured (0,0,250) as "OldProfit"
in order to built an oscillator that help to understand trend by volume ... in other words something that looks like a new money in the market
the cumulation values gives these oscillator
PLEASE how to translate in metastock language?
thank you
Luigi
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,971
Thanks: 94 times Was thanked: 156 time(s) in 151 post(s)
|
Not really familiar with the script language. Is the [1] referring to the previous day? You could try the following formula but I am not sure what the oscillator is expected to look like:
NewMoney:=Cum(C * (V-Ref(V,-1)));
NewMoney;
OldProfit:=Cum(Ref(V,-1) * (C - Ref(C,-1)));
OldProfit;
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
Hello,
is it possible to translate also this indicator from ProRealTime to Metastock?
// Butterworth Indicator
if BarIndex < 2 then
BU=Close
else
BU=BU[1]-BU[2]/3.414+(1/3.414)*Close
Endif
Return BU
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,971
Thanks: 94 times Was thanked: 156 time(s) in 151 post(s)
|
Not familiar with this myself, but someone did create a Butterworth Filter via this older post:
http://forum.metastock.c...rworth-Filter#post153839
{ 2 Pole Butterworth Filter }
Data:=((H+L)/2);
Period:=Input("Period",5,175,175);
a1:=Exp(-1.414*3.14159/Period);
b1:=2*a1*Cos(1.414*180/Period);
coef2:=b1;
coef3:=-a1*a1;
coef1:=(1-b1+a1*a1)/4;
Butter:=coef1*(Data+2*Ref(Data,-1)+Ref(Data,-2)) + coef2*PREV + coef3*Ref(PREV,-1);
Butter;
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
Thank you for the quickly reply, but this is two pole filter.
As shown below:
prevP1 = price[index-1];
prevP2 = price[index-2];
prevB1 = ifNull(price, butter[index-1]); //feedback ingredent
prevB2 = ifNull(price, butter[index-2]); //feedback ingredent
piPrd = Math.PI/period;
a1 = Math.exp(-1.414 * piPrd);
b1 = 2 * a1 * Math.cos(1.414 * piPrd);
coef2 = b1;
coef3 = -a1 * a1;
coef1 = (1 - b1 + a1 * a1) / 4;
plot: butter = coef1 * (price + (2*prevP1) + prevP2) + (coef2*prevB1) + (coef3*prevB2);
Mine should be easier.
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,971
Thanks: 94 times Was thanked: 156 time(s) in 151 post(s)
|
I can take a shot at it, you can see if this meets your criteria:
BU:=Cum(1);
BU2:=If(BU < 2,CLOSE,Ref(BU,-1) - Ref(BU,-2))/3.414+(1/3.414)*CLOSE;
BU2
|
 1 user thanked MS Support for this useful post.
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
Thank you, i will give a try.
By the way is there, apart formula Metastock Formula Primer pdf, a manual where i can find what every term means quickly?
ie: C = Close, O=Open, etc...
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,971
Thanks: 94 times Was thanked: 156 time(s) in 151 post(s)
|
Basically we have what is in the F1 Help of MetaStock. There should be a primary topic called MetaStock Formula Language with several subsections, including the Price Array Identifiers as well as a section for Working With Functions.
|
 1 user thanked MS Support for this useful post.
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
Ok. I will check.
Thank you for now.
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
How about writing this in metastock?
lag=11
if BarIndex > 2
then BU=close
else BU=BU[1]-BU[2]/3.414+(1/3.414)*Close
endif
c1=BU>BU[lag]
if c1
then buy 1 share at market tomorrowopen
endif
c2=BU<BU[lag]
if c2
then sellshort 1 share at market tomorrowopen
endif
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,971
Thanks: 94 times Was thanked: 156 time(s) in 151 post(s)
|
Are you looking to use this as an indicator, system test, exploration, or expert advisor?
|
 1 user thanked MS Support for this useful post.
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
I would like to use mainly as an indicator, but if it useful also as a system test and expert advisor.
Thank you.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,971
Thanks: 94 times Was thanked: 156 time(s) in 151 post(s)
|
In looking at the formula a bit, I am not quite sure what the following is supposed to represent:
BU[1]-BU[2]
Is this supposed to refer to the difference between the Close price 1 bar and Close price 2 bars ago?
|
|
|
|
Rank: Newbie
Groups: Registered Users, Subscribers Joined: 1/28/2016(UTC) Posts: 9
Thanks: 6 times
|
if BarIndex < 2 then
BU=Close
else
BU=BU[1]-BU[2]/3.414+(1/3.414)*Close
Endif
should be in Metastock
BU:=Cum(1);
BU2:=If(BU < 2,CLOSE,Ref(BU,-1) - Ref(BU,-2))/3.414+(1/3.414)*CLOSE;
BU2
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,971
Thanks: 94 times Was thanked: 156 time(s) in 151 post(s)
|
Well this formula I believe would generally work, but because your condition will virtually always be in a buy or sell state, it will repeat the signals:
Lag:=11;
BarIndex:=Cum(1);
BU:=If(BarIndex < 2,CLOSE,Ref(BarIndex,-1) - Ref(BarIndex,-2))/3.414+(1/3.414)*CLOSE;
C1:=BU>Ref(BU,-Lag);
C2:=BU<Ref(BU,-Lag);
If(C1,1,If(C2,-1,0))
There is a way you can write the formula to limit the signals to "new" buy or sell signals, meaning it would only generate a sell signal if the previous signal was a buy, as opposed to repeating the sell signal or buy signal over and over. I'm just not sure if that is what you're looking for. Edited by user Thursday, February 18, 2016 3:03:36 PM(UTC)
| Reason: Not specified
|
 1 user thanked MS Support for this useful post.
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
help to code a formula from PRO REALTIME to METASTOCK
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.