This website uses cookies to enhance site navigation, analyze site usage, and assist in our marketing efforts. By clicking “Accept All” you are providing your consent to our use of all cookies. Alternatively, please provide your choice by pressing “Customize Cookies”. For more information, please read our Privacy policy
chweb
18 Mar 2013, 13:25
The problem is NOT the crash
Somethimes I have to stop my robot for various reasons (update, ..) But after restarting, onPositionClosed is not called.
Look at my example:
If run the robot, a position is opened.
When I close the position via cAlgo, onPositionClosed works correct.
When I stop the robot while a position is open and restart the robot and I close the position via cAlgo, onPositionClosed is not doing anything.
[Robot]
public class NewRobot : Robot
{
Position pos;
protected override void OnStart()
{
if(Account.Positions.Count==0){
Trade.CreateBuyMarketOrder(Symbol,10000);
}else{
pos=Account.Positions[0];
}
}
protected override void OnPositionOpened(Position openedPosition)
{
pos=openedPosition;
}
protected override void OnPositionClosed(Position position)
{
Print("Netprofit: "+position.NetProfit);
}
}
@chweb