- ago
Hello, I would like to know a way to set the target to be twice the distance from the stop to the entry point. I'm not finding any way to do this
at the Building Blocks. as in the example.
0
331
Solved
3 Replies

Reply

Bookmark

Sort
Glitch8
 ( 8.70% )
- ago
#1
What Building Block is the stop loss based on?
0
Cone8
 ( 12.32% )
- ago
#2
Glitch, it's this one -


joao - which of those bars is the signal bar? (The entry would be the next bar.) It looks like you indicated that the entry occurred on the open of the bar before the bar identified as the stop.

The limitation of the rule is that you need to find an indicator that has the price you need on or before the entry bar. Although you can do this easily with C# code, it could be challenging to find way to do that with this building block.
0
Glitch8
 ( 8.70% )
- ago
#3
Something like this is very easy to do in code, here's a minimal example:

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) {          rsi14 = RSI.Series(bars.Close, 14);          rsi14.MassageColors = true;          lowest = Lowest.Series(bars.Low, 5);          lowest.MassageColors = true;          PlotIndicator(rsi14);          PlotIndicator(lowest);          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 (rsi14[idx] < 30)             {                PlaceTrade(bars, TransactionType.Buy, OrderType.Market);                stop = lowest[idx];             } } else {             //code your sell conditions here                   double diff = LastOpenPosition.EntryPrice - stop;             target = LastOpenPosition.EntryPrice + diff * 2.0;             PlaceTrade(bars, TransactionType.Sell, OrderType.Stop, stop);             PlaceTrade(bars, TransactionType.Sell, OrderType.Limit, target); } }       //declare private variables below       private RSI rsi14;       private Lowest lowest;       private double stop;       private double target; } }
0
Best Answer

Reply

Bookmark

Sort