Hi,
I have the following line:
Transaction thisTransaction = PlaceTrade(bars, TransactionType.Sell, OrderType.Market);
The compiler gives the following error:
Argument 2: cannot convert from 'WealthScript2.MyStrategy.TransactionType' to 'WealthLab.Backtest.TransactionType'
How can I fix it?
Thanks!
I have the following line:
Transaction thisTransaction = PlaceTrade(bars, TransactionType.Sell, OrderType.Market);
The compiler gives the following error:
Argument 2: cannot convert from 'WealthScript2.MyStrategy.TransactionType' to 'WealthLab.Backtest.TransactionType'
How can I fix it?
Thanks!
Rename
We’d need to see the complete code. It sounds like you defined a class called Transaction in your Strategy code.
There's not enough code to diagnose this problem. Are you forgetting a "using WealthLab.Backtest" statement? Is the PlaceTrade statement inside an Execute{block}? Is MyStrategy inheriting from UserStrategyBase?
CODE:Something is very wrong, but we can only guess with so little code provided.
public class MyStrategy : UserStrategyBase
CODE:
using WealthLab.Backtest; using WealthLab.Core; . . . public override void Execute(BarHistory bars, int idx) { PlaceTrade(bars, TransactionType.Cover, OrderType.Stop); . . . }
Thank you for your time! Here is a guess as to what might be the reason for the error message. I have the same PlaceTrade working fine in the Execute section.
Here I have it in the variables section after Execute and wrapped around with my async call (accessing TD Ameritrde). I was hoping my code would not change but the async call would.
The error is seen even when the ExecutionMode if is removed.
Here I have it in the variables section after Execute and wrapped around with my async call (accessing TD Ameritrde). I was hoping my code would not change but the async call would.
CODE:
public async void placeSellOrderTDTangerineAsync(BarHistory bars, string optionName) { if (ExecutionMode == StrategyExecutionMode.StreamingChart) { Transaction thisTransaction = PlaceTrade(bars, TransactionType.Sell, OrderType.Market); } }
The error is seen even when the ExecutionMode if is removed.
Your problem is outside my expertise, but my "attempted" fix would look something like this. You'll need to fix the new errors. I'm not even sure you can "safely" use an async routine in this multithreaded context. I would try to get it running without the "async" part first.
CODE:
public async void PlaceSellOrderTDTangerineAsync(UserStrategyBase usb, BarHistory bars, string optionName) { if (usb.ExecutionMode == StrategyExecutionMode.StreamingChart) { Transaction thisTransaction = usb.PlaceTrade(bars, TransactionType.Sell, OrderType.Market); } } public override void Execute(BarHistory bars, int idx) { if (HasOpenPosition(bars, PositionType.Long)) { //sell conditions below PlaceSellOrderTDTangerineAsync(this as UserStrategyBase, bars, optionName); } else { //buy conditions below } }
@haytac - this is a name collision that is causing the compile-time error. As Glitch indicated, check if you have class TransactionType class or enum TransactionType defined in your code.
Your Response
Post
Edit Post
Login is required