- ago
Hi guys,

Is it possible to develop a feature where the profit target/profit loss is X times the size of the trigger/entry candle?

Tyvm!
2
715
Solved
9 Replies

Reply

Bookmark

Sort
- ago
#1
You are going to wait a long time before this feature request gets enough votes to be implemented. What I would do instead is have your strategy calculate this value at the time the position is sold, then assign that value to the Position object (during that sale) using the SetMetric property. Lookup the Position object in the QuickRef, then read about its SetMetric property.

Custom metrics like this will show up in the Analysis Series visualizer and the Position Metrics report.

Let me add that custom metrics are usually assigned at the Transaction Buy point using SetPositionMetric (see the QuickRef for Transaction), but it this case all the stats may not be available until the position is sold, so this latter approach may not be an option here.
0
Glitch8
 ( 10.62% )
- ago
#2
It's pretty easy to accomplish in a C# coded Strategy:

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          r = RSI.Series(bars.Close, 14);          PlotIndicator(r);          PlotStopsAndLimits(); } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) {             //code your buy conditions here             if (r[idx] < 40)             {                PlaceTrade(bars, TransactionType.Buy, OrderType.Market);                barRange = bars.High[idx] - bars.Low[idx];             } } else {             //sell at N times the range of the signal bar (change 3 to whatever factor you want)             Position pos = LastOpenPosition;             PlaceTrade(bars, TransactionType.Sell, OrderType.Stop, pos.EntryPrice - barRange * 3);             PlaceTrade(bars, TransactionType.Sell, OrderType.Limit, pos.EntryPrice + barRange * 3); } }       //declare private variables below       private RSI r;       private double barRange; } }
0
Best Answer
- ago
#3
Oops, I thought he wanted to "track and record" what the selling value would be in Reply# 1. Sorry for the confusion.
0
- ago
#4
QUOTE:
Is it possible to develop a feature where the profit target/profit loss is X times the size of the trigger/entry candle?

This idea is becoming popular. As said in Post #4, we could expand the "Sell/Cover at Profit Target/Stop Loss" block:

2x profit of entry bar size, 1x stop loss the entry bar size

@fmaggioni, don't forget to vote for your own request by giving it a thumbs up on the Wishlist page (click).
0
- ago
#5
I'm not very good at coding, so I guess I'll have to wait until the building block is created.

Thank you very much guys!
0
- ago
#6
Added to PowerPack B15
https://www.wealth-lab.com/extension/detail/PowerPack#changeLog
1
- ago
#7
Hi guys! Just to say thank you for this addition to Wealth-Lab, it works great and it will help me tremendously!
2
Cone8
 ( 4.98% )
- ago
#8
Hi fmaggioni,
I just took quick a look at the rule, and I don't think it's programmed correctly for the blocks. (Glitch got it right above though.) I'll call it a bug and we'll investigate and fix.
1
- ago
#9
Awesome, thanks for the heads up!
0

Reply

Bookmark

Sort