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

Notification

Icon
Error

Options
Go to last post Go to first unread
Leverage  
#1 Posted : Monday, August 2, 2010 12:18:28 PM(UTC)
Leverage

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 1/25/2010(UTC)
Posts: 44
Location: Rome, IT

Hi guys,
there is someone who can help me for translate an oscillator formula from easy language to metastock language?
Unfortunately don't know easy language [:(]
johnl  
#2 Posted : Monday, August 2, 2010 9:29:26 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

If you want it done free then your best bet is to post the code and someone may take some interest in it.
Leverage  
#3 Posted : Tuesday, August 3, 2010 2:27:38 AM(UTC)
Leverage

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 1/25/2010(UTC)
Posts: 44
Location: Rome, IT

Absolutely...here the code in easy language to translate:

{Description of Inputs}{CXOver - This oscillator can be used with a crossover, although it is usually plotted without one.CXOver is the length of the of the moving agerage of the BLine to construct the crossover. The purpose of a crossover is to improve the accuracy of an oscillator that wiggles at tops and bottoms. In most markets the BLine does not often wiggle at tops and bottoms.}

{SellLine and BuyLine are levels the osc must rise above for an osc downturn to paint a sell setup bar, or drop below for an osc upturn to paint a buy setup bar}


Inputs: CXOver(0),SellLine(70),BuyLine(30),Alrt(0);

Vars: Len1(3),Len2(3),Len3(3),OBOSMY(0),OBOSMYC(0),Sum(0),Cnt(0);

{OBOS}
Sum=0;
For Cnt=0 to Len2-1 begin
Sum=Sum+_OBOS(CXOver)[Cnt];
End;
If Len2>0 then
OBOSMY=Sum/Len2
Else
OBOSMY=0;
Sum=0;
For Cnt=0 to CXOver-1 begin
Sum=Sum+OBOSMY[Cnt];
End;
If CXOver>0 then
OBOSMYC=Sum/CXOver
Else
OBOSMYC=0;
If Alrt<>0 then begin
If OBOSMY<BuyLine then Alert=True;
If OBOSMY>SellLine then Alert=True;
End;

{Plots}
If CXOver=0 then
Plot1(Round(OBOSMY,1),"BLine");
If CXOver<>0 then begin
Plot1(Round(OBOSMY,1),"BLine");
Plot2(Round(OBOSMYC,1),"BLine_CO");
End;
Plot3(SellLine,"BLine_SL");
Plot4(BuyLine,"BLine_BL");
__________________________________

I think it would be a good oscillator to grab market cycles...TNX

vienna  
#4 Posted : Tuesday, August 3, 2010 3:51:44 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

In the previous post the _OBOS function is missing.. so it wouldn't be possible to code it in metastock with only this information.

In the web I found this Function: (source: http://www.forex-tsd.com...trader-indicator-me.html )

{_OBOS:OBOB}

Inputs: CXOver(NumericSimple);

Vars: Len1(3),Len2(3),Len3(3),OBOS(0),PPr(0),Op(0),HstH(0),LstL(0),Cntr(0),
DAmt(0),UAmt(0),USm(0),DSm(0),UAvg(0),DAvg(0),MRng(0);

{OB/OS}
Op=O[Len3];
HstH=_Hst(H,Len3);
LstL=_Lst(L,Len3);
PPr=(Op+HstH+LstL+C)/4;
If CurrentBar=1 then begin
MRng=Len1;
USm=0;
DSm=0;
For Cntr=0 to MRng-1 begin
UAmt=PPr[Cntr]-PPr[Cntr+1];
If (UAmt>=0) then
DAmt=0
Else begin
DAmt=-UAmt;
UAmt=0;
End;
USm=USm+UAmt;
DSm=DSm+DAmt;
End;
UAvg=USm/MRng;
DAvg=DSm/MRng;
End
Else
If CurrentBar>1 then begin
UAmt=PPr[0]-PPr[1];
IF UAmt>=0 then
DAmt=0
Else begin
DAmt=-UAmt;
UAmt=0;
End;
UAvg=(UAvg[1]*(MRng-1)+UAmt)/MRng;
DAvg=(DAvg[1]*(MRng-1)+DAmt)/MRng;
End;
IF UAvg+DAvg<>0 then
OBOS=100*UAvg/(UAvg+DAvg)
Else
OBOS=0;

_OBOS=OBOS;

But at least there is also an "End" missing in this code...
Leverage  
#5 Posted : Tuesday, August 3, 2010 8:07:16 AM(UTC)
Leverage

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 1/25/2010(UTC)
Posts: 44
Location: Rome, IT

TNX vienna,
confirm that _OBOS code start and finish in this mode:

{_OBOS:OBOB}

Inputs: CXOver(NumericSimple);

Vars: Len1(3),Len2(3),Len3(3),OBOS(0),PPr(0),Op(0),HstH(0),LstL(0),Cntr(0),
DAmt(0),UAmt(0),USm(0),DSm(0),UAvg(0),DAvg(0),MRng(0);

{OB/OS}
Op=O[Len3];
HstH=_Hst(H,Len3);
LstL=_Lst(L,Len3);
PPr=(Op+HstH+LstL+C)/4;
If CurrentBar=1 then begin
MRng=Len1;
USm=0;
DSm=0;
For Cntr=0 to MRng-1 begin
UAmt=PPr[Cntr]-PPr[Cntr+1];
If (UAmt>=0) then
DAmt=0
Else begin
DAmt=-UAmt;
UAmt=0;
End;
USm=USm+UAmt;
DSm=DSm+DAmt;
End;
UAvg=USm/MRng;
DAvg=DSm/MRng;
End
Else
If CurrentBar>1 then begin
UAmt=PPr[0]-PPr[1];
IF UAmt>=0 then
DAmt=0
Else begin
DAmt=-UAmt;
UAmt=0;
End;
UAvg=(UAvg[1]*(MRng-1)+UAmt)/MRng;
DAvg=(DAvg[1]*(MRng-1)+DAmt)/MRng;
End;
IF UAvg+DAvg<>0 then
OBOS=100*UAvg/(UAvg+DAvg)
Else
OBOS=0;

_OBOS=OBOS;
_________________________

but I think that in the code there are a references to other function. So I post all the code that I have in easylanguage in reference to oscillator:

function _Hst:
{_Hst: Calculates Highest Values}

Inputs: Price(NumericSeries),Length(NumericSimple);

Vars: X(0),Hi(-999999);

Hi=-999999;
For X=0 to Length-1 begin
If Price[X]>Hi then Hi=Price[X];
End;

_Hst=Hi;
________________________
function _Lst:
{_Lst: Calculates Lowest Values}

Inputs: Price(NumericSeries),Length(NumericSimple);

Vars: X(0),Lo(999999);

Lo=999999;
For X=0 to Length-1 begin
If Price[X]<Lo then Lo=Price[X];
End;

_Lst=Lo;
_________________________

Tell me if you need other function that I forgotten....TNX

johnl  
#6 Posted : Wednesday, August 4, 2010 8:38:10 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602


After taking quite a few liberties, how about this:


PPr:=(O+HHV(H,5)+LLV(L,5)+C)/4;
Uamt:=PPR-Ref(PPr,-1);
Damt:=If((UAmt>=0),0,-UAmt);
USm:=Sum((Uamt>0),10);
DSm:=Sum((Uamt<0),10);
UAvg:=USm/10;
DAvg:=DSm/10;
OBOS:=100*UAvg/(UAvg+DAvg);
OBOS

Any chance of a picture of the indicator?
Leverage  
#7 Posted : Thursday, August 5, 2010 5:33:24 AM(UTC)
Leverage

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 1/25/2010(UTC)
Posts: 44
Location: Rome, IT

Great johnl! almost the solution!!!

I post a picture: in red the oscillator who I want reproduce for my studies, in black your result

CLICK THIS LINK FOR THE PICTURE

and here the two oscillators compared in the same inner windows:

CLICK THIS LINK FOR THE COMPARE OSCILLATORS


johnl  
#8 Posted : Thursday, August 5, 2010 7:33:12 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

How about if I stick a Moving Avereage in there:


PPr:=(O+HHV(H,5)+LLV(L,5)+C)/4;
Uamt:=PPR-Ref(PPr,-1);
USm:=Sum((Uamt>0),10);
DSm:=Sum((Uamt<0),10);
UAvg:=Mov(usm,5,E);
DAvg:=Mov(dsm,5,E);
OBOS:=100*UAvg/(UAvg+DAvg);
OBOS

Leverage  
#9 Posted : Friday, August 6, 2010 2:32:01 AM(UTC)
Leverage

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 1/25/2010(UTC)
Posts: 44
Location: Rome, IT

Hi johnl...missing a particular that I cannot find:

THE RESULT AFTER LAST MODIFICATION

in black your result. I tried to change the parameters but something missing.
I thank you anyway for the help you have given me
stiv  
#10 Posted : Tuesday, February 22, 2011 2:37:52 AM(UTC)
stiv

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/21/2011(UTC)
Posts: 4

Hi, i wrote formula in EL but in forst line after "vars" compilation show me error, can you show me my mistake? My formula bellow:

vars: HH,LL,d;

HH=maxlist(H,H[1],H[2],H[3]);

LL=minlist(L,L[1],L[2],L[3]);

d[0]=C;

if C>HH[1] then d=LL; else

if C<LL[1] then d=HH; else

d=d[1];

if C crosses above d then buy( "sygnal dluga" ) 1 share this bar close ;



Thanks Stiv
wabbit  
#11 Posted : Tuesday, February 22, 2011 12:58:21 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)
What a strange question to be asking in a MetaStock Forum?

Anyway...

You need to declare, define and initialise your variables -- it's all in the manual.



wabbit [:D]

stiv  
#12 Posted : Wednesday, February 23, 2011 8:03:56 AM(UTC)
stiv

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/21/2011(UTC)
Posts: 4

Hi viena, can you help me translate formula from metastock to easy language?

My formula: Normal 0 21 false false false PL X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

d:=If(C>Ref(Max(Max(H,Ref(H,-3)),Max(Ref(H,-1),Ref(H,-2))),-1),Min(Min(L,Ref(L,-3)),Min(Ref(L,-1),Ref(L,-2))),If(C<Ref(Min(Min(L,Ref(L,-3)),Min(Ref(L,-1),Ref(L,-2))),-1),Max(Max(H,Ref(H,-3)),Max(Ref(H,-1),Ref(H,-2))),PREV));

a:=Cross(C,d);

b:=Cross(d,C);

state:=If(BarsSince(a)<BarsSince(b),1,0);

state=1


Thanks in advance Stiv

vienna  
#13 Posted : Thursday, February 24, 2011 2:23:41 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

Hi Stiv,
I'm sorry but I have no software which "speaks" easy language (to test code), and I also have never programmed in easy language. Therefore the other way round would be easier for me. Maybe its better to ask in a forum which is for an easy language software package?
wabbit  
#14 Posted : Thursday, February 24, 2011 3:03:13 AM(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)
Try starting with:
Code:

vars: HH(0),LL(0),d(0);




wabbit [:D]

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.