I want to access the very first trade opened when the strategy is started. This is because I want to open the following trades with respect to its opening price. Plz tell me how to access the first trade opened.
Regards,
Jimmy.
API Support
Post subject: Re: How to access the first trade taken
Ok, suppose the strategy creates the first order in the following way :
IOrder order = engine.submitOrder("MyMaketBuyOrder", Instrument.EURUSD, OrderCommand.BUY, 0.1);
How will I be able to fetch the opening price of this trade in a way that I can use it to open the next few trades if they cross this value. Could you plz explain?
API Support
Post subject: Re: How to access the first trade taken
How will I be able to fetch the opening price of this trade in a way that I can use it to open the next few trades if they cross this value. Could you plz explain?
You have to make the IOrder object a field (i.e. global variable), i.e., define it before onStart, the same way as it is done in the wiki example MarketOrder.java which can be found in the previously referenced article.
JimmyHowl8
Post subject: Re: How to access the first trade taken
So could you plz tell me how to access the first trade opening price without mixing it up with the last order closed?
Assign your first order to a different IOrder object than the other orders. Also please use Code tags when posting code snippets, to make it more readable.