Topics
Replies
PanagiotisCharalampous
26 Mar 2020, 09:29
Hi Francesco,
This view is not available from cTrader. It seems you have taken it from Trading Central website.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 09:24
Hi Luca,
You can use Position.Closed event to monitor when a position is closed and take an appropriate action. See below an example
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
Positions.Closed += Positions_Closed;
}
private void Positions_Closed(PositionClosedEventArgs obj)
{
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 09:14
Hi edoardo.picazio02,
To get the open time of the last bar, you need to use Last(0).
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 09:12
Hi bienve.pf,
No there is no such option.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 09:09
Hi bienve.pf,
There is no ETA for Renk/Range backtesting at the moment. Can you explain what do you mean when you say "any external solution or project that works with the latest version of cTrader".
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 09:06
Hi Peter,
To delete accounts, you need to contact your broker.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 09:01
Hi,
You can use PositionCloseReason to check if a position is closed by a stop loss. See below
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
Positions.Closed += Positions_Closed;
}
private void Positions_Closed(PositionClosedEventArgs obj)
{
if (obj.Reason == PositionCloseReason.StopLoss)
{
}
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 17:06
Hi Francesco,
I am not sure what kind of help you need. Can you please elaborate?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 16:30
Hi tb135qet13,
You will need to program such functionality yourself. You can use ScrollChanged event and the new Chart UI controls which are more flexible and allow you place controls in a position relative to the chart.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 15:56
Hi Tj11,
You just need to add the relevant reference. See below
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 09:43
Hi Delta_Gamma,
We will add these timeframes in a future update of cTrader Web.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 08:44
Hi dannyilumi,
See below an example
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Automate API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file might be lost on the next application update.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// The "Sample Trend cBot" will buy when fast period moving average crosses the slow period moving average and sell when
// the fast period moving average crosses the slow period moving average. The orders are closed when an opposite signal
// is generated. There can only by one Buy or Sell order at any time.
//
// -------------------------------------------------------------------------------------------------
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SampleTrendcBot : Robot
{
[Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("MA Type", Group = "Moving Average")]
public MovingAverageType MAType { get; set; }
[Parameter("Source", Group = "Moving Average")]
public DataSeries SourceSeries { get; set; }
[Parameter("Slow Periods", Group = "Moving Average", DefaultValue = 10)]
public int SlowPeriods { get; set; }
[Parameter("Fast Periods", Group = "Moving Average", DefaultValue = 5)]
public int FastPeriods { get; set; }
private MovingAverage slowMa;
private MovingAverage fastMa;
private const string label = "Sample Trend cBot";
private bool _buyOpened;
private bool _sellOpened;
protected override void OnStart()
{
fastMa = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
slowMa = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);
}
protected override void OnTick()
{
var longPosition = Positions.Find(label, SymbolName, TradeType.Buy);
var shortPosition = Positions.Find(label, SymbolName, TradeType.Sell);
var currentSlowMa = slowMa.Result.Last(0);
var currentFastMa = fastMa.Result.Last(0);
var previousSlowMa = slowMa.Result.Last(1);
var previousFastMa = fastMa.Result.Last(1);
if (previousSlowMa > previousFastMa && currentSlowMa <= currentFastMa && longPosition == null)
{
if (shortPosition != null)
ClosePosition(shortPosition);
if (!_buyOpened)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName, VolumeInUnits, label);
_buyOpened = true;
}
}
else if (previousSlowMa < previousFastMa && currentSlowMa >= currentFastMa && shortPosition == null)
{
if (longPosition != null)
ClosePosition(longPosition);
if (!_sellOpened)
{
ExecuteMarketOrder(TradeType.Sell, SymbolName, VolumeInUnits, label);
_sellOpened = true;
}
}
}
private double VolumeInUnits
{
get { return Symbol.QuantityToVolumeInUnits(Quantity); }
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 08:32
( Updated at: 21 Dec 2023, 09:21 )
Hi travkinsm1,
It seems ok to me
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 08:25
Hi Nobody,
You can use Chart.DrawEquidistantChannel() method.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Mar 2020, 07:58
Hi Shares4UsDevelopment,
I cannot reproduce the case with the zeros in the stats. Whenever you have some time, please provide us with the necessary information to look into this further.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Mar 2020, 15:06
( Updated at: 21 Dec 2023, 09:21 )
Hi Sune,
cBot Log only appears after you add a cBot on the chart. See below
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Mar 2020, 15:01
Hi Shares4UsDevelopment,
I still need cBot parameters, dates and optimization parameters so that we can reproduce the results you are seeing.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Mar 2020, 11:39
Hi,
The button can be used alone.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Mar 2020, 11:23
Hi Shares4UsDevelopment,
Please provide us with the cBot code, cBot parameters, dates and optimization parameters so that we can reproduce the results and explain the statistics.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 12:02
Hi Luca,
Check the Sample Martingale cBot. It has an example on how to execute random orders.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous