If you debug your code, you will find out exactly where your code is crashing. It is probably crashing because ht is null. You should be checking if the trade exists before using it.
Hi, I tried to debug it, I have changed the code so that there is a position opened and closed on start so there is history but the FindLast still doesn't work.
can you help me show an example of a working code for this function? there isn't one available on the Ctrader website.
jeelom111
06 Oct 2022, 08:32
RE:
PanagiotisChar said:
Hi, I tried to debug it, I have changed the code so that there is a position opened and closed on start so there is history but the FindLast still doesn't work.
can you help me show an example of a working code for this function? there isn't one available on the Ctrader website.
HistoricalTrade ht = History.FindLast("RobotID1");+
Print(ht.NetProfit)
@jeelom111