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

Notification

Icon
Error

3 Pages<123
Options
Go to last post Go to first unread
henry1224  
#41 Posted : Wednesday, March 21, 2012 6:51:58 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Kase mentioned 4 different levels in her book, I just added 2 more.
the 6 levels would have to be tested, Everybody has a different level of risk.
Kase uses 2 consecutive closes below a level to close out a long trade.
The code I provided was a basic formula based on the ideas provided from her book.
I have since modified the levels for the type of system I am trading
IE: If(Long=1 and C>level,1,If(Short=-1 and C < Level,-1,0))

As far as testing goes levels 1 and 2 are a little too fast and take you out of a trade

Levels 4 and 5 let your profits run but at the end of the trend you get slippage


indexarb  
#42 Posted : Friday, March 23, 2012 10:28:29 AM(UTC)
indexarb

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/12/2012(UTC)
Posts: 44

Hi Guys can you tell me where i am going wrong beow to add optimisers please original.... {_Test} Pds:=Input("Period",2,50,10); Sensitivity:=Input("Std Dev",.5,5,1); UseClose:=Input("Use Close",0,1,0); maMP:=mov(mp(),Pds,e); maATR:=mov(ATR(1),Pds,e); ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity; Entry:=if(UseClose,Close>ADM,High>ADM); Exit:=if(UseClose,ADM>Close,ADM>Low); { CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell } Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? } Signal:=ValueWhen(1,entry-exit0 OR Signal,entry); { Current } entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st } exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st } entry:=(exit=0)*entry; { favor EXIT } Signal:=Entry-Exit; { Signal } Season:=ValueWhen(1,Signal0,Entry)*2-1; { Signal active } { PLOT } ADM; OPT added {_Test} Pds:=Input("Period",OPT1,OPT2,OPT3); Sensitivity:=Input("Std Dev",.OPT4,OPT5,OPT6); UseClose:=Input("Use Close",0,1,0); maMP:=mov(mp(),Pds,e); maATR:=mov(ATR(1),Pds,e); ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity; Entry:=if(UseClose,Close>ADM,High>ADM); Exit:=if(UseClose,ADM>Close,ADM>Low); { CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell } Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? } Signal:=ValueWhen(1,entry-exit0 OR Signal,entry); { Current } entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st } exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st } entry:=(exit=0)*entry; { favor EXIT } Signal:=Entry-Exit; { Signal } Season:=ValueWhen(1,Signal0,Entry)*2-1; { Signal active } { PLOT } ADM;
jjstein  
#43 Posted : Friday, March 23, 2012 11:33:55 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Code:

Pds:=OPT1; { set 2 & 50 in the tab}
Sensitivity:=OPT2; { set .5 & 5 in tab}


henry1224  
#44 Posted : Friday, March 23, 2012 11:36:16 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
Code:

Pds:=Input("Period",OPT1,OPT2,OPT3);

Sensitivity:=Input("Std Dev",.OPT4,OPT5,OPT6);

UseClose:=Input("Use Close",0,1,0);




Should be

Pds:=Opt1;

Sensitivity:=Opt2;

UseClose:=Opt3;

Opt1 min should be 5 Max should be 50 and steps should be 5
Opt2 min should be 1 and Max should be 5 and steps should be 1
Opt3 Min should be 0 and max should be 1 and steps should be 1 

under the long enrty

Pds:=Opt1;

Sensitivity:=Opt2;

UseClose:=Opt3;
maMP:=mov(mp(),Pds,e);

maATR:=mov(ATR(1),Pds,e);


ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity;



Entry:=if(UseClose,Close>ADM,High>ADM);


Exit:=if(UseClose,ADM>Close,ADM>Low);


{ CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell }


Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? }

Signal:=ValueWhen(1,entry-exit<>0 OR Signal,entry); { Current }

entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st }

exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st }

entry:=(exit=0)*entry; { favor EXIT }

Signal:=Entry-Exit; { Signal }

Season:=ValueWhen(1,Signal<>0,Entry)*2-1; { Signal active }

Season=1 and Ref(Season,-1)<>1



Under the sell order tab



Pds:=Opt1;

Sensitivity:=Opt2;

UseClose:=Opt3;

maMP:=mov(mp(),Pds,e);


maATR:=mov(ATR(1),Pds,e);



ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity;





Entry:=if(UseClose,Close>ADM,High>ADM);




Exit:=if(UseClose,ADM>Close,ADM>Low);



{ CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell }




Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? }


Signal:=ValueWhen(1,entry-exit<>0 OR Signal,entry); { Current }


entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st }


exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st }


entry:=(exit=0)*entry; { favor EXIT }


Signal:=Entry-Exit; { Signal }


Season:=ValueWhen(1,Signal<>0,Entry)*2-1; { Signal active }


Season<>1 and Ref(Season,-1)=1

under the sell short order tab



Pds:=Opt1;

Sensitivity:=Opt2;

UseClose:=Opt3;

maMP:=mov(mp(),Pds,e);


maATR:=mov(ATR(1),Pds,e);



ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity;





Entry:=if(UseClose,Close>ADM,High>ADM);




Exit:=if(UseClose,ADM>Close,ADM>Low);



{ CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell }




Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? }


Signal:=ValueWhen(1,entry-exit<>0 OR Signal,entry); { Current }


entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st }


exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st }


entry:=(exit=0)*entry; { favor EXIT }


Signal:=Entry-Exit; { Signal }


Season:=ValueWhen(1,Signal<>0,Entry)*2-1; { Signal active }


Season=-1 and Ref(Season,-1)<>-1


in the buy to cover tab



Pds:=Opt1;

Sensitivity:=Opt2;

UseClose:=Opt3;

maMP:=mov(mp(),Pds,e);


maATR:=mov(ATR(1),Pds,e);



ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity;





Entry:=if(UseClose,Close>ADM,High>ADM);




Exit:=if(UseClose,ADM>Close,ADM>Low);



{ CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell }




Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? }


Signal:=ValueWhen(1,entry-exit<>0 OR Signal,entry); { Current }


entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st }


exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st }


entry:=(exit=0)*entry; { favor EXIT }


Signal:=Entry-Exit; { Signal }


Season:=ValueWhen(1,Signal<>0,Entry)*2-1; { Signal active }


Season<>-1 and Ref(Season,-1)=-1


this is an example of a system that gives 4 distinct signals.
with this code you could use it in experts ,explorations and now system tests

indexarb  
#45 Posted : Saturday, March 24, 2012 7:25:12 AM(UTC)
indexarb

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/12/2012(UTC)
Posts: 44

in the indicator builder i now have {_Test} Pds:=Opt1; Sensitivity:=Opt2; UseClose:=Opt3; maMP:=Mov(MP(),Pds,E); maATR:=Mov(ATR(1),Pds,E); ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity; Entry:=If(UseClose,CLOSE>ADM,HIGH>ADM); Exit:=If(UseClose,ADM>CLOSE,ADM>LOW); { CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell } Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? } Signal:=ValueWhen(1,entry-exit0 OR Signal,entry); { Current } entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st } exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st } entry:=(exit=0)*entry; { favor EXIT } Signal:=Entry-Exit; { Signal } Season:=ValueWhen(1,Signal0,Entry)*2-1; { Signal active } { PLOT } ADM; however i get the error msg ... Optimization variables are not allowed in this type of formula.
jjstein  
#46 Posted : Saturday, March 24, 2012 9:41:33 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Read Henry's reply more carefully. You cannot use OPTx variables in the Indicator Builder, you must copy the code instead.
indexarb  
#47 Posted : Saturday, March 24, 2012 3:28:02 PM(UTC)
indexarb

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/12/2012(UTC)
Posts: 44

Hi guys Totally Lost. Can you spell it out like the initial post please As I don't know if I have try o create as new indicator for this code What parts to put in the indicator, expert and system test
jjstein  
#48 Posted : Saturday, March 24, 2012 3:57:47 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
indexarb wrote:
Hi guys Totally Lost. Can you spell it out like the initial post please As I don't know if I have try o create as new indicator for this code What parts to put in the indicator, expert and system test


There is no Indicator or Expert. OPTx only works in the System Tester, so you have to copy & paste the formula code into the System Tester order windows.

BUY ORDER
Code:
{_Test}

Pds:=Opt1;
Sensitivity:=Opt2;
UseClose:=Opt3;

maMP:=Mov(MP(),Pds,E);
maATR:=Mov(ATR(1),Pds,E);

ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity;

Entry:=If(UseClose,CLOSE>ADM,HIGH>ADM);
Exit:=If(UseClose,ADM>CLOSE,ADM>LOW);

{ CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell }
Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? }
Signal:=ValueWhen(1,entry-exit<>0 OR Signal,entry); { Current }
entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st }
exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st }
entry:=(exit=0)*entry; { favor EXIT }
Signal:=Entry-Exit; { Signal }
Season:=ValueWhen(1,Signal<>0,Entry)*2-1; { Signal active }

{ PLOT }
Signal=+1;



SELL ORDER
Code:
{_Test}

Pds:=Opt1;
Sensitivity:=Opt2;
UseClose:=Opt3;


maMP:=Mov(MP(),Pds,E);
maATR:=Mov(ATR(1),Pds,E);

ADM:=maMP-maATR/2+Stdev(maATR,Pds)*Sensitivity;

Entry:=If(UseClose,CLOSE>ADM,HIGH>ADM);
Exit:=If(UseClose,ADM>CLOSE,ADM>LOW);

{ CLEAN - REMOVE REDUNDANT SIGNAL, 1=Buy -1=Sell }
Signal:=Cum(IsDefined(entry+exit))=1; { Enough data ? }
Signal:=ValueWhen(1,entry-exit<>0 OR Signal,entry); { Current }
entry:=Signal*(Alert(Signal=0,2) OR entry*Cum(entry)=1); { Current or 1st }
exit:=(Signal=0)*(Alert(Signal,2) OR exit*Cum(exit)=1); { Current or 1st }
entry:=(exit=0)*entry; { favor EXIT }
Signal:=Entry-Exit; { Signal }
Season:=ValueWhen(1,Signal<>0,Entry)*2-1; { Signal active }

{ PLOT }
Signal=-1;



indexarb  
#49 Posted : Saturday, March 24, 2012 4:41:44 PM(UTC)
indexarb

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/12/2012(UTC)
Posts: 44

And then put the optimized values into the indicator ?
jjstein  
#50 Posted : Saturday, March 24, 2012 8:35:34 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
indexarb wrote:
And then put the optimized values into the indicator ?


That's the theory.

Strongly suggest you END the optimization period a year ago, test on the past year's data.

Otherwise, you curve-fit the optimized variables -- which means the indicator will work well on past data, and fail when you trade on future data.

henry1224  
#51 Posted : Sunday, March 25, 2012 7:34:50 AM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
indexarb,

you really need to sit down with the user manual, read the sections about the metastock formula language.
Read about system testing and then experts and explorations.

Optimization is only allowed in system testing

using Inputs are only allowed in the indicator builder
When using Fml() and FmlVar() functions from indicators that have inputs, the values will be derived from the default values!

experts and explorations need defined values

read about defining Variables and nesting functions

Once you have done these, You will now see how easy it really is with metastock

You think you can skip over sections , but you're only stunting your knowledge of metastock
indexarb  
#52 Posted : Wednesday, March 28, 2012 5:44:26 AM(UTC)
indexarb

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/12/2012(UTC)
Posts: 44

Hi I think am making some progress, even though i probably know less than 10% quick question Justin wit this code allowed me to get a 1 or -1 signal as above _Test Signal FmlVar("_Test","Signal"); i know have 3 such signals FmlVar("_Test","Signal"); FmlVar("_Test1","Signal"); FmlVar("_Test2","Signal"); is there any way to have the sum of these signals (net result) in a new signal? (so all combined) thanks mehul
wabbit  
#53 Posted : Wednesday, March 28, 2012 6:34:36 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)
What do you think might add three values together? wabbit [:D]
indexarb  
#54 Posted : Wednesday, March 28, 2012 7:28:30 AM(UTC)
indexarb

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/12/2012(UTC)
Posts: 44

Hi sorry is it simply creating a new indicator with a sum function? i basically want the sum of the last -1 or 1 for the 3 individual indicators. each indicator has the same formula just different parammeters regards, mehul
wabbit  
#55 Posted : Wednesday, March 28, 2012 9:37:58 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)
So in the last month you've leaned nothing from reading the MS User Manual or the free Equis Formula Primer, just bludged off the good members here to do all the work for you; including showing you how to use +

Code:
FmlVar("_Test","Signal")+
FmlVar("_Test1","Signal")+

FmlVar("_Test2","Signal");


I don't know about the other members, but I'm tired...



wabbit [:D]

indexarb  
#56 Posted : Thursday, March 29, 2012 1:07:08 AM(UTC)
indexarb

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/12/2012(UTC)
Posts: 44

Hi all of your help is much appreciated and i know i have much work to do .... have one final question i know have the "combined indicator" showing in an inner window but how do i get a combined expert advisor ? i have tried changing the BUY --- FmlVar("_Test","Season")=1; { Color -- GREEN } to "A4" which is my combined indicator thanks again
PegasusDK  
#57 Posted : Tuesday, February 5, 2013 4:17:32 PM(UTC)
PegasusDK

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/5/2013(UTC)
Posts: 1

Hi all,

I see you're requesting some formula assistance regarding the fear/greed overlay and trender indicator.
Please have a look at my spread sheet at http://www.pointfigure.dk/dl.asp (search for trender).
The site is in danish, but the spread sheet is in english.

Please forward any comments to my email, since I'm not a common guest here...

Best
Peter, Denmark

Users browsing this topic
Guest (Hidden)
3 Pages<123
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.