Trace Order Status during executing Code in different Methods
Created at 22 Feb 2016, 00:14
Trace Order Status during executing Code in different Methods
22 Feb 2016, 00:14
Hi there,
I have an Issue tracking the Status of an Order while executing different Methods in my Code.
Basically I do not want my Code to stop if a Market Order is executed in Order to be able to continue with Calculations.
My Code looks like this
namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class myBot: Robot { public TradeOperation OpenLong; Method1() { TradeOperation OpenLong = ExecuteMarketOrderAsync(TradeType.Buy,Symbol,10,"OpenLong",30,30); } onTick() { If(OpenLong.TradeResult.IsSuccessful == true) Print("Order filled") } } }
If the Code Execution proceeds the the If() in onTick() I get an 'System.NullReferenceException'.
What am I missing, respectively how can I query the Order Status from another Method?
Thank you!
Mikro
23 Feb 2016, 22:18
Sorted that one out
The mistake ist to declare 'OpenLong' as a TradeOperation the second time inside Method1().
Only using
OpenLong = ExecuteMarketOrderAsync(...);
it works.
@Mikro