I have an error message.
Ok, let me ask you this, if I may.
How would you code the following in WL7:
if the current bar is at least 3 bars later than the entry bar.
Thank you.
Ok, let me ask you this, if I may.
How would you code the following in WL7:
if the current bar is at least 3 bars later than the entry bar.
Thank you.
Rename
CODE:
Position pos = LastPosition; if (idx - pos.EntryBar + 1 > 3) { PlaceTrade(bars, TransactionType.Sell, OrderType.Market); }
Thanks Eugene.
Ok, so I already have that.
Compiles OK, but gives an error on backtesting "Object reference not set to an instance of an object."
Out of respect to other members, I was avoiding creating a new discussion thread.
Ok, so I already have that.
Compiles OK, but gives an error on backtesting "Object reference not set to an instance of an object."
Out of respect to other members, I was avoiding creating a new discussion thread.
QUOTE:
Compiles OK, but gives an error on backtesting "Object reference not set to an instance of an object."
Please give me some context i.e. DataSet / symbols, data range and a more complete sample code that demonstrates the issue.
It's because LastPosition is null. Make sure you've got a position first, like this -
CODE:
public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { //code your buy conditions here } else { Position pos = LastPosition; if (idx - pos.EntryBar + 1 > 3) { PlaceTrade(bars, TransactionType.Sell, OrderType.Market); } } }
It's just a snippet for exit in Post #1, of course it's incomplete.
Thanks for your help.
I made some changes and it ran without error.
But no trades ...
There is now quite a large dent in the wall next to me.
In 6.9, I could figure things out more easily.
A quadruple espresso may help.
I made some changes and it ran without error.
But no trades ...
There is now quite a large dent in the wall next to me.
In 6.9, I could figure things out more easily.
A quadruple espresso may help.
If you want to describe your basic entry and exit conditions i’d be happy to mock something up to get you started?
Your Response
Post
Edit Post
Login is required