Topics
Replies
PanagiotisCharalampous
28 Sep 2020, 08:23
Hi cdyett,
These features are enabled only after the broker requests for them.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
28 Sep 2020, 08:21
Hi deadletteropener,
We do not have immediate plans to add this in the near future.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 14:47
Hi firemyst,
You cannot use Output IndicatorDataSeries to do this since they have a one to one correspondence with the chart timeframe's bar. You need to be more inventive. Here is a solution
using System;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class Test : Indicator
{
[Parameter()]
public TimeFrame SourceTimeFrame { get; set; }
[Parameter("Min AF", DefaultValue = 0.02)]
public double MinAF { get; set; }
[Parameter("Max AF", DefaultValue = 0.2)]
public double MaxAF { get; set; }
[Output("Main", PlotType = PlotType.Points, LineStyle = LineStyle.Dots, LineColor = "White", Thickness = 2)]
public IndicatorDataSeries Result { get; set; }
private Bars _marketSeries;
private ParabolicSAR _psar;
int previousAltIndex = 0;
protected override void Initialize()
{
if (SourceTimeFrame != null)
_marketSeries = MarketData.GetBars(SourceTimeFrame, Symbol.Name);
else
_marketSeries = MarketData.GetBars(Bars.TimeFrame, Symbol.Name);
_psar = Indicators.ParabolicSAR(_marketSeries, MinAF, MaxAF);
}
public override void Calculate(int index)
{
int altIndex = index;
if (Bars.TimeFrame != _marketSeries.TimeFrame)
{
altIndex = _marketSeries.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
}
if (Bars.TimeFrame != _marketSeries.TimeFrame)
{
altIndex = _marketSeries.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
for (int i = previousAltIndex; i < altIndex; i++)
{
Chart.DrawIcon(_marketSeries.OpenTimes[i].ToString(), ChartIconType.Circle, _marketSeries.OpenTimes[i], _psar.Result[i], Color.Red);
}
altIndex = previousAltIndex;
}
// blah blah blah
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 11:19
( Updated at: 21 Dec 2023, 09:22 )
Hi firemyst,
Did you try my code? It prints a line on the starting time of every bar for the lower timeframe
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 11:07
Hi Luca,
You can use the OnBar() method. Else you can check if the Bars.OpenTimes.LastValue has changed.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 10:43
Hi firemyst,
OnCalculate method is called once per bar when the indicator is calculated for past values. Having that in mind, if you want your indicator to display values from lower timeframes, you need to write the corresponding logic that will take this into consideration. Here is a starting point, an indicator drawing vertical lines on lower tiimeframe open times
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewIndicator : Indicator
{
[Parameter(DefaultValue = 0.0)]
public TimeFrame SourceTimeFrame { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
private Bars _marketSeries;
int previousAltIndex = 0;
protected override void Initialize()
{
if (SourceTimeFrame != null)
_marketSeries = MarketData.GetBars(SourceTimeFrame, Symbol.Name);
else
_marketSeries = MarketData.GetBars(Bars.TimeFrame, Symbol.Name);
}
public override void Calculate(int index)
{
int altIndex = index;
if (Bars.TimeFrame != _marketSeries.TimeFrame)
{
altIndex = _marketSeries.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
for(int i = previousAltIndex; i < altIndex; i++)
{
Chart.DrawVerticalLine(_marketSeries.OpenTimes[i].ToString(), _marketSeries.OpenTimes[i], Color.Red);
}
altIndex = previousAltIndex;
}
// blah blah blah
}
}
}
Note that for current values, OnCalculate() is called on every tick, in case you need to take that into consideration.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 07:59
Hi firemyst,
You will need to program your own methods to calculate those times.
Regarding
Does cTrader have the ability to plot 3 smaller time frame bar values in the space of 1 bar on a higher time frame?
I did not understand the question. You are trying to do something here but I do not understand what it is. Maybe it would be better to explain what are you trying to do instead discussing about a solution you thought would work.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 07:50
Hi ctid2568413,
Some solutions are proposed here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 07:45
Hi Luca,
Check here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2020, 07:44
Hi maciel.rafael1,
You can send it at community@spotware.com
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Sep 2020, 17:08
Hi maciel.rafael1,
You need to be more specific. Please provide the cBot code and the exception you get.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Sep 2020, 16:49
Hi maciel.rafael1,
cTrader does not stop cBots. cBots are either stopped manually/automatically by the trader or due to some exception. Did you check your logs? Are there any messages there indicating why the cBot has stopped?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Sep 2020, 16:39
Hi cosacdaher,
Please help me understand why it didn't work
I cannot help you with this since there is not evidence it did not work. If you do not remember the Equity Stop Loss level then how do you know it did not work?
why was I allowed to copy an strategy with $100 if that was not enough margin to operate within the strategy
The minimum investment amount is set by the strategy provider, not by us. You were allowed to follow because this is what the strategy provider set as minimum
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Sep 2020, 16:06
Hi arthur.albert990,
Hello PanagiotisCharalampous, i've tried to add an output to the code and the "Result" on Calculate() but i'm unable to obtain the result from macd, platform tells me that the ZeroLagMACD doesn't has a definition for Result.
If this is the indicator you use, then it doesn't :)
Here are your options
[Output("Histogram", Color = Colors.Turquoise, PlotType = PlotType.Histogram)]
public IndicatorDataSeries Histogram { get; set; }
[Output("MACD", Color = Colors.Blue)]
public IndicatorDataSeries MACD { get; set; }
[Output("Signal", Color = Colors.Red, LineStyle = LineStyle.Lines)]
public IndicatorDataSeries Signal { get; set; }
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Sep 2020, 10:27
Hi Sam,
Here you go
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; }
RelativeStrengthIndex _rsiDaily;
RelativeStrengthIndex _rsiHourly;
protected override void OnStart()
{
var dailyBars = MarketData.GetBars(TimeFrame.Daily);
var hourlyBars = MarketData.GetBars(TimeFrame.Hour);
_rsiDaily = Indicators.RelativeStrengthIndex(dailyBars.ClosePrices, 14);
_rsiHourly = Indicators.RelativeStrengthIndex(hourlyBars.ClosePrices, 14);
}
protected override void OnBar()
{
if (_rsiDaily.Result.Last(1) > 60 && _rsiHourly.Result.Last(1) > 60)
{
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 1000);
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Sep 2020, 07:56
Hi sam,
There are a lot of mistakes in your code. What is the actual information you are missing?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
24 Sep 2020, 07:51
Hi arthur.albert990,
It does not display anything because you do not have any output. Read here how to create a custom indicator.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Sep 2020, 16:03
Hi Sam,
Here is the correct condition
if (Positions.Count == 0)
{
// Do something
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Sep 2020, 14:19
Hi ctid1074959,
You can post it here. If you don't want to disclose the code, you can send it to community@spotware.com
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
28 Sep 2020, 08:25
Hi Christian,
You can find instructions on how to compile the .proto files here.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous