/* We use the colon sign to designate inheritance.Additionally, we used expressions in square brackets tospecify the parameters that apply to the entire class */[Robot(AccessRights = AccessRights.None)]publicclassNewBot:Robot{/* We declare a custom class property and make it read-only. */publicstringCustomProperty{get;}/* In this declaration, we define the default value of a custom parameter. */[Parameter("BotName", DefaultValue = "Traders First!")]/* We declare the BotName property which is changeable via the "BotName" parameter. */publicstringBotName{get;}/* We also declare the BotComment parameter. It can be both read and set. */[Parameter("BotComment", DefaultValue = "Our super-duper bot!")]publicstringBotComment{get;set;}}
namespaceCoolTradingBots{[Robot(AccessRights = AccessRights.None)]publicclassNewBot:Robot{// ... Defining the class parameters.// We declare the CustomTradeOperation method. protectedoverridevoidCustomTradeOperation(stringsymbolName,doublevolume){// This space is for declaring the method logic. }}}
namespaceCoolTradingBots{[Robot(AccessRights = AccessRights.None)]publicclassNewBot:Robot{// ... Defining the class parameters.protectedoverridevoidCustomTradeOperation(stringsymbolName,doublevolume){// We declare and initialize the 'result' variable.varresult=Analytics.Action.EvaluateMarket();// We use a conditional statement based on the IsSuccessful property.if(result.IsSuccessful){Print("Operation successful!")}}}}
usingSystem;namespaceSpotware.cBots{[Robot(AccessRights = AccessRights.None)]publicclassSuperAwesomeBot:Robot{/* In the below method, we define the operation(s) that our bot should perform when it is launched. */protectedoverridevoidOnStart(){varresult=ExecuteMarketOrder(TradeType.Buy,symbolName,10000);/* We use a conditional statement using the IsSuccessful property of the TradeResult object. */if(result.IsSuccessful){varposition=result.Position;Print("Position entry price is {0}",position.EntryPrice);}}}}