Stop Exit combined with time based exit
Author: traindl
Creation Date: 8/19/2012 6:33 AM
profile picture

traindl

#1
Hello Guys,

hope you can help me ... there must be a failure in my code.

I just wanted to exit a long position after a random entry criteria either at a stop loss level at 2% from entry or if this stop never get triggered after 3 days in market (sell at close) time based exit.

every time when i try to run the strategy following error appears "Runtime error: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. bei WealthLab.Strategies.MyStrategy.Execute()

and also only 2 trades were done in 15 years backtest. !?

i will attach my coding.... hope you can help me.

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

Eugene

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

Eugene

#3
P.S. A couple of notes:

#1 - The stop and limit orders were peeking into the future (corrected).
#2 - You might want to check out the WealthScript Programming Guide, Programming Trading Strategies > Peeking > Order of Trading Signals.
profile picture

traindl

#4
Hi Eugene,

thanks for quick info... i will check that programming guide... only one thing left...

what if i want the same also on short side ....
so both on long and short side , stop loss 2% or time based exit either what triggers before ?

thanks so much
profile picture

Eugene

#5
Hi Thomas,

Then I guess it would be like this:
CODE:
Please log in to see this code.

QUOTE:
so both on long and short side , stop loss 2% or time based exit either what triggers before ?

Time-based exit - being a marketable/AtClose order - would trigger before AtStop.
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).