Topics
Replies
Prasanna
08 Apr 2020, 16:11
RE:
PanagiotisCharalampous said:
Hi kittu.ce10,
Can you send us some information like backtesting parameters and dates where you expect the events to happen but they don't so that we can explain to you what happens?
Best Regards,
Panagiotis
Sure,
I tested this cBot on EURUSD, Volume - 10000 and RSI period 14
dates 01/01/2020 - 31/01/2020, Initial capital - 10000, tick data, commissions zero for testing purposes.
@Prasanna
Prasanna
08 Apr 2020, 12:21
Hello,
After trying I have come up with a code with above mentioned logic.
But there is a problem in the backtesting. The bot isn't taking the trades how I wanted. sometimes it's missing to close positions when the criteria met.
Please take a look at the code and let me know if something is wrong.
Very much appreciate admin help on this.
Thanks.
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.EAustraliaStandardTime, AccessRights = AccessRights.None)]
public class SampleSARTrailingStop : Robot
{
[Parameter(DefaultValue = 10000, MinValue = 0)]
public int Volume { get; set; }
[Parameter("Source", Group = "RSI")]
public DataSeries Source { get; set; }
[Parameter("Periods", Group = "RSI", DefaultValue = 14)]
public int Periods { get; set; }
private RelativeStrengthIndex rsi;
protected override void OnStart()
{
rsi = Indicators.RelativeStrengthIndex(Source, Periods);
}
protected override void OnBar()
{
var longPosition = Positions.Find("RSI", SymbolName, TradeType.Buy);
var shortPosition = Positions.Find("RSI", SymbolName, TradeType.Sell);
{
if (rsi.Result.Last(0) > 30 && rsi.Result.Last(1) < 30 && longPosition == null)
{
if (shortPosition != null)
{
ClosePosition(shortPosition);
}
ExecuteMarketOrder(TradeType.Buy, SymbolName, Volume, "RSI");
}
if (rsi.Result.Last(0) > 70 && rsi.Result.Last(1) < 70)
{
if (longPosition != null)
{
ClosePosition(longPosition);
}
}
}
{
if (rsi.Result.Last(0) < 70 && rsi.Result.Last(1) > 70 && shortPosition == null)
{
if (longPosition != null)
{
ClosePosition(longPosition);
}
ExecuteMarketOrder(TradeType.Sell, SymbolName, Volume, "RSI");
}
if (rsi.Result.Last(0) < 30 && rsi.Result.Last(1) > 30)
{
if (shortPosition != null)
{
ClosePosition(shortPosition);
}
}
}
}
}
}
@Prasanna
Prasanna
31 Mar 2020, 14:30
Hi,
Thanks for the reply. I have been going through some sample cBots in the cTrader and have two questions.
1) what is the purpose of the time zone function?
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
what happens if I change it to my timezone? for example UTC+11
2) [Parameter(DefaultValue = 10000, MinValue = 0)]
public int Volume { get; set; }
How to change the volume to lots?
These might seem very basic questions but I'm just starting learn this programming. So, I wanted to begin with thorough understanding.
I very much appreciate if someone could answer my questions
Thanks in advance
@Prasanna
Prasanna
24 Mar 2020, 04:05
MACD bot
Hi,
I recently come across this MACD bot. I have a question. Is there a way to remove stop loss and take profit. Instead of SL or TP when the MACD generates opposite signal the previous position is closed and a new position opens until the MACD generates another signal to the opposite side. Any ideas?
@Prasanna
Prasanna
08 Apr 2020, 16:59
RE:
PanagiotisCharalampous said:
Hi,
Thanks for the quick reply.
Yes, that is working now perfectly.
another question though. Can I use the "HasCrossedAbove/Below" function instead
Is this correct?
@Prasanna