Profit Target is not valid until the 3rd day
Author: Gunny
Creation Date: 2/17/2015 3:20 PM
profile picture

Gunny

#1
I`ve a problem with the profit target. I`ve opened a position at the open price and have a profit target at x%. The normal exit is time based. I don`t have a aditional stop order. The problem with the profit target is, that it is not valid until the 3rd day. What can I do, that the profit target will be valid from the first day on?
profile picture

Eugene

#2
Let's start by saying that a profit target may be active from the first day only if the entry was made at market open (i.e. not using an AtStop/AtLimit order). Otherwise the profit target is valid on the next day. It is discussed in this FAQ: I want to test a strategy that buys and sells with stop/limit orders on the same bar.

Note that both the entry and exit bars count in "Bars Held" to arrive at the most pessimistic "profit per bar" possible. For example, if your system exited a Position on the next open after entry will be held for 2 bars (not 1). Don't be confused into thinking that a Position is being held longer than it should.

If you want further troubleshooting, please show us the code.
profile picture

Gunny

#3
Hello Eugene,

my example code is following (it`s from the rule wizard):

CODE:
Please log in to see this code.



I tried a changing from "SellAtMarket(bar + 1, p, "Group1")" to "SellAtMarket(bar, p, "Group1")", but it doesn`t give the solution.
profile picture

Eugene

#4
The code is correct and like I supposed, the notion re: "valid until 3rd day" is untrue. The profit target comes into play starting on the next day after entry (day 2) which is by design of the rule wizard and the "single-position strategy template". (However, the time-based exit makes impossible for the AtLimit order to activate.)

Here's a tweak that allows the profit target to be active starting from entry date:

CODE:
Please log in to see this code.


QUOTE:
I tried a changing from "SellAtMarket(bar + 1, p, "Group1")" to "SellAtMarket(bar, p, "Group1")", but it doesn`t give the solution.


Not only it will not give a solution but in fact will introduce a separate problem called "peeking into the future". For more details please see the WealthScript Programming Guide > Programming Trading Strategies > Peeking.
profile picture

Gunny

#5
@Eugene: Thank you very much for the code!
profile picture

Gunny

#6
@Eugene: The 3rd day was a mistake. The first day is correct.
I`ve a little problem to implement the code in other systems.
Could you please give me a second tweak example with this simple code:

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

Eugene

#7
This will be a little DIY project for you. Here's the new entry condition:
CODE:
Please log in to see this code.

Take my code above and place this snippet by analogy. It's easy.

CODE:
Please log in to see this code.

P.S. I suggest to rename one of these strings to make them unique:
CODE:
Please log in to see this code.

To avoid some potential issue, it's best that parameter labels do not duplicate each other.
profile picture

Gunny

#8
@Eugene: Thank you very much!
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).