First cBot
First cBot
02 Aug 2022, 09:16
Hi there,
I'm writing my first cBot and just trying to create a MKT order very simple. I copied the code from cBot Code Samples, paste it in, click build and the build is successful but when I click play no orders are placed. Nothing I do will actually create a position?
Please advise what im doing wrong.
Using this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public string Message { get; set; }
protected override void OnStart()
{
var result = ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000);
if (result.IsSuccessful)
{
var position = result.Position;
Print("Position entry price is {0}", position.EntryPrice);
}
}
protected override void OnTick()
{
// Handle price updates here
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}
Replies
ctid2434759
02 Aug 2022, 10:37
RE:
Hi Panagiotis,
Thanks for the reply, i needed to change the target framework to .NET Framework 4.x and now it works.
When creating a new CBOT it was automatically .NET 6.0 which would not run for me.
@ctid2434759
PanagiotisCharalampous
02 Aug 2022, 09:22 ( Updated at: 21 Dec 2023, 09:22 )
Hi there,
It works fine for me.
Did you check the logs. Anything weird there?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous