Topics
15 Mar 2013, 14:47
 4299
 6
Replies

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