Topics
Replies
inky_morning
02 Apr 2019, 18:30
RE:
Panagiotis Charalampous said:
Hi Ziheng,
It seems you already do that in the cBot code. What additional help do you need?
Best Regards,
Panagiotis
one more word, if I use VS edit this code, it tells "error CS0102/CS0229" on "MAR"s, I don't know how to translate the 2 errors into English...
@inky_morning
inky_morning
02 Apr 2019, 18:15
RE:
Panagiotis Charalampous said:
Hi Ziheng,
It seems you already do that in the cBot code. What additional help do you need?
Best Regards,
Panagiotis
Hi Panagiotis,
It doesn't work. I try to run the code, it stucks at MARs' lines,like parameter,private, or override.
Best Regards,
Ziheng
@inky_morning
inky_morning
02 Apr 2019, 12:58
( Updated at: 21 Dec 2023, 09:21 )
RE:
Panagiotis Charalampous said:
Dear trader,
Thanks for posting in our forum. However your question is not clear. Do you mean that you want to pass the moving average as a source to the RSI?
Best Regards,
Panagiotis
Dear Panagiotis,
Thanks a lot for your reply. I need to write my question again ... that webpage didn't save my text. So sorry for take so long time.
I'll show you what I need:

In this pic, the white MA based on price, the red one calculated by RSI. They both are MAs, but I need free to choose their MaType, like the white is EMA and the red is SMA, and I could change it freely.
I'm learning writing bot for several days, just a rookie. Here is my code :
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 InkyMorning : Robot
{
#region Parameters
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("MA Type in Price Chart", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MaType { get; set; }
[Parameter("MA1 Period", DefaultValue = 5)]
public int MA1Period { get; set; }
[Parameter("MA2 Period", DefaultValue = 20)]
public int MA2Period { get; set; }
[Parameter("Volume", DefaultValue = 100, MinValue = 1)]
public int Volume { get; set; }
[Parameter("RSI Period", DefaultValue = 14)]
public int RSIPeriod { get; set; }
[Parameter("MA Type in RSI Chart", DefaultValue = MovingAverageType.Exponential)]
public MovingAverageType MaType2 { get; set; }
[Parameter("MA Period in RSI Chart", DefaultValue = 9)]
public int MAR { get; set; }
#endregion
#region Private
private MovingAverage MA1;
private MovingAverage MA2;
private MovingAverage MAR;
private RelativeStrengthIndex RSI;
private const string botName = "InkyMorning";
#endregion
#region cBot Events
protected override void OnStart()
{
base.OnStart();
MA1 = Indicators.MovingAverage(Source, MA1Period, MaType);
MA2 = Indicators.MovingAverage(Source, MA2Period, MaType);
RSI = Indicators.RelativeStrengthIndex(Source, RSIPeriod);
MAR = Indicators.MovingAverage(RSI.Result, MAR, MaType2);
}
protected override void OnStop()
{
base.OnStop();
closePositions();
}
protected override void OnBar()
{
// Put your core logic here
}
private void OnPositionClosed(PositionClosedEventArgs args)
{
}
#endregion
#region cBot Utils
private int OpenedTrades
{
get { return Positions.FindAll(botName, Symbol).Count(); }
}
#endregion
}
}
It's not finish yet... thanks again.
Best Regards,
Ziheng
@inky_morning
inky_morning
15 Apr 2019, 10:13
RE:
Panagiotis Charalampous said:
Hi Panagiotis,
Thank you for your help, and say sorry to so long time no reply, because my baby was born these days, I must taking care of my wife and baby.
This problem is solved now, I'll finish the code first.
Thanks again and Best Regards,
Ziheng
@inky_morning