- ago
hi, i am trying to following in block:
if close above 2 atr + entry price , then start a trail stop.

but i do not not how to quote entry price.

so is there any way to quote position price information like entry price, last entry price in active trade?

thanks.
0
293
Solved
8 Replies

Reply

Bookmark

Sort
- ago
#1
The Position object returns EntryPrice and related properties:
https://www.wealth-lab.com/Support/ApiReference/Position
0
Cone8
 ( 5.94% )
- ago
#2
You need a new condition similar to PowerPack's Price Compare to Entry Bar that:

1. Compares Indicators (not PriceComponents)...
2. on and each bar after the Entry Bar (not just on the Entry Bar),
3. and importantly, once triggered, always returns true.

Pretty simple with a C# Strategy, but if you need it as a block:
1. We can mark this as Feature Request, or,
2. Concierge Service
0
Best Answer
Cone8
 ( 5.94% )
- ago
#3
Here's an example for a C# Strategy -

CODE:
: : else //exit logic {    Position p = LastPosition;    if (idx - p.EntryBar + 1 > 100)       ClosePosition(p, OrderType.Market, 0, "Time Based");    else    {       //if close above 2 atr + entry price , then start a trail stop.       double mfePts = Highest.Value(idx, bars.Close, idx - p.EntryBar + 1);       if (mfePts > 2 * ATR.Series(bars, 10)[p.EntryBar] + p.EntryPrice)          CloseAtTrailingStop(p, TrailingStopType.PercentHL, 2.0, "2% TStop");    } }
0
- ago
#4
I would definitely vote for this as a building block feature. I think it's an important feature need
0
- ago
#5
i am learning C#, but since i do not have coding background, it will be more questions than using block.

since the position price information is quite useful in strategy building, i hope this feature can be added to .

thanks, guys.
0
Cone8
 ( 5.94% )
- ago
#6
Let's think of a different title for the feature request and make sure the code is doing what you expect.

1. The code above finds the Highest Closing price since and including the entry bar. Generalizing, it could be any indicator and could be Lowest for short positions.

2. It compares the result from #1 to a price level calculated by an indicator's value on the entry bar, ATR(10), added to the entry price. However...

a. It doesn't make sense to add (or subtract) all indicators from the entry price (e.g., any moving average), so that could be optional.

b. Maybe also, you want to compare the value of the indicator at some point after the entry bar. The max value? min value? long/short?

If we're going to add a blocks, requirements like these need to be defined in a generalized manner to have the most impact.
0
- ago
#7
thanks Cone,

i think maybe can create some basic price block to give traders more freedom, like:

1. last entry price
2.average entry price
3.current equtiy
4.current net profit
5.count of entrys

just FYI
0
Cone8
 ( 5.94% )
- ago
#8
Those are off-topic (but several are already available in the PowerPack).
This discussion is limited to defining one condition block that remains true after a price attains "some level" after a position's entry bar.

Here's my current thinking -
Block Title: Price Crossed Entry Price Op Indicator

Parameters:
- Indicator_1 (e.g., Close, High, EMA, etc.)
- Crossed Above/Below
- Indicator_2
- Math Op (optionally applied to Entry Price)

The Math Op optionally adds, subtracts, multiplies, or divides a Position's Entry Price with/by Indicator_2. The result is compared to Indicator_1. If Ind_1 obtains/crosses the other level, it remains true until the position exit.

A second rule would would Math Op a Value instead of Indicator_2 to the Entry Price. e.g., Entry Price * 1.05 to define a 5% level above the entry price.


0

Reply

Bookmark

Sort