Code not executing as designed/intended
Author: romaioi
Creation Date: 3/14/2012 8:00 AM
profile picture

romaioi

#1
Hi, I'm hoping someone could point out what I am doing wrong with this code. I'm going back to basics with my coding (3 years no practice) and the example below was converted from WL4 language to WL6 using the translator app.

The intention of this code is simply to observe a short term pull back (using the CumDown function), allow up to 15 days to pass before another condition is met (using the metastock derived approach via the "barover1" counter - I can't think of anything else) and then buy on a moving average crossover. However, this script compiles but never executes any trades alerts. It seams to stop counting forward at the end of the CumDown period.

I have tried putting this together in a few subtly different ways, but in those cases it simply traded on every moving average cross without taking into account the cumdown condition. Can anyone offer any suggestions?


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

Eugene

#2
Below is an example demonstrating the application of a design pattern that you'd use to delay an action (i.e. up to 15 days to pass before another condition is met). I attached a simple exit after a number of bars:
CODE:
Please log in to see this code.
profile picture

romaioi

#3
Thanks Eugene, for the code and the link. I'll give that a shot. Much appreciated.
profile picture

Cone

#4
Seems like the following should be sufficient without the use of all the booleans, but the results are different.. homework for you!

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

Eugene

#5
This should produce closer results - implements romaioi's exits:
CODE:
Please log in to see this code.
profile picture

romaioi

#6
the amount I still have to learn is depressing ;)

In some of my subtly different coding attempts I tried the using "setup" approach but slightly differently, with the same result as my other attempts.

Thanks for the help guys.

One aspect I do not understand about the code is: why is the background being set to red after a trade takes place? The way I read the code is that it should turn red once the CumDown condition is met, before the trade.
profile picture

Eugene

#7
The code continues to evaluate all the time because this is a multi-position Strategy, so there can be several open positions.
profile picture

Digger

#8
Hope someone can help -
I have converted WLD4 to WLD6 using WSTL but getting different exit outcomes after the translation.
WLD4 exit is:
CODE:
Please log in to see this code.


The WSTL converts to (with some cosmetics script in middle) :

CODE:
Please log in to see this code.

Hope there is enough information here to find the answer. I have omitted the cosmetics from the WLD4 script because I know how to. My C# skills are almost nil.
Digger
profile picture

Eugene

#9
From what I can tell, LATR is a double but is being treated as an integer by WSTL. So instead of 0.8 this will get you a 0. Try changing this line:
CODE:
Please log in to see this code.

This way:
CODE:
Please log in to see this code.


Find the LATR definition in your undisclosed code and if it's defined as integer, remove that variable from definitions.

We might need to see more relevant strings if that doesn't resolve the problem.

Also, for a realistic version to version comparison please try importing the WL4 source using WL4Files provider and choose precisely the same data loading settings and precision (number of decimals in the Preferences).
profile picture

Digger

#10
Thanks Eugene,
I've included a little more script and included your suggestion (see below), however I get the following error message:
"Operator "/" cannot be applied to operands of type 'WealthLab.StrategyParameter' and 'double'

CODE:
Please log in to see this code.

I await the response of your learned mind!!
profile picture

Eugene

#11
Sorry John, this was a typo caused by on-the-fly coding. Now that I see the translated output, disregard removing the the LATR definition and simply try this instead:

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

Digger

#12
Eugene,
Thank you.
Digger
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).