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

Notification

Icon
Error

Options
Go to last post Go to first unread
analias  
#1 Posted : Tuesday, August 4, 2009 1:54:00 PM(UTC)
analias

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 5/22/2009(UTC)
Posts: 9

When I put any of functions starting with "Simulation...", System Tester shows all simulation results as 0s. Why?

Thanks..

This is a result of the normally working simple system simulation. When I put any of the "Simulation..." functions (Simulation.CurrentPositionAge or Simulation.CurrentPositionValue) in any of the order codes, the result becomes all 0s, no position is taken:

Simulation Date 04.08.2009 22:53:01 0 15 Minute Bars 00.00.0000 00:00 Through 00.00.0000 00:00 (0 Days) Points Only Test
Performance Profit 0.0000 Pts Performance N/A Annualized Performance N/A Buy & Hold Profit 0.0000 Pts Buy & Hold Performance N/A Buy & Hold Annualized Performance N/A

Trade Summary Total Trades 0 Trade Efficiency 0.00 % Average Profit/Average Loss N/A

Profitable Trades Total 0 Long 0 Short 0

Average Profit 0.0000 Pts Highest Profit 0.0000 Pts Lowest Profit 0.0000 Pts Most Consecutive 0

Unprofitable Trades Total 0 Long 0 Short 0

Average Loss 0.0000 Pts Highest Loss 0.0000 Pts Lowest Loss 0.0000 Pts Most Consecutive 0

Maximum Position Excursions Long Favorable 0.0000 Pts Short Favorable 0.0000 Pts Long Adverse 0.0000 Pts Short Adverse 0.0000 Pts

Trade Efficiency Average Entry 0.00 % Average Exit 0.00 % Average Total 0.00 %

Average Long Entry 0.00 % Average Long Exit 0.00 % Average Long Total 0.00 %

Average Short Entry 0.00 % Average Short Exit 0.00 % Average Short Total 0.00 %

Performance Indices Buy & Hold Index 0.00 % Profit/Loss Index 0.00 % Reward/Risk Index 0.00 %

Accounting Initial Equity 0.0000 Pts Trade Profit 0.0000 Pts Trade Loss 0.0000 Pts Commissions 0.0000 Pts Interest Credited 0.0000 Pts Interest Charged 0.0000 Pts Final Equity 0.0000 Pts Open Positions 0.0000 Pts

Account Variation Highest Account Balance 0.0000 Pts Lowest Account Balance 0.0000 Pts Highest Portfolio Value 0.0000 Pts Highest Open Drawdown 0.0000 Pts Highest Closed Drawdown 0.0000 Pts

Account Events Margin Calls 0 Overdrafts 0

Profitable Timing Average Trade Length 0 Longest Trade Length 0 Shortest Trade Length 0 Total Trade Length 0

Unprofitable Timing Average Trade Length 0 Longest Trade Length 0 Shortest Trade Length 0 Total Trade Length 0

Out of Market Timing Average 0 Longest 0 Total 0


Justin  
#2 Posted : Tuesday, August 4, 2009 2:26:10 PM(UTC)
Justin

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/13/2004(UTC)
Posts: 673
Location: Salt Lake City, UT

It would depend on the formula, where you're using the formula, and whether the data meets the criteria. For starters, unless you are in a current position, any "simulation.currentposition" would likely fail. You may want to use them for your Exit criteria, not your Entry criteria.
analias  
#3 Posted : Tuesday, August 4, 2009 2:38:36 PM(UTC)
analias

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 5/22/2009(UTC)
Posts: 9

First of all, thank you.

Actually, I have found codes on the forum by searching and put them as they are. System Tester did not work. For instance, as simple as this code: Simulation.CurrentPositionAge >= 3. When I put this into Buy to Cover Order, the simulation which is normally working became not working. If you can give me a piece of code to try, I can try and reply back with the results.

Lastly, what about this?
If(Simulation.CurrentPositionValue IS NOT NULL ?,Simulation.CurrentPositionValue=Simulation.CurrentPositionValue,Simulation.CurrentPositionValue=0);
IF(Close>=Simulation.CurrentPositionValue, ATR StopLoss Condition Comes Here, Normal Position (Buy or Sell) Condition Comes Here)

Justin, thank you again.

I have also found ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN) on the forum and tried the following as an Sell Order:
ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN)<=ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN)-ATR(20)
It did not work at all.
Justin  
#4 Posted : Tuesday, August 4, 2009 5:07:29 PM(UTC)
Justin

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/13/2004(UTC)
Posts: 673
Location: Salt Lake City, UT

I just did a quick test using simple entry criteria:

{Buy Order}
C > Mov(C,30,E)

{Sell Order}

Simulation.CurrentPositionAge >= 3

{Sell Short Order}
C < Mov(C,30,E)

{Buy to Cover Order}

Simulation.CurrentPositionAge >= 3

I was able to get plenty of results testing this on Alcoa. As to your other statements, there is no way to reference NULL or NOT NULL in the MetaStock formula language, unfortunately.

Also, you cannot define a variable like that (inside of an IF statement), although it is possible that statement could be written a different way to accomplish the same goal.
analias  
#5 Posted : Wednesday, August 5, 2009 7:27:06 AM(UTC)
analias

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 5/22/2009(UTC)
Posts: 9

Justin, thank you so much. I have got the idea of "Simulation" functions and the code you have given worked. Thank you.

I have just another easy question for you (I hope so). How can I tell MetaStock that SIGNAL ONLY when the following conditions met for the FIRST TIME after the previous -opposite- signal?
A>=B
AND
C<=D
AND
E>=F

Trying to prevent continuous signals because the conditions may be met several times.

Thank you again.
Justin  
#6 Posted : Wednesday, August 5, 2009 10:50:40 AM(UTC)
Justin

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/13/2004(UTC)
Posts: 673
Location: Salt Lake City, UT

You can use the following formulas as examples of how to set something like this up. Use 2-state when you have 1 entry and 1 exit, long or short. Use 3-state if you have separate entry criteria than exit criteria. The BC, SC, BE, SE (Buy Condition, Sell Condition, Buy Exit, Sell Exit) variables are to be defined by you. Replace the formulas with your own.

2 state:

bc:=Cross(C,Mov(C,20,S)){buy signal condition};
sc:=Cross(Mov(C,20,S),C){sell signal condition};
trade:=If( bc=1, 1, If(sc=1, 0, PREV));
cross( trade= x, 0.5)


3 state:

bc:=C > Mov(C,20,S)+1{enter long condition};
be:=Cross(Mov(C,20,S),C){close long condition};
sc:=C < Mov(C,20,S)-1{enter short condition};
se:=Cross(C,Mov(C,20,S)){close short condition};
trade:=If( bc=1, 1, If(sc=1, -1, If((be AND PREV=1)
OR (se AND PREV=-1),0,PREV)));
Cross( trade= x, 0.5)

You will need to change the Trade=X, in the above formulas to Trade= 1, Trade= -1, or Trade= 0, depending on the condition you are defining.
analias  
#7 Posted : Wednesday, August 5, 2009 1:34:22 PM(UTC)
analias

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 5/22/2009(UTC)
Posts: 9

Justin,

Thank you.

However, in "2 state" condition for instance, bc only returns "1" at the intersection point. However at that point other conditions have not been met yet. I want MetaStock to signal when all conditions first time met. For instance;

bc:=Cross(C,Mov(C,20,S)){buy signal condition};
sc:=Cross(Mov(C,20,S),C){sell signal condition};
trade:=If( bc=1, 1, If(sc=1, 0, PREV));
cross( trade= x, 0.5)
when(a>=b)

Now it is 05.08.2009 bar number 10: Close crosses over Mov(C,20,S) which means bc=1 however a is still below b so there is no signal produced.

Now it is 05.08.2009 bar number 11: Close is no longer crossing Mov(C,20,S) (Close is now above it) which means bc=0 and a is now above b (a>=b is true) so there is no signal produced.

Now it is 05.08.2009 bar number 12: Close is no longer crossing Mov(C,20,S) (Close is now above it) which means bc=0 and a is still above b (a>=b is true) so there is no signal produced.

Now it is 05.08.2009 bar number 13: Close is no longer crossing Mov(C,20,S) (Close is now above it) which means bc=0 and a is still above b (a>=b is true) so there is no signal produced.


If I convert the code into the following:
bc:=C>=Mov(C,20,S){buy signal condition};
sc:=Mov(C,20,S)>=C{sell signal condition};
trade:=If( bc=1, 1, If(sc=1, 0, PREV));
cross( trade= x, 0.5)
when(a>=b)

Now it is 05.08.2009 bar number 10: Close crosses over Mov(C,20,S) which means bc=1 however a is still below b so there is no signal produced.

Now it is 05.08.2009 bar number 11: Close is no longer crossing Mov(C,20,S) (Close is now above it) which means bc=1 and a is now above b (a>=b is true) so there is signal produced.

Now it is 05.08.2009 bar number 12: Close is no longer crossing Mov(C,20,S) (Close is now above it) which means bc=1 and a is still above b (a>=b is true) so there is signal produced.

Now it is 05.08.2009 bar number 13: Close is no longer crossing Mov(C,20,S) (Close is now above it) which means bc=1 and a is still above b (a>=b is true) so there is signal produced.

I want only the signal at the 11th bar to be produced and no more, it is time all the conditions are FIRST met. Isn't is possible?

P.S.:
1. Why 0.5 in the following?: cross( trade= x, 0.5)
2. I have read the PREV function in the manual, however, what is the following one referring to?: trade:=If( bc=1, 1, If(sc=1, 0, PREV));
3. Is there any sources about this programming language other than the official manual?

Thank you so much. I appreciate your help very much.
oztrader  
#8 Posted : Wednesday, August 5, 2009 7:35:53 PM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Analias,

Probably using the Forum.Dll will solve your problem.

The links below are for both the Dll and the manual:-

http://forum.equis.com/files/3018/programming_files/entry19695.aspx

http://forum.equis.com/files/3018/programming_files/entry19696.aspx

When the downloads are completed I would suggest a quick read of

1) Latch or Flip Flop Function

If you run a search on “latches” over the entire Equis Forum you will also find some good info.

oz

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.