Short on cross under of WMA
Author: Mats
Creation Date: 8/25/2008 6:16 PM
profile picture

Mats

#1
Noticed all the nice info about C# on the forum, but for my simple scripts I probably would learn more by seeing my own scripts getting converted. So, anyone who takes this?

Regards
Mats

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Not very much different, isn't it?
CODE:
Please log in to see this code.
profile picture

Mats

#3
Thanks a lot Eugene. It's absolutely understandable, not that big difference.

This is the only part I don't understand that well. The script is for second, should that matter?

CODE:
Please log in to see this code.
profile picture

Eugene

#4
Mats, in its present state your script does not show anything specific to seconds. If for some reason you decide to compare dates with seconds (e.g. if GetTime(bar) > 150030... ), then just modify the function to honor seconds:

CODE:
Please log in to see this code.
profile picture

Mats

#5
aha, that's what it was. What does these two mean?
Thanks for the feedback :-)

CODE:
Please log in to see this code.
profile picture

Eugene

#6
QUOTE:
aha, that's what it was. What does these two mean?

That's C#.

A class (here called "Mats") of type WealthScript is a group of methods, functions and variables, related to a C# trading strategy.

Execute() is the main point of entry of a Strategy in WealthScrpt, equal to procedure Main() in a C# program.

Classes is a huge topic, therefore it's best to pick a free .NET/C# book from the list below:

Net Books
Pro C# & .Net 3.5
.Net Book Zero
C# CodeNotes
C# Tutorial 1
C# Tutorial 2
C# Tutorial 3

Keep in mind that you don't have to be proficient in C# to build strategies. After acquiring basic knowledge of syntax and concepts, see QuickRef and the WealthScript Programming Guide, compare the old and new examples, and feel the difference.
profile picture

Mats

#7
Exactly :-) I look forward to getting the feeling. Are there many days left for the 5.0 for non US now?
profile picture

Eugene

#8
QUOTE:
Are there many days left for the 5.0 for non US now?
Currently we believe that, according to the Wealth-Lab Wiki main page, it's going to happen today:Wealth-Lab News
profile picture

Mats

#9
oh, I see, looking forward to it. Thanks for the help today :-)
profile picture

ChrisM

#10
Unfortunately Wealthlab Developer 5.1 is still (27 Aug) not purchasable or downloadable from the wealth-lab website.
profile picture

Cone

#11
It's "released", but it's up to the webmaster to post it. "Purchase", however, will still be delayed several more days, but that won't affect use of the product since the first 30-days are free anyway.
profile picture

Mats

#12
Mr Webmaster, please post it, hardly can't wait.... :-)
profile picture

Mats

#13
just so I know when I test it, will the WL5 take advantage of all cpus( like 4*100% if Quad) maximum by itself without any settings?
profile picture

Eugene

#14
Yes.
profile picture

Cone

#15
The Webmaster has come through again... let the downloads begin!
profile picture

Mats

#16
Superb, here we go!
profile picture

Mats

#17
How do I OR "TradingSessionMidday" to TradingSessionOpen?



if( TradingSessionOpen & CrossUnder( bar, wma1, wma3 ) ) ShortAtMarket( bar+1, "Short");
profile picture

Eugene

#18
QUOTE:
How do I OR "TradingSessionMidday" to TradingSessionOpen?

The equivalent operator in C# is | (or ||) -- please see reply above from 8/26/2008 7:54 AM for some tutorial links.
CODE:
Please log in to see this code.
profile picture

Mats

#19
this worked, thanks

if((TradingSessionOpen||TradingSessionMidday||TradingSessionClose ) &
CrossUnder( bar, wma1, wma3 ) )
ShortAtMarket( bar+1, "Short");

Another thing, I tested the WL4 vs WL5 with same script, and it came out 5 trades more of 500 and 0,1% different profit. I'm sure the script is the same. Is this to be counted as normal?
profile picture

Eugene

#20
QUOTE:
Another thing, I tested the WL4 vs WL5 with same script, and it came out 5 trades more of 500 and 0,1% different profit. I'm sure the script is the same. Is this to be counted as normal?


Yes, sometimes.

1. For stop or limit orders, tick adjustment is slightly different than in WLD4.
2. For market orders in portfolio simulation mode, you should assign priority to a position because when trades are rejected due to lack of capital, the new truly random priorities for positions come in play (refer to Strategy Window > Backtesting Strategies > How Trades Are Chosen in the User Guide for more details).
profile picture

Cone

#21
Other likely culprits:

1. Did you use the same data (exactly the same)?
2. Same Options / Preferences?
3. Turn off all $imulator options?
profile picture

Mats

#22
This should all be the same Yes. I will take a deeper look at it this weekend, gowing troutfishing now :-)
profile picture

Mats

#23
obs... guess You are adding a delete function soon too
profile picture

Eugene

#24
Yes ;)
profile picture

Mats

#25
Is there a optimization function in WL5?
profile picture

Eugene

#26
The functionality is rolled out in phases, so optimization is something I'd expect in a future release.

For now we're bound to interactive optimization using Parameter Sliders.
profile picture

Mats

#27
oki, thanks :-)

profile picture

warren631

#28
I just upgraded to WL5. Where do I start to learn the new coding? I have a trusted function in WL4 that I need to convert that uses floats for a MACD (such as 35.0 and 35.005) which seems to give me a better indicator than the regular MACD. Does the new WL5 allow custom functions?

Anyone willing to save me some time on convertion?

CODE:
Please log in to see this code.
profile picture

Cone

#29
Start with the WealthScript Programming Guide. It gives lots of examples.
profile picture

Eugene

#30
QUOTE:
Does the new WL5 allow custom functions?

Yes. Many custom indicator open source code available in our WL5 Wiki.
QUOTE:
Anyone willing to save me some time on convertion?

Here it goes. Keep in mind there is more than one way to skin a cat, so these indicators can be compiled and then appear as a regular item on the Indicators list, allowing itself to be selected in Rule-based strategies and included in any code-based strategies. But for starters it should suffice.
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).