major error, does not close open positions during the OnStop event
major error, does not close open positions during the OnStop event
04 Aug 2022, 04:22
protected override void OnStop()
{
if (RunningMode == RunningMode.SilentBacktesting || RunningMode == RunningMode.VisualBacktesting || RunningMode == RunningMode.Optimization)
{
foreach (var posi in Positions)
{
if (posi.SymbolName == SymbolName )
{
ClosePosition(posi);
}
}
foreach (var pos in PendingOrders)
{
if (pos.SymbolName == SymbolName)
{
pos.Cancel();
}
}
}
}
log plotted error: 24/07/2011 04:53:00.000 | CBot instance [TF Ax Bot 2022, EURUSD, D1] aborted by timeout.
Replies
G.A.F
04 Aug 2022, 12:32
RE: no matter the code, it happens at any date or time when I have to close various positions as I told you, the bot is also operational in live on icmarkets, so please solve it quickly or give the possibility to return to the previous working version
PanagiotisCharalampous said:
Hi there,
Please provide us with the following
- The complete cBot code
- Broker, cBot parameters and dates where we can run this and reproduce the problem
Best Regards,
Panagiotis
@G.A.F
... Deleted by UFO ...
PanagiotisCharalampous
04 Aug 2022, 12:53
Hi there,
I tried with the attached code and there is no problem. Unfortunately we cannot help if we do not recieve the requested information.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
G.A.F
04 Aug 2022, 19:50
PanagiotisCharalampous said:
Hi there,
I tried with the attached code and there is no problem. Unfortunately we cannot help if we do not recieve the requested information.
Best Regards,
Panagiotis
Eur Usd
start :14/6/2011
stop:26/6/2011
icmarkets
no pposition closed
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 NewcBot4 : Robot
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
protected override void OnStart()
{
}
protected override void OnBar()
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Symbol.VolumeInUnitsMin, "0", null, null, "A", false);
}
protected override void OnStop()
{
if (RunningMode == RunningMode.SilentBacktesting || RunningMode == RunningMode.VisualBacktesting || RunningMode == RunningMode.Optimization)
{
foreach (var posi in Positions)
{
if (posi.SymbolName == SymbolName)
{
ClosePosition(posi);
}
}
foreach (var pos in PendingOrders)
{
if (pos.SymbolName == SymbolName)
{
pos.Cancel();
}
}
}
}
}
}
@G.A.F
G.A.F
04 Aug 2022, 19:51
RE:
giuseppealessioferrandes said:
PanagiotisCharalampous said:
Hi there,
I tried with the attached code and there is no problem. Unfortunately we cannot help if we do not recieve the requested information.
Best Regards,
Panagiotis
Eur Usd
start :14/6/2011
stop:26/6/2011
icmarkets
no pposition closed
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 NewcBot4 : Robot
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
protected override void OnStart()
{
}
protected override void OnBar()
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, Symbol.VolumeInUnitsMin, "0", null, null, "A", false);
}
protected override void OnStop()
{
if (RunningMode == RunningMode.SilentBacktesting || RunningMode == RunningMode.VisualBacktesting || RunningMode == RunningMode.Optimization)
{
foreach (var posi in Positions)
{
if (posi.SymbolName == SymbolName)
{
ClosePosition(posi);
}
}
foreach (var pos in PendingOrders)
{
if (pos.SymbolName == SymbolName)
{
pos.Cancel();
}
}
}
}
}
}
i forgot timeframe daily
@G.A.F
PanagiotisCharalampous
05 Aug 2022, 08:30
( Updated at: 21 Dec 2023, 09:22 )
Hi,
It worked fine for me
Can you record a video so that we can see what you are doing?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
04 Aug 2022, 09:17
Hi there,
Please provide us with the following
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous