Topics
Forum Topics not found
Replies
amusleh
30 Jul 2021, 09:40
RE:
cW22Trader said:
Could you also provide a simple example with an indicator used for multiple symbols at the same time?
Is it still initialized in OnStart? Do I need one per symbol or is this handled automatically?
Kind regards
Please check the example on Market Data API references.
@amusleh
amusleh
30 Jul 2021, 09:37
( Updated at: 19 Mar 2025, 08:57 )
RE: API Activation Request
opusensemble said:
Hi amusleh,
My API application is not activated. The current status is "Submitted".
To have it activated, is it enough to request it here or should I request it through a separate method?
(In case I need to use another method like Email or ticket, kindly let me know the email address or where I should place the ticket)
Looking forward to hearing back from you,
Best Regards,
opusensemble
Please send an email to support@ctrader.com and we will activate your app.
Before sending an activation request be sure you fill the application description filled so we will know what you will use the application for.
@amusleh
amusleh
29 Jul 2021, 14:45
RE: RE:
victor.major said:
amusleh said:
Hi,
Can you send us the troubleshoot report by adding this forum thread URL to your reference description?
You can explain what actions you did that caused cTrader to become unresponsive?
If possible can you send us the code of cBots you used before cTrader became unresponsive?
Done.
I can cause even the new version 4.1 to become unresponsive when I switch views from Trade to cBot instance view. In v4.0 cTrader would go unresponsive when I try to scroll through the cBot list on the left of the window. It appears that every time cTrader went unresponsive I was trying to interact with its display, clicking, dragging, selecting, etc.
Hi,
Our team checked your troubleshoot report and they found that the issue is your cBots, in order to reproduce the issue we need your cBot code and a video that shows how to reproduce the issue.
@amusleh
amusleh
29 Jul 2021, 12:52
Hi,
Try this:
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.FullAccess)]
public class RiskonSL : Robot
{
[Parameter("Label", DefaultValue = "")]
public string _Label { get; set; }
[Parameter("Risk %", DefaultValue = 1.0, MaxValue = 100.0, MinValue = 0.01, Step = 0.1)]
public double _RiskPercent { get; set; }
[Parameter("Max Allowed Lots", DefaultValue = 10.0, MaxValue = 100.0, MinValue = 0.01, Step = 0.01)]
public double _MaxLots { get; set; }
[Parameter("Stop Loss", DefaultValue = 10.0, MaxValue = 50.0, MinValue = 0.1, Step = 0.1)]
public double _SL { get; set; }
[Parameter("Take Profit", DefaultValue = 15.0, MaxValue = 50.0, MinValue = 0.1, Step = 0.1)]
public double _TP { get; set; }
private ExponentialMovingAverage _ema_12;
private ExponentialMovingAverage _ema_26;
private bool _ema_buy, _ema_sell;
protected override void OnStart()
{
_ema_12 = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 12);
_ema_26 = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 26);
}
protected override void OnBar()
{
var ActiveBuy = Positions.Find(_Label, SymbolName, TradeType.Buy);
var ActiveSell = Positions.Find(_Label, SymbolName, TradeType.Sell);
var volume = GetVolume();
if (_ema_12.Result.HasCrossedAbove(_ema_26.Result.Last(1), 1))
{
_ema_buy = true;
_ema_sell = false;
}
else if (_ema_12.Result.HasCrossedBelow(_ema_26.Result.Last(1), 1))
{
_ema_sell = true;
_ema_buy = false;
}
if (ActiveBuy == null && _ema_buy)
{
if (ActiveSell != null)
{
ClosePosition(ActiveSell);
}
ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, _Label, _SL, _TP);
}
if (ActiveSell == null && _ema_sell)
{
if (ActiveBuy != null)
{
ClosePosition(ActiveBuy);
}
ExecuteMarketOrder(TradeType.Sell, SymbolName, volume, _Label, _SL, _SL);
}
}
private double GetVolume()
{
double costPerPip = (double)((int)(Symbol.PipValue * 10000000)) / 100;
double baseNumber = Account.Equity;
double sizeInLots = Math.Round((baseNumber * _RiskPercent / 100) / (_SL * costPerPip), 2);
var result = Symbol.QuantityToVolumeInUnits(sizeInLots);
if (result > Symbol.VolumeInUnitsMax)
{
result = Symbol.VolumeInUnitsMax;
}
else if (result < Symbol.VolumeInUnitsMin)
{
result = Symbol.VolumeInUnitsMin;
}
else if (result % Symbol.VolumeInUnitsStep != 0)
{
result = result - (result % Symbol.VolumeInUnitsStep);
}
return result;
}
}
}
@amusleh
amusleh
29 Jul 2021, 12:44
Hi,
Can you send us the troubleshoot report by adding this forum thread URL to your reference description?
You can explain what actions you did that caused cTrader to become unresponsive?
If possible can you send us the code of cBots you used before cTrader became unresponsive?
@amusleh
amusleh
29 Jul 2021, 11:02
RE: RE:
khoshroomahdi said:
amusleh said:
Hi,
You can have one line and two outputs, that's exactly what my posted code does.
i mean 1 output line with two color by condition.
could you please explain me why in plottype.point or dicontinueline or histogram, it's fine but plottype.line we have 2 line.
i couldn't underatnd it.
Hi,
You can't have one output with two-color, the solution is to use two outputs and show only one based on some condition like I did on my code.
The PlotType.Line is continuous, it will always be shown even if you set some values in between to NAN.
@amusleh
amusleh
29 Jul 2021, 09:30
RE:
SmallStep said:
Hi is v4.0 and brokerage=ICMarkets
I am also getting weird data, eg, I ran VBT from 1/1/2012 to 31/12/2020, start time 0101 to 2359 (bot trading times) i cant get any 2019 or 2020 trades at all. It might be the bot settings, but when i tried with same date ranges, same other settings and time 0101 to 0459, i got some 2020 trades. It might be some bugs with the bot, but would like to know whether there might be the issue and not with ctrader VBT
I test but I couldn't replicate the issue, can you record a short video?
@amusleh
amusleh
30 Jul 2021, 09:43
Please create a thread in the suggestions section of the forum.
@amusleh