Crazy with the code
Author: PaoloPaolo
Creation Date: 8/25/2009 7:35 AM
profile picture

PaoloPaolo

#1
First of all WL5 script seems to be more complex to be programmed compared to WL4.
Does it is possible to continue programming using WL4 script language also inside WL5?

Second, I don't undersand why changing SELL to BUY and viceversa, the program buy and sell in different dates.

I put this code:

CODE:
Please log in to see this code.



and then this one

CODE:
Please log in to see this code.



why the program sell in different dates compared to the one they buy in the first case?
I just want to make the inverse.
profile picture

Eugene

#2
QUOTE:
First of all WL5 script seems to be more complex to be programmed compared to WL4.

It only seems so. It's natural for human nature to react this way when we see something really new. Try, for example, to come up with something in WL4 like the code below. It fits one's screen, taking less than 80 lines and having no "$Includes", but does everything from downloading raw historical data to trading using these external data series:
HowTo | Access Internet sites and collect historical data on-the-fly

Your C# code can be as complex as you like (or required by your task), because it's a full-fledged programming language. Please take a look at these tips, hope they'll cut the learning curve for you:
I'm a Wealth-Lab 3/4 user, how to learn C# ?
QUOTE:
Does it is possible to continue programming using WL4 script language also inside WL5?

To a certain extent, yes - when using WealthScript Translator with its WealthScriptTL library. Although we don't endorse or support it, this would be the closest thing to the WL4 syntax, if it's familiar to you (?).
QUOTE:
why the program sell in different dates compared to the one they buy in the first case?
I just want to make the inverse.

Because you're using a stop order. The opposite order (short) doesn't necessarily have to trigger on the same day. It will trigger when its condition is active. A guaranteed order in this case would be AtMarket.
profile picture

PaoloPaolo

#3
Thanks for the reply.
Supposing SellAtStop is the opposite of CoverAtStop (like BuyAtStop is the opposite of ShortAtStop) I supposed everything should work, but unfortunatly not.
What I should write to have the opposite order (short) trigger in the same way?

I mean: if I write "BuyAtStop(bar + 1, H55[bar])" and then "ShortAtStop(bar + 1, H55[bar])" they buy/sell in different days, but the condition is the same, just the order is different (first case "buy" and second case "sell").
What I understand from your answer is that "BuyAtStop" is not the exact contrary of "ShortAtStop" (even if they both have the same parameters), but I cannot find from the quickref any other function I can use: could you please suggest me what should I use to have the exact contrary of BuyAtStop?
profile picture

Eugene

#4
QUOTE:
Supposing SellAtStop is the opposite of CoverAtStop

SellAtStop is not the opposite of CoverAtStop. The condition is different. Just give it a thought and recall how do you place stop orders in real life. If the High of the bar is above "H55[bar]", a buy stop should trigger (assuming enough capital). But if the Low of the bar is not below "H55[bar]", you will not see an order, of course.
QUOTE:
what should I use to have the exact contrary of BuyAtStop?

To ensure one of the orders is going to fire, you'll need to use AtMarket for both these orders. But if I get you right, you're trying to backtest how would the system work if you reverse the rules? If you could tell us what's on your mind, we'll try to suggest a way of getting it done in code.
profile picture

PaoloPaolo

#5
Dear Eugene, thanks again for the fast replay.

To explain better, I have downloaded the demo version of WL5 in order to test this new software (interface it's really better!).

Testing everything around (to discover the software) I load the embedded "channel breakout VT" strategy.
I optimize it on the Dow Jones Index (using a range of the LongChannel and ShortChannel starting from "1" instead of the original margins) and I discover that for LongChannel=1 and ShortChannel=1 the rescult was a loss of 56.589€ (10.000€ commissions) (period: 8 years from now / investment amount: always 1 contract).

I repeat I'm just testing this new WL5, so in my mind I said: if I reverse I must obtain a gain of about 36.000€ (equivalent of 56.000€ - 10.000€ - 10.000€), that's why I inverse the buy/sell condition.

Anyway, it's just an initial test becouse I'm totally not used to WL5, so when I'll go really deeply on it (I hope time will allow it), I think I'll be able to write more complex rules, analysing the intraday max/min and set the exact selling/buying point passed as parameter.

The important point that I understand now is that SellAtStop is not the opposite of CoverAtStop
profile picture

Cone

#6
QUOTE:
SellAtStop is not the opposite of CoverAtStop
Let's be clear about this instead of talking in general terms.

SellAtStop will exit a long position when price moves lower to the stop trigger price.

CoverAtStop will exit a short position when price moves higher to the stop trigger price.


Whether or not you call it "opposite" this is the way these signals work.
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).