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

Notification

Icon
Error

Options
Go to last post Go to first unread
HyperionAUT  
#1 Posted : Tuesday, January 1, 2013 11:40:23 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Hi, may someone can help me. I try to start the system tester ($$) with following expert formula.
The code was originally written by Jose Silva in 2004.

BUY:

When(Mov(C, 5, E), >, Mov(C, 38, E))
AND

When(Mov(Tema(C,3)-Tema(C,38),3,E), >, 0)
AND

When(O, >, Mov(C, 50, E))
AND

When(Mov(C, 9, E), >, Mov(C, 50, E))

Exit:

When(C, <, SAR(0.07, 0.15))

SELL - Short:

When(Mov(C, 5, E), <, Mov(C, 38, E))
AND

When(Mov(Tema(C,3)-Tema(C,38),3,E), <, 0)
AND

When(O, <, Mov(C, 50, E))
AND

When(Mov(C, 9, E), <, Mov(C, 50, E))

Exit:

When(C, >, SAR(0.07, 0.15))

but it is not "working" as i need it. there should be only one BUY signal at the beginning of the new trend, or only once when the conditions are true.

like the expert, it is a green 2cm long field, all the time the condictions are true, but in the system tester i only need it ONCE, and sell (exit) when the SAR() condictions are true. then buy again, during the time the expert is "true" and sell (exit) again.

Any idea how to type this into the system-tester? that the simulation calculate the profit (loss) only between the buy, and exit (sell short and exit) bars.

if() .. or how can i simulate it, that it will only BUY ONE time, .. till the exit take place, and then buy again??

i do not need 20 green arrows (screenshot), only (e.g.) 4 during the green expert - time.

Screenshot: (how can i upload a picture? then you see what i mean) : )

wabbit  
#2 Posted : Tuesday, January 1, 2013 6:28:13 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)
Where to start? When posting code, please use the proper tags; it helps readers differentiate text from code. The use of the three argument When() function was deprecated about 15 years ago, so have a read through the current user manual and do the exercises in the free Equis formula primer to learn how to use the current function set in MS. When writing your system rules, when you have an entry criteria which does not include the exit criteria, you run the risk of entering the trade one bar only to have it exit on the next bar, so it's safer to write something like:
Code:

exit:= {some criteria};
enter:={some criteria} AND exit=0;
If you have specified in the EST that you can only simultaneously have 1 trade open, although the code will be triggering many times only one trade will be opened until the exit condition is met. You can do some more programming to convert open-and-stay-open signals into discrete signals, but the EST doesn't really need these. On the chart, for the expert advisor however, too many signals and arrows can appear confusing, so you'll need some sort of latch to remove redundant signals; the forum.dll has a function which will suit many traders but check the logic map first to ensure the latch trades the way you want to trade, or you could use a PREV based latch as Roy (MSTT) has demonstrated soooooo many times on this forum, do a search and read his excellent tutorial available in the downloads section of the forum. Do a search for how to post images; it has been covered hundreds of times. wabbit [:D] n:=
HyperionAUT  
#3 Posted : Wednesday, January 2, 2013 5:23:49 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Thank you Wabbit! I´ll do my best ... so I am 15 years in the past?
I take this personally... Just kidding *g*

HyperionAUT  
#4 Posted : Thursday, January 3, 2013 3:47:23 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Finally, so i guess... but there is no guarantee | System Tester:


Buy Order
BuyL:=If((Dema(C,9)-Dema(C,30) > 0) AND (C > Mov(C,50,E)) AND (C > SAR(0.07, 0.18)) AND (Mov(C, 5, E) > Mov(C, 13, E)) AND AroonUp(1),1,0);
ExitL:= If(C < SAR(0.07, 0.18),1,0);
BuyL AND BarsSince(Ref(BuyL, -1))> BarsSince(Ref(ExitL, -1));

Sell Order
BuyL:=If((Dema(C,9)-Dema(C,30) > 0) AND (C > Mov(C,50,E)) AND (C > SAR(0.07, 0.18)) AND (Mov(C, 5, E) > Mov(C, 13, E)) AND AroonUp(1),1,0);
ExitL:= If(C < SAR(0.07, 0.18),1,0);
BuyL AND BarsSince(Ref(BuyL, -1))> BarsSince(Ref(ExitL, -1));

Sell Short Order
SellS:=If((Dema(C,9)-Dema(C,30) < 0) AND (C < Mov(C,50,E)) AND (C < SAR(0.07, 0.18)) AND (Mov(C, 5, E) < Mov(C, 13, E)) AND AroonDown(1),1,0);
ExitS:= If(C > SAR(0.07, 0.18),1,0);
SellS AND BarsSince(Ref(SellS, -1))> BarsSince(Ref(ExitS, -1));

Buy to Cover Order
SellS:=If((Dema(C,9)-Dema(C,30) < 0) AND (C < Mov(C,50,E)) AND (C < SAR(0.07, 0.18)) AND (Mov(C, 5, E) < Mov(C, 13, E)) AND AroonDown(1),1,0);
ExitS:= If(C > SAR(0.07, 0.18),1,0);
SellS AND BarsSince(Ref(SellS, -1))> BarsSince(Ref(ExitS, -1));

HyperionAUT  
#5 Posted : Thursday, January 3, 2013 3:51:31 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

And for the EXPERT: Trends

Bullish:

LE:=(Dema(C,9)-Dema(C,30) > 0) AND (C > Mov(C,50,E)) AND (C > SAR(0.07, 0.18)) AND (Mov(C, 5, E) > Mov(C, 13, E)) AND AroonUp(1);
LX:= O < SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;LE:=(Dema(C,9)-Dema(C,30) > 0) AND (C > Mov(C,50,E)) AND (C > SAR(0.07, 0.18)) AND (Mov(C, 5, E) > Mov(C, 13, E)) AND AroonUp(1);
LX:= O < SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;

Bearish:
LE:=(Dema(C,9)-Dema(C,30) < 0) AND (C < Mov(C,50,E)) AND (C < SAR(0.07, 0.18)) AND (Mov(C, 5, E) < Mov(C, 13, E)) AND AroonDown(1);
LX:= O > SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;LE:=(Dema(C,9)-Dema(C,30) < 0) AND (C < Mov(C,50,E)) AND (C < SAR(0.07, 0.18)) AND (Mov(C, 5, E) < Mov(C, 13, E)) AND AroonDown(1);
LX:= O > SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;


And for the EXPERT: Symbols

BUY:
LE:=(Dema(C,9)-Dema(C,30) > 0) AND (C > Mov(C,50,E)) AND (C > SAR(0.07, 0.18)) AND (Mov(C, 5, E) > Mov(C, 13, E)) AND AroonUp(1);
LX:= O < SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;LE:=(Dema(C,9)-Dema(C,30) > 0) AND (C > Mov(C,50,E)) AND (C > SAR(0.07, 0.18)) AND (Mov(C, 5, E) > Mov(C, 13, E)) AND AroonUp(1);
LX:= O < SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;


SELL:
LE:=(Dema(C,9)-Dema(C,30) < 0) AND (C < Mov(C,50,E)) AND (C < SAR(0.07, 0.18)) AND (Mov(C, 5, E) < Mov(C, 13, E)) AND AroonDown(1);
LX:= O > SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;LE:=(Dema(C,9)-Dema(C,30) < 0) AND (C < Mov(C,50,E)) AND (C < SAR(0.07, 0.18)) AND (Mov(C, 5, E) < Mov(C, 13, E)) AND AroonDown(1);
LX:= O > SAR(0.07, 0.18);
Z:= ExtFml( "ForumEquis.Latch", LE, LX, 0, 0);
EnterLong:=Z = 1 AND Ref(Z,-1) <> 1;
ExitLong:=Z = 0 AND Ref(Z,-1) = 1;
EnterLong-ExitLong;


ahmm..... really no idea what it is good for... the results are "IMPRESSIVE!" : - ))

SAR(0.035, 0.350)

wabbit  
#6 Posted : Thursday, January 3, 2013 6:13:12 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)
Is it just me? Or, have you got some cut and paste issues here? Also, the latch has the capability to deal simultaneously with long and short trades. wabbit [:D]
wabbit  
#7 Posted : Thursday, January 3, 2013 7:38:26 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)
If you're going to have lots of components in MS using the same code (indicators, experts and system tests) it can get confusing when trying to edit the same code in every location in MS; sometimes it can be better to write the system once as an indicator and call it using the Fml() and/or FmlVar() functions; e.g.

Code:

{MY_TRADING_SYSTEM indicator}

mySAR:=SAR(0.07, 0.18);

LE:=
Dema(C,9) > Dema(C,30) AND
C > Mov(C,50,E) AND
C > mySAR AND
Mov(C, 5, E) > Mov(C, 13, E) AND
AroonUp(1);

LX:= O < mySAR;

SE:=
Dema(C,9) < Dema(C,30) AND
C < Mov(C,50,E) AND
C < mySAR AND
Mov(C, 5, E) < Mov(C, 13, E) AND
AroonDown(1);

SX:= O > mySAR;

{the latch}
ExtFml("ForumEquis.Latch", LE, LX, SE, SX);


Expert Advisor
Code:

{LongEntry Symbol}
Z:=Fml("MY_TRADING_SYSTEM");
Z=1 AND Ref(Z,-1)<>1;

{LongExit Symbol}
Z:=Fml("MY_TRADING_SYSTEM");
Z<>1 AND Ref(Z,-1)=1;

{ShortEntry Symbol}
Z:=Fml("MY_TRADING_SYSTEM");
Z=-1 AND Ref(Z,-1)<>-1;

{ShortExit Symbol}
Z:=Fml("MY_TRADING_SYSTEM");
Z<>-1 AND Ref(Z,-1)=-1;

{Bullish Trend}
Fml("MY_TRADING_SYSTEM")=1;

{Bearish Trend}
Fml("MY_TRADING_SYSTEM")=-1;


Use the same codes in the EST as required.


wabbit [:D]


HyperionAUT  
#8 Posted : Friday, January 4, 2013 2:08:32 PM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Thank you! I try my best, by now it is not that easy to pack the code into such a small ... function. Have to train my brain. Soon, yeah soon...

Cool Wabbit, nice and helped me a lot xD

so the next million is mine! : D

HyperionAUT  
#9 Posted : Saturday, January 5, 2013 6:49:23 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Hi Wabbit, and to anyone else... i am trying but i cannot figure it out. : (

the Chart is doing what i want but i cannot get it into a code.

So do you mind if i ask you again?

at least i copied something, deleted something *haha* and now it is close to that what it should do! but... yeah..

at least, i describe it now, and if i find out how to upload a picture = ) you´ll get a screen shot.

it should work like building a pyramide into the trend.

i have the "5 green buy arrows" in the chart (dont ask me how i did that),

and i have at least one EXIT sign (as long the close is above whatever, the Mov(C, 50, W) i guess. when the close is below this MA, then i have 20 exit signs.

the problem now is, i cannot use your code, because then i have all time

enter, exit, enter, exit, enter, exit (u know the flip.flop).

now i just want to have the entry criteria, with always a green buy arrow in the expert,

and only ONE EXIT symbol if the final criteria matches.

yeah... i tried but then i have at least 10 green arrows (on every bar, when it is true) and

or 100 exit signs...

so in the Picture, ... i just want every time a buy arrow, but only ONE exit sign.

the new "entry" criteria was, when O < SAR(). and when it is above SAR BUY again.

but with the code, there will always be an EXIT sign (and i do not need this) just the re-entry symbol.

HyperionAUT  
#10 Posted : Saturday, January 5, 2013 6:52:19 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

In Expert Advisor:

Buy with your creteria from the MY TRADING SYSTEM Code:

{LongEntry Symbol}
Z:=Fml("MY_TRADING_SYSTEM");
Z=1 AND Ref(Z,-1)<>1;

BUT the NEW EXIT which should only occur ONCE.

(it does as long the C is above the MA 50, i guess? hu?)


x:=1;
type:=1;
depth:=1;
pds:=5;
xHi:=If(x=1,H,C);
xLo:=If(x=1,L,C);
Hi:=(HHV(xHi,pds-1)>xHi)>Ref(HHV(xHi,pds-1)>xHi,-1);
HiVal1:=ValueWhen(1,Hi,Ref(xHi,-1));
Lo:=(LLV(xLo,pds-1)<xLo)>Ref(LLV(xLo,pds-1)<xLo,-1);
LoVal1:=ValueWhen(1,Lo,Ref(xLo,-1));

Hi:=Hi AND HiVal1>LoVal1*(1+depth/100);
Lo:=Lo AND LoVal1<HiVal1*(1-depth/100);
supp:=ValueWhen(1,Lo,Ref(xLo,-1));
res:=ValueWhen(1,Hi,Ref(xHi,-1));
comb:=If(BarsSince(Hi)<BarsSince(Lo),res,supp);
suppH:=Trough(1,xLo,depth);
supp:=If(type=1,supp, suppH);

If(C < supp, 1,0);

HyperionAUT  
#11 Posted : Saturday, January 5, 2013 6:58:54 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

No Clue with the Picture Upload in this forum?!?!?!

UserPostedImage

So here you can see that it luckily worked once, and this is my question.

Is it possible to have many entry arrows, but only one exit sign in the expert advisor?

so at least when the close is below (in the MY TRADING SYSTEM it will be the SHORT criteria which are fullfilled) that there is also a lot of Entry short signals, but only ONE EXIT sign?

for this chat i deleted the SHORT SELLING criterias in the expert advisor, it would be much more difficult. Hell yeah!

Sorry for the wall of text!

wabbit  
#12 Posted : Sunday, January 6, 2013 7:34:10 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)
Again, you raise more points than I feel like working through, but let's start with some basics first.

1. When you post other people's code, leave their notices intact, they give credit where is credit is due and also provide valuable information about the functions themselves. Your code was originally written by Jose Silva in 2004.

2. Had you left the formula comments intact, you'd notice the author specifically mentions the use of hindsight based functions, i.e. Peak() and Trough() and these CANNOT be used in real life trading to produce trading signals on the very last bar of the chart. There are many hundreds of posts on the forum explaining this and also in the MS User Manual.

3. Get your logic straight. Instead of sitting in front of the computer jamming code together and hoping something magically goes right, take some time away from the computer to get your trading logic mapped out, on paper is a good way to start. At the moment, you have pyramid entry points based on exit criteria which aren't exit criteria and exits which are not part of the latched trading logic (although at the moment the exits are hindsight based so need to be changed anyway). Although you have some very expensive software, forget it for now and start with pencil and paper to get your logic right before you attempt to code anything.

That'll do for now...

Please read your MS User Manual (or re-read it if you think you have already read it).



wabbit [:D]

HyperionAUT  
#13 Posted : Monday, January 7, 2013 4:28:56 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Hi, okay thanks for the information. I do it (read, pencil, etc), and I mentioned Jose now at the start of the threat, sorry and thanks a lot for your time and help man!

henry1224  
#14 Posted : Monday, January 7, 2013 11:07:14 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)
dear Hype, to post charts, save them as gif files, upload them to imgur.com, then use the url procedure under wabbit's profile to post them here

HyperionAUT  
#15 Posted : Tuesday, January 8, 2013 9:57:21 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Thanks henry, you are right! Cool stuff :)
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.