search Nothing found
Main Algotrading documentation Input parameters

Robot parameters

struct TBotParams
{
BSTR SymbolName; // symbol name of the current chart
int TimerValue; // value through which the OnTimer() event is generated
int Tag; // instance number in the list of robots
BSTR TimeFrame; // timeframe of the current chart
};

In backtesting mode, the value of the Tag parameter is always -1

 

Example:

using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Reflection;

namespace uAlgo.Bots
{
public class NewBot : Bot
{
//-------------------------------------
//
//-------------------------------------
private void PrintToFile(
string f, // file name
string msg // message to be recorded to file
)
{
// get the path to the folder with our robot
string AssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar.ToString();
// full path to the file for recording service information
string mLog = AssemblyPath + f;

using (StreamWriter sw = new StreamWriter(mLog, true))
sw.WriteLine(msg);
}

public void OnTick()
{
// Put your core logic here
}

public void OnStart()
{
PrintToFile("BotParams.txt",
"\nSymbol = "+BotParams.SymbolName+
"\nTimeFrame = "+BotParams.TimeFrame+
"\nTimerValue = "+BotParams.TimerValue+
"\nTag= "+BotParams.Tag
);
}

public void OnStop()
{
// Put your deinitialization logic here
}
}
}


// Execution result example:

// Symbol = EURUSD
// TimeFrame = H1
// TimerValue = 100
// Tag= 0