using a building block technology,
i want to buy 3% below yeterday's high'
And I want to sell
1.5% above
and i can stand 10% loss before it sells
Can anyone screen shot what what that should look like
(tqqq) What goes up, must? go down? not apposed to a specific youtube link with similiar conditions. I have watched a few but can't yet critically think my way through it. So it has to be similiar
i want to buy 3% below yeterday's high'
And I want to sell
1.5% above
and i can stand 10% loss before it sells
Can anyone screen shot what what that should look like
(tqqq) What goes up, must? go down? not apposed to a specific youtube link with similiar conditions. I have watched a few but can't yet critically think my way through it. So it has to be similiar
Rename
It's easier to do this in code, here it is:
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; 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) { } //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)) { double entryPrice = bars.High[idx] * 0.97; PlaceTrade(bars, TransactionType.Buy, OrderType.Limit, entryPrice); exitLimit = bars.High[idx] * 1.01; } else { //code your sell conditions here PlaceTrade(bars, TransactionType.Sell, OrderType.Limit, exitLimit); PlaceTrade(bars, TransactionType.Sell, OrderType.Stop, LastPosition.EntryPrice * 0.9); } } //declare private variables below private double exitLimit; } }
You did that so well, i have been struggling with the code and the bar system. OMG - thanks you. ill try. I know its not financial advice and only a beautiful string of code.
Your Response
Post
Edit Post
Login is required