Topics
Replies
alexander.n.fedorov
26 Feb 2018, 11:11
How do you add the screenshots?
I did not figure out how to post the screens.
@alexander.n.fedorov
alexander.n.fedorov
16 Feb 2018, 17:27
email notifications
If I don't want them (like when I am testing something with a lot of small orders) how do I get rid of them?
@alexander.n.fedorov
alexander.n.fedorov
16 Feb 2018, 11:52
1 derivative
By the way, is there any indicator or property which will show the first and maybe the second derivative on moving average?
@alexander.n.fedorov
alexander.n.fedorov
16 Feb 2018, 11:48
I happened to find a pair for testing on Demo, and ...it works!
@alexander.n.fedorov
alexander.n.fedorov
16 Feb 2018, 11:28
Dear Panagiiotis!
I thank you very much, you are very kind. But I am very new to c#, especially to cAlgo. It must take a lot of explanation on your side how to that (It would have been for me much easier to do a complete SQL development)
So, if could explain in more details , it would be very usefull not only for me.
Otherwise let me get some more experience.
Best regards,
Alexander
@alexander.n.fedorov
alexander.n.fedorov
16 Feb 2018, 11:18
BB timeframe
Thank you. It seems to be working, at list build was "OK"
Now I will have to test it. How do I test it if there is now visualisation?
To wait before the price go out of frame may take a long time ... :)
@alexander.n.fedorov
alexander.n.fedorov
13 Feb 2018, 11:16
Backtesting
I am trying to not stop the order or position manually, but when I did have the above part, when I closed position by hand, it started to generate orders, because of event
I tryied to protect against closing by Stop Loss and Take Profit
I think it was either breakeven, or trailing, which I think I now should try how to handle. In any case, you very good, and thank's a lot.
But I will be righting to you in the future
Alexander
@alexander.n.fedorov
alexander.n.fedorov
13 Feb 2018, 10:51
Backtesting
In addition to timing info, which was tonight and is available from the cBot log, broker is ICMarkets, timeframe - 1 hr, lot=0.01
@alexander.n.fedorov
alexander.n.fedorov
13 Feb 2018, 10:32
Backtesting
Dear Panagiotis.
I will do in about an hour
@alexander.n.fedorov
alexander.n.fedorov
07 Feb 2018, 21:10
In my bot the position is closed when it meets a cirtain criteria
In that case I do
....
Private bool ClosedByRobot=false
...//when the criteria is met then
ClosedByRobot=true
But for the SL there is no way I could do that, even to on the server they know it
@alexander.n.fedorov
alexander.n.fedorov
07 Feb 2018, 21:05
Stop Loss
Yes, I also agree with Panagiotis, there must be a direct event, which actually is somewhere, cause every time the order is filled with SL or TP I got a mail, saying that my position was close due to .... (SL or TP) was filled. I will try to make them suggestion, but will they listen?
@alexander.n.fedorov
alexander.n.fedorov
05 Feb 2018, 12:11
What a beautiful solution and explanation! Thank you
Everything is working fine now.
Alexander
@alexander.n.fedorov
alexander.n.fedorov
29 Jan 2018, 13:43
I am new to C#. I was trying to use what I thought would be the normal shortcut for bunch of if.
Thank you very much for your reply. It is really a pleasure to recieve good service
I already figured out how to if (longer way)
Regards
@alexander.n.fedorov
alexander.n.fedorov
28 Jan 2018, 16:04
RE: I am still curious if anybody can help, please?
alexander.n.fedorov said:
My bot is moving a Stop Loss to breakeven
The problem: it does fine for "Sell" orders, but shows an error for "Buy" orders.
Can anybody help?
here is the code:
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
/// <summary>
/// This is a doubling the lot bot, with the stoploss halfed after the double
/// today the 20 th of Jan 2018 I am adding a breakeven to it
/// </summary>
namespace cAlgo
{
#region parameters
[Robot(TimeZone = TimeZones.RussianStandardTime, AccessRights = AccessRights.FullAccess)]
public class StartAChain : Robot
{
[Parameter(DefaultValue = 100000)]
public int LotSize { get; set; }
[Parameter(DefaultValue = 10.0)]
public double SL { get; set; }
[Parameter(DefaultValue = 10.0)]
public double TP { get; set; }
[Parameter("Instance Name", DefaultValue = "001")]
public string InstanceName { get; set; }
[Parameter("Source SMA #1")]
public DataSeries SourceSma1 { get; set; }
[Parameter("Period SMA #1", DefaultValue = 5, MinValue = 1, MaxValue = 100)]
public int PeriodsSma1 { get; set; }
[Parameter()]
private int currentLot { get; set; }
[Parameter()]
private double currentStop { get; set; }
[Parameter("Include Break-Even", DefaultValue = false)]
public bool IncludeBreakEven { get; set; }
[Parameter("Break-Even Trigger (pips)", DefaultValue = 10, MinValue = 1)]
public int Trigger { get; set; }
[Parameter("Break-Even Extra (pips)", DefaultValue = 2, MinValue = 0)]
public int BreakEvenExtraPips { get; set; }
private TradeType _tradeType;
#endregion
#region Indicator declarations
private SimpleMovingAverage _sma1 { get; set; }
public bool Buy { get; private set; }
#endregion
#region cTrader events
/// <summary>
/// This is called when the robot first starts, it is only called once.
/// </summary>
protected override void OnStart()
{
// construct the indicators
_sma1 = Indicators.SimpleMovingAverage(SourceSma1, PeriodsSma1);
currentLot = LotSize;
currentStop = SL;
// Positions.Closed += positionsOnClosed;
_tradeType = Buy ? TradeType.Buy : TradeType.Sell;
}
protected override void OnTick()
{
ManagePositions();
if (IncludeBreakEven == true)
GoToBreakEven();
}
protected override void OnStop()
{
// unused
}
#endregion
#region Manage Positions
private void ManagePositions()
{
if (!IsPositionOpenByType(TradeType.Buy) && !IsPositionOpenByType(TradeType.Sell))
{
if (_sma1.Result.LastValue < Symbol.Ask)
{
ExecuteMarketOrder(TradeType.Buy, Symbol, currentLot, InstanceName, currentStop, TP);
}
else
{
ExecuteMarketOrder(TradeType.Sell, Symbol, currentLot, InstanceName, currentStop, TP);
}
}
}
private bool IsPositionOpenByType(TradeType type)
{
var p = Positions.FindAll(InstanceName, Symbol, type);
if (p.Count() >= 1)
return true;
return false;
}
#endregion
#region Break Even
private void GoToBreakEven()
{
var position = Positions.Find(InstanceName, Symbol);
var entryPrice = position.EntryPrice;
var distance = _tradeType != TradeType.Sell ? Symbol.Bid - entryPrice : entryPrice - Symbol.Ask;
Print("distance {0} ", distance);
if (distance >= Trigger * Symbol.PipSize)
ModifyPosition(position, entryPrice, position.TakeProfit);
}
#endregion
}
}
@alexander.n.fedorov
alexander.n.fedorov
03 Jan 2018, 12:11
( Updated at: 03 Jan 2018, 12:12 )
If visualization is not working in backtesting, could you please advise an instrument to convert a cBot to a MT4 expert advisor?
@alexander.n.fedorov
alexander.n.fedorov
26 Feb 2018, 11:58
Backtesting
The funny thing is that I did not change anything on both computers, and all of a sudden optimization is woking OK now.
What could it possibly be?
@alexander.n.fedorov