mrsic8
 ( 9.50% )
- ago
Hello,

can someone help me. I'd like to start with just the entry position, but it doesn't actually do what I'd like.

I'd like to get in after the SROC falls at -20. But I am getting in, after "StartIndex." I thought it couldn't be that difficult.

CODE:
using finantic.Indicators; using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; namespace WealthLab8Training { public class srocLong : UserStrategyBase { public srocLong() { AddParameter("PeriodSROC", ParameterType.Int32, 15, 2, 100, 2); AddParameter("DownPercentage", ParameterType.Double, 16, 2, 32, 2); } public override void Initialize(BarHistory bars) { _indicator = new SROC(bars.Close, Parameters[0].AsInt); PlotIndicator(_indicator, WLColor.Black, PlotStyle.ThickLine); StartIndex = 50; } public override void Execute(BarHistory bars, int idx) { // _enterShort = _indicator[idx] >= Parameters[1].AsDouble; { if (!HasOpenPosition(bars, PositionType.Long)) { if (_indicator < -20 != null) { PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, 0, "BuyAtMarket"); } } } } private IndicatorBase _indicator; private bool _enterShort; } }

0
530
Solved
7 Replies

Reply

Bookmark

Sort
- ago
#1
CODE:
//if (_indicator < -20 != null) if (_indicator[idx] < -20 != null)
0
mrsic8
 ( 9.50% )
- ago
#2
Hello Eugene,

nothing change.
0
- ago
#3
Oh gosh, I focused on the left comparison and overlooked the right part of the "equation" which makes the whole line totally erroneous. This is how it should be:
CODE:
if (_indicator[idx] < -20)

There are so many examples of what you're trying to do i.e. access the value of an indicator at given index (bar), even bundled with WL8. Check them out.
1
mrsic8
 ( 9.50% )
- ago
#4
Thanks.
0
mrsic8
 ( 9.50% )
- ago
#5
Hello,
I am trying converting positive double into negativ. It says
0: Parameter Increment must be greater than zero.
CODE:
AddParameter("DownPercentage", ParameterType.Double, -20, -2, -32, -2);


Than I did try this one: Error: Nothing happens.
CODE:
if (_indicator[idx] < -Parameters[1].AsDouble)


Can anyone give me a hint how to convert AddParameter to negative?

0
Glitch8
 ( 10.94% )
- ago
#6
This should do the trick ...

CODE:
AddParameter("DownPercentage", ParameterType.Double, -20, -32, -2, 2);
1
Best Answer
mrsic8
 ( 9.50% )
- ago
#7
Hello Glitch,

trick works fine. Thanks.
0

Reply

Bookmark

Sort