- ago
Hi,
Is it possible to create the following system with the Building Blocks?
Thanks in advance for a support.

Buy when the close is below the 20-day moving average of the closes minus the 20-day average true range multiplied by 2.5.
Sell ​​when the opposite is true.

Buy = Close < MA(Close,20) - (ATR(20)*2.5)
Sell ​​= Close > MA(Close,20) + (ATR(20) * 2.5)
0
494
Solved
5 Replies

Reply

Bookmark

Sort
- ago
#1
Yes, it's possible. You're looking for MathIndOp* indicators from the Transformers group. For the Buy side, it should be set up like this:



I leave the Sell side for you to construct, it's simple once you get a handle on this.

P.S. To summarize your question clearly, changed the topic title:

WAS: Question about the building blocks
IS: Buy when Close is above MA +/- ATR factor in Blocks?
0
- ago
#2
perfect help, THANK YOU!
:-)
1
- ago
#3
hi eugene,
another additional question: what am I doing wrong, since your solution gives an error message.
Thanks for the support!

0
Cone8
 ( 28.45% )
- ago
#4
This is a current limitation with the Transformers - you can't put a Transformer in a Transformer.

The way to solve it is to create a Custom Indicator.. for the ATR multiple for example.
Then you can just use it where required.

See the Help (F1) for Indicators > Custom Indicators. If you need help, just let us know.
0
- ago
#5
If you're willing to use C# code then it becomes trivial - with the help of the ATRBand* indicator. It cannot be used this way in Blocks. Check this out:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript1 { public class MyStrategy : UserStrategyBase {       IndicatorBase dsU, dsL;        //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          var sma = SMA.Series(bars.Close, 20);          dsU = ATRBandUpper.Series(bars, sma, 20, 2.5);          dsL = ATRBandLower.Series(bars, sma, 20, 2.5);          PlotIndicatorBands(dsU, dsL); } //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             //Buy = Close < MA(Close, 20) - (ATR(20) *2.5)             PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, dsL[idx]); } else {             //code your sell conditions here             //Sell ​​= Close > MA(Close, 20) + (ATR(20) * 2.5)     PlaceTrade(bars, TransactionType.Sell, OrderType.Limit, dsU[idx]);          } } //declare private variables below } }
0
Best Answer

Reply

Bookmark

Sort