Topics
Replies
Cerunnos
12 Dec 2013, 21:10
RE:
Hyperloop said:
I am using a custom domain, hosted through Yahoo Small Business Hosting.
If I just create a new robot that sends an email OnStart, the error message I am getting now is:
12/12/2013 18:56:45.144 | Failed to send email "Test". System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Authentication required at System.Net.Mail.SendMailAsyncResult.End(IAsyncResult result) at System.Net.Mail.SmtpClient.SendMailCallback(IAsyncResult result)
Hi, in the e-mail settings of cAlgo you can enable "use authentication" with username & pw. It looks as if your SMTP server now requires authentication.
@Cerunnos
Cerunnos
12 Dec 2013, 14:43
RE:
jeex said:
Is there a way for a robot to get the name or another identification of the broker or the account? I try to log data from two diferent brokers in two instances of cAlgo in two different external CSV-files. But they use the same robot.
Have you tried:
/api/reference/internals/iaccountprovider/getaccount-c8ec
@Cerunnos
Cerunnos
07 Dec 2013, 18:20
The easiest way is using multiple robots with different currencies (different instances of your robot).
But you should better learn C # and cAlgo API. Then you can easily use in your code multi symbols:
var eurJpySeries = MarketData.GetSeries("EURJPY", TimeFrame);
var eurUsdSeries = MarketData.GetSeries("EURUSD", TimeFrame);
@Cerunnos
Cerunnos
06 Dec 2013, 12:55
RE: RE: RE: RE:
jallopy said:
Has it yet?
cAlgo_Fanatic said:
jallopy said:
Hi Admin,
Is this implemented yet, could you give and example code for closing , for example , 25% of an open position?
Thank-you
admin said:
There will be an implementation for it very soon.
This feature has not been implemented yet.
@Cerunnos
Cerunnos
06 Dec 2013, 00:02
Hi! I have not tested the following code. It's just a basic framework with which you can start. You will undoubtedly need to make adjustments and for that you need the basics in C # and cAlgo API. The strategy also seems a bit too easy. Improvements are certainly necessary. Happy coding...
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC)]
public class _30K_Robot : Robot
{
private MacdHistogram _macd;
private Position _position;
private double startingBalance;
private const double BalancePercent = 0.85; // change the value = max. DrawDown
[Parameter(DefaultValue = 30000, MinValue = 0)]
public int Volume { get; set; }
[Parameter("Inital Stop Loss (pips)", DefaultValue = 10.0)]
//SL in pips
public int init_StopLoss { get; set; }
[Parameter("Period", DefaultValue = 12)]
public int Period { get; set; }
[Parameter("Long Cycle", DefaultValue = 22)]
public int LongCycle { get; set; }
[Parameter("Short Cycle", DefaultValue = 9)]
public int ShortCycle { get; set; }
protected override void OnStart()
{
_macd = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
startingBalance = Account.Balance;
}
protected void CheckBalance()
{
if (Account.Equity <= startingBalance * BalancePercent)
{
foreach (var pos in Account.Positions)
{
if(pos.Label == "my_FirstRobot")
Trade.Close(pos);
}
Stop();
Notifications.SendEmail("xy@domain.net", "xy@domain.net", "DrawDown!", "Robot was stopped! Check It!");
Print("DrawDown!");
}
}
protected override void OnTick()
{
if (Trade.IsExecuting)
return;
CheckBalance();
foreach (var position in Account.Positions)
{
if (position.Label == "my_FirstRobot" && position.GrossProfit >= 24)
{
Trade.Close(position);
}
}
bool isLongPositionOpen = _position != null && _position.TradeType == TradeType.Buy;
bool isShortPositionOpen = _position != null && _position.TradeType == TradeType.Sell;
if (_macd.Histogram.LastValue > 0.0 && _macd.Signal.IsRising() && !isLongPositionOpen)
{
ClosePosition();
Buy();
}
if (_macd.Histogram.LastValue < 0.0 && _macd.Signal.IsFalling() && !isShortPositionOpen)
{
ClosePosition();
Sell();
}
}
private void ClosePosition()
{
if (_position != null)
{
Trade.Close(_position);
_position = null;
}
}
private void Buy()
{
var request = new MarketOrderRequest(TradeType.Buy, Volume)
{
Label = "my_FirstRobot",
StopLossPips = init_StopLoss
};
Trade.Send(request);
}
private void Sell()
{
var request = new MarketOrderRequest(TradeType.Sell, Volume)
{
Label = "my_FirstRobot",
StopLossPips = init_StopLoss
};
Trade.Send(request);
}
}
}
@Cerunnos
Cerunnos
05 Dec 2013, 20:33
RE:
Kevin said:
Awesome, thanks! :D
I noticed you replied to my other post too and I have a similar problem with this in that I don't know how to add it to the code I already have.
Also, I can change the email address as that is quite clear, but where do I edit/add the account balance or percentage?
In the declaration block add following code:
private double startingBalance;
private const double BalancePercent = 0.85; // change the value = max. DrawDown
@Cerunnos
Cerunnos
05 Dec 2013, 20:03
RE:
Kevin said:
Hi, does anyone know of a way to code in a kind of "fire-sale". I.e. when your equity hits a certain low, all trades are closed.
The idea being that a certain amount of equity is always protected, so I could (for example) go on holiday and leave a robot running without having to worry about it clearing my account. Although stop-losses should prevent this, it's possible with a series of bad trades and it would be typical that this would happen while I'm not watching.
protected override void OnStart()
{
startingBalance = Account.Balance;
}
protected void CheckBalance()
{
if (Account.Equity <= startingBalance * BalancePercent)
{
foreach (var pos in Account.Positions)
{
// If(pos.Label == "m10_Robot")
Trade.Close(pos);
}
Stop();
Notifications.SendEmail("xy@domain.net", "xy@domain.net", "DrawDown!", "Robot was stopped! Check It!");
Print("DrawDown!");
}
}
Hope that helps :-)
@Cerunnos
Cerunnos
19 Dec 2013, 11:29
RE:
StormeNet said:
Which indicator do use in cTrader? Then it's possible to disable the notification in the code...
@Cerunnos