Topics
Replies
PanagiotisCharalampous
22 Jan 2021, 07:59
Hi ctid1074959,
Can you share the code you are using?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
21 Jan 2021, 11:55
Hi lampies_mvr,
To enable your account, you need to contact your broker.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
21 Jan 2021, 08:51
Hi rgasch,
1) Print() method for indicators works only in cTrader Automate
2) Your indicator code seems outdated. Please use the one below
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class HeikenAshiPro : Indicator
{
[Output("_haOpen")]
public IndicatorDataSeries _haOpen { get; set; }
[Output("_haClose")]
public IndicatorDataSeries _haClose { get; set; }
[Output("_haHigh")]
public IndicatorDataSeries _haHigh { get; set; }
[Output("_haLow")]
public IndicatorDataSeries _haLow { get; set; }
[Output("_haColorDir")]
public IndicatorDataSeries _haColorDir { get; set; }
protected override void Initialize()
{
}
public override void Calculate(int index)
{
var open = Bars.OpenPrices[index];
var high = Bars.HighPrices[index];
var low = Bars.LowPrices[index];
var close = Bars.ClosePrices[index];
var time = Bars.OpenTimes[index];
var haClose = (open + high + low + close) / 4;
var haOpen = (index > 0) ? (_haOpen[index - 1] + _haClose[index - 1]) / 2 : (open + close) / 2;
var haHigh = Math.Max(Math.Max(high, haOpen), haClose);
var haLow = Math.Min(Math.Min(low, haOpen), haClose);
_haOpen[index] = haOpen;
_haHigh[index] = haHigh;
_haLow[index] = haLow;
_haClose[index] = haClose;
_haColorDir[index] = haClose > haOpen ? 1 : -1;
Print("XXX " + index);
Print("YYY " + _haOpen[index]);
Chart.ChartType = ChartType.Line;
drawCandle(index, time, haOpen, haHigh, haLow, haClose);
}
private void drawTrendLine(int id, DateTime time1, double open1, DateTime time2, double open2, double close2)
{
var clr = close2 > open2 ? Color.ForestGreen : Color.OrangeRed;
Chart.DrawTrendLine("trendline" + id, time1, open1, time2, open2, clr, 2);
}
private void drawCandle(int id, DateTime t, double open, double high, double low, double close)
{
var clr = close > open ? Color.ForestGreen : Color.OrangeRed;
Chart.DrawTrendLine("candlebody" + id, t, open, t, close, clr, candlewidth(Chart.ZoomLevel));
Chart.DrawTrendLine("candlewick" + id, t, high, t, low, clr, 1);
Chart.DrawEllipse("price" + id, t, Bars.ClosePrices.LastValue, t, Bars.ClosePrices.LastValue, Color.Blue, 8);
resetCandlewidth();
}
private int candlewidth(int zoomlevel)
{
return zoomlevel <= 10 ? 1 : (zoomlevel <= 20 ? 2 : (zoomlevel <= 40 ? 5 : (zoomlevel <= 80 ? 10 : (zoomlevel <= 180 ? 20 : (zoomlevel <= 320 ? 40 : (60))))));
}
private void resetCandlewidth()
{
// if (_previousZoomLevel != Chart.ZoomLevel)
{
//_previousZoomLevel = Chart.ZoomLevel;
for (int i = 0; i < _haOpen.Count; i++)
{
var time = Bars.OpenTimes[i];
var haclr = _haClose[i] > _haOpen[i] ? Color.ForestGreen : Color.OrangeRed;
Chart.DrawTrendLine("candlebody" + i, time, _haOpen[i], time, _haClose[i], haclr, candlewidth(Chart.ZoomLevel));
var dotwidth = Chart.ZoomLevel <= 80 ? 5 : 8;
Chart.DrawEllipse("price" + i, time, Bars.ClosePrices[i], time, Bars.ClosePrices[i], Color.Blue, dotwidth);
}
}
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
21 Jan 2021, 08:35
Hi TOPGUNFX,
The last value of the indicator is always Last(0), shifted or not. If you want assosiate the indicator values with the bars then you need to take into consideration the shift as well. For example, based on your example above, the Jaws value that corresponds to Bars.Last(0) is alligator.Jaws.Last(13);
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
21 Jan 2021, 08:26
( Updated at: 21 Dec 2023, 09:22 )
Hi rbrt.gorski,
Here you go
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
21 Jan 2021, 08:20
Hi Johannes ,
Please post your issue in the relevant section and provide more information like exact steps to reproduce this behavior. This section is for suggestions only and this thread will be deleted soon.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 12:24
Hi samuel.jus.cornelio,
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; }
DateTime _lastTrade;
protected override void OnStart()
{
_lastTrade = Server.Time.AddDays(-1);
}
protected override void OnTick()
{
if (_lastTrade.DayOfYear != Server.Time.DayOfYear)
{
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 1000);
_lastTrade = Server.Time;
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 09:47
Hi 3rrr168,
Ok thanks, as mentioned above, to assist you further you need to provide us with the complete source code and steps to reproduce so that we can understand what the issue is and propose the proper alternative.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 08:27
Hi antoniogmd,
There is no such feature in cTrader. You can write a custom indicator for this.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 08:25
Hi 3rrr168,
Are the simultaneous orders executed by the same instance or by different instances?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 08:20
Hi samuel.jus.cornelio,
It's not one line of code :) You need to record the datetime at which the trade took place and then check if your current Server.Time day has changed before placing another one.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 08:14
Hi malas7malas,
To be honest, I did not understand what the problem is. Why don't you just stretch your charts vertically to get a better ratio?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 08:09
Hi amirrezaik,
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.None)]
public class SampleRSIRobot : Robot
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("Periods", DefaultValue = 5)]
public int Periods { get; set; }
[Parameter("Stop Loss (pips)", DefaultValue = 100, MinValue = 1)]
public int StopLoss { get; set; }
[Parameter("Take Profit (pips)", DefaultValue = 100, MinValue = 1)]
public int TakeProfit { get; set; }
[Parameter("Volume", DefaultValue = 10000, MinValue = 1000)]
public int Volume { get; set; }
private RelativeStrengthIndex rsi;
protected override void OnStart()
{
rsi = Indicators.RelativeStrengthIndex(Source, Periods);
}
protected override void OnBar()
{
if (rsi.Result.LastValue < 30)
{
Close(TradeType.Sell);
Open(TradeType.Buy);
}
else if (rsi.Result.LastValue > 70)
{
Close(TradeType.Buy);
Open(TradeType.Sell);
}
}
private void Close(TradeType tradeType)
{
foreach (var position in Positions.FindAll("SampleRSI", Symbol, tradeType))
ClosePosition(position);
}
private void Open(TradeType tradeType)
{
var position = Positions.Find("SampleRSI", Symbol, tradeType);
if (position == null)
ExecuteMarketOrder(tradeType, Symbol, Volume, "SampleRSI", StopLoss, TakeProfit);
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jan 2021, 08:03
Hi prosteel1,
No, it is work in progress.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
19 Jan 2021, 14:44
Hi dnatan,
You can start from here. You can also consider posting a Job or contacting a Consultant to do this for you.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
19 Jan 2021, 14:41
Hi ang2681442,
You can try using this cBot.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
19 Jan 2021, 14:38
Hi 3rrr168,
There are many but you need to provide us with the complete source code and steps to reproduce so that we can understand what the issue is and propose the proper alternative.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
19 Jan 2021, 11:32
Hi abdulrahmanzakari007,
I cannot change the code since I don't know what are you trying to achieve. If you don't know how to program, maybe contact a Consultant to help you with this.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
19 Jan 2021, 09:33
Hi abdulrahmanzakari007,
There are several ways to achieve this. Some of them are
- Use a flag
- Check if there are other positions opened
The correct solution depends on what your cBot logic is.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
22 Jan 2021, 08:01
Hi ctid1074959,
You can consider posting a Job too.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous