Robot


Summary

Base class for all cBots.

Remarks

Provides a convenient framework for creating cBots including methods to create, modify, cancel orders and close positions, methods trigered by each tick and each bar, access to built-in Indicators and more.

Syntax

public class Robot : Algo

Members

NameTypeSummary
Account PropertyContains all Account information
CancelPendingOrder MethodCancel a Pending Order
CancelPendingOrderAsync MethodCancel a Pending Order in asynchronous execution mode
ClosePosition MethodClose a position
ClosePositionAsync MethodClose a position in asynchronous execution mode
ExecuteMarketOrder MethodExecute a Market Order
ExecuteMarketOrderAsync MethodExecute a market order in asynchronous execution mode
GetFitness MethodOverride this method to provide custom fitness value for Optimization
LastResult PropertyThe latest trade result
ModifyPendingOrder MethodModify a Pending Order
ModifyPendingOrderAsync MethodModify a Pending Order in asynchronous execution mode
ModifyPosition MethodModify the volume of a position
ModifyPositionAsync MethodModify Position in asynchronous execution mode
OnBar MethodCalled on each incoming Bar.
OnError MethodCalled if there is an error executing a trade operation.
OnStart MethodCalled when cBot is being started. Override this method to initialize cBot, create nested indicators, etc.
OnStop MethodCalled when cBot is stopped.
OnTick MethodCalled on each incoming market tick.
PlaceLimitOrder MethodPlace a Limit Order
PlaceLimitOrderAsync MethodPlace limit order in asynchronous execution mode
PlaceStopLimitOrder MethodPlace a Stop Limit Order
PlaceStopLimitOrderAsync MethodPlace Stop Limit order in asynchronous execution mode
PlaceStopOrder MethodPlace a stop order
PlaceStopOrderAsync MethodPlace stop order in asynchronous execution mode
ReversePosition MethodModify the direction of trade at position
ReversePositionAsync MethodModify Position in asynchronous execution mode
Robot MethodRobot class constructor
Stop MethodStops the cBot. cBot will be completely stopped and will not send/receive any signals.
ToString MethodReturns the cBot class name

Example 1

namespace cAlgo.Robots
{
[Robot]
public class myCBot : Robot
{
    protected override void OnStart()
    {
        //This method is called when the cBot is being started, once.
    }
    
    protected override void OnBar()
    {
        // Called on each incoming Bar.
    }
    protected override void OnTick()
    {
        // Called on each incoming tick.
    }
    
    protected override void OnError(Error error)
    {
        Print("There has been an Error");
    }
    protected override void OnStop()
    {
        //This method is called when the cBot is being stoped.
    }