Topics
Replies
mparama
18 Nov 2020, 00:40
RE:
mgpublic said:
Hi,
I need help with the code below so that it only closes the position with the indicated SymbolName for example "USDJPY"
I'm using the code below and it closes all positions.
if ()
{
foreach (var position in Positions)
ClosePositionAsync(position);
}Thx for help!
//mgpublic
You should use:
var posBuy = Positions.FindAll(Label, SymbolName, TradeType.Buy);
var posSell = Positions.FindAll(Label, SymbolName, TradeType.Sell);
if ()
{
foreach (var position in posBuy)
ClosePositionAsync(position);
}
@mparama
mparama
17 Oct 2020, 05:03
RE:
xabbu said:
found it - no chart events allowed...
is there the possibility to check if the cBot is in optimization mode (like isBacktesting) or any other trick not to out comment the lines with chart.xxxx?
Kindest regards,
if (RunningMode != RunningMode.Optimization)
{
.......Chart events.....
}
@mparama
mparama
01 May 2020, 03:26
RE:
driftingprogrammer said:
Hi,
I am facing the same problem in my Indicator.
Half the year the server runs on UTC+2 time zone and half the year it runs on UTC+3 time zone. The transition happens randomly during a certain weekend.
When my Indicator is invoked for MarketSeries.OpenTime.LastSeries being 0030hr on 4th november, i want to know if it is in UTC+2 timezone or UTC+3 timezone, or in other words i want to know if the daylight saving is on or off because only then i can know if the data is applicable to 3rd November or 4the November.
Any help is appreciated.
Thanks in advance,
Warm Regards,
Vipin.
Try this:
if (Server.TimeInUtc.IsDaylightSavingTime())
{
currentHours = Server.TimeInUtc.AddHours(+3).TimeOfDay.Hours;
currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
}
if (!Server.TimeInUtc.IsDaylightSavingTime())
{
currentHours = Server.TimeInUtc.AddHours(+2).TimeOfDay.Hours;
currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
}
@mparama
mparama
13 Mar 2020, 20:32
RE: AtoZ awards cTrader
Spotware said:
Dear Trader,
It is with great pleasure that we share a new addition to our awards’ portfolio - “Best Forex Trading Platform” from AtoZ Markets.
AtoZ Markets have been conducting their annual forex awards for several years, with the aim of recognizing financial markets’ industry leaders, and it is an honour for cTrader to have been chosen by the community as the top trading platform provider.
This motivates us to improve further, delivering even more innovative, transparent and value-adding solutions for your complete, all-in-one trading experience. The best is yet to come!
Without a doubt ... you are the best platform !!!!
@mparama
mparama
20 Feb 2020, 01:54
RE: RE: New API 3.7: Backtest and Optimization are working OK.
TzvetomirTerziysky said:
mparama said:
Dear Panagiotis,
I have tested BackTest in Beta and it seems working even faster then version 3.6.
I have tested as well the optimization with MultiTimeframe and everything seems working OK.
Thank you very much to you and all the staff of Spotware for the efforts to give us always a better service.
Regards
Can you please share how you define the MultiTime frame?
My Bars are empty in Optimisation if they are different time frame( and throw Null Exception), while the work perfectly fine under BackTesting
Hi,
as soon as they released di HotFix the Optimization seems working again. Some days later it was not working again probably because they were working in progress.
Yesterday from Beta version I have downloaded an upgrade and it seems they fixed the optimization.
@mparama
mparama
14 Feb 2020, 02:14
New API 3.7: Backtest and Optimization are working OK.
Dear Panagiotis,
I have tested BackTest in Beta and it seems working even faster then version 3.6.
I have tested as well the optimization with MultiTimeframe and everything seems working OK.
Thank you very much to you and all the staff of Spotware for the efforts to give us always a better service.
Regards
@mparama
mparama
10 Feb 2020, 03:47
RE:
lithast said:
Hi guys,
My cTrader application took an update this morning, and backtesting is extremely, extremely slow after the update. The version indicated is 3.7 and the update seems to have made MarketSeries obsolete in favour of a new API for "Bars". I've updated my bots to use Bars instead of MarketSeries.
Backtests that were taking 10 seconds to complete previously are now taking 5 minutes to complete. Results are identical.
Any ideas?
Thanks
That's my problem as well and not using any Indicators...!!!!
@mparama
mparama
10 Feb 2020, 03:15
( Updated at: 21 Dec 2023, 09:21 )
RE: 3.7 changed something in code, now half of my Algo`s dont work anymore..can anyone tell me what to do?
w.b.z said:
I got the same problem with optimization using multi-timeframe.
Backtest is ok
Trading is ok
when I try to optimize I get "Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object" and I found that the problem is related to the New API with Multi-TimeFrames,:
I replaced the old MarketSeries (everything was working fine) with the New API line guide (Optimization not working)
@mparama
mparama
27 Sep 2019, 06:30
Found It !!!
//---------------------------------------------
var January = Server.TimeInUtc.Month.Equals(1);
var May = Server.TimeInUtc.Month.Equals(5);
var September = Server.TimeInUtc.Month.Equals(9);
//---------------------------------------------
.................................................
...............................................
if (!January && !May && !September)
{
Thanks anyway !!!!
@mparama
mparama
27 Sep 2019, 04:20
[Parameter("===== SELL Time =====", DefaultValue = "============")]
public string sep1 { get; set; }
[Parameter("SELL", DefaultValue = true)]
public bool Sell { get; set; }
[Parameter("Start Hour", DefaultValue = 10, MinValue = 2, MaxValue = 21)]
public int StartTimeHour_Sell { get; set; }
[Parameter("Start Minutes", DefaultValue = 15, MinValue = 0, MaxValue = 59)]
public int StartTimeMinutes_Sell { get; set; }
//-------------
[Parameter("======= BUY Time ======", DefaultValue = "============")]
public string sep2 { get; set; }
[Parameter("Buy", DefaultValue = false)]
public bool Buy { get; set; }
[Parameter("Start Hour", DefaultValue = 13, MinValue = 2, MaxValue = 21)]
public int StartTimeHour_Buy { get; set; }
[Parameter("Start Minutes", DefaultValue = 30, MinValue = 0, MaxValue = 59)]
public int StartTimeMinutes_Buy { get; set; }
//=========================================================================
........................................
........................................
//============== =====================
var currentHours = Server.TimeInUtc.TimeOfDay.Hours;
var currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
//------- Time in UTC -------
if (Server.TimeInUtc.IsDaylightSavingTime())
{
//----- Server Time Ora Legale ------
currentHours = Server.TimeInUtc.AddHours(+1).TimeOfDay.Hours;
currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
}
if (Server.TimeInUtc.IsDaylightSavingTime() == false)
{
//----- Server Time NO Ora Legale ------
currentHours = Server.TimeInUtc.AddHours(+2).TimeOfDay.Hours;
currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
}
//-----------------------------------------------
var Time_Buy = currentHours == StartTimeHour_Buy && currentMinute == StartTimeMinutes_Buy;
var Time_Sell = currentHours == StartTimeHour_Sell && currentMinute == StartTimeMinutes_Sell;
@mparama
mparama
14 Jul 2019, 04:18
[Parameter("Kelt Priod", DefaultValue = 35, MinValue = 1, MaxValue = 100, Step = 1)]
public int KeltPeriod { get; set; }
[Parameter("Kelt ATR Priod", DefaultValue = 35, MinValue = 1, MaxValue = 100, Step = 1)]
public int KeltATRPeriod { get; set; }
ExponentialMovingAverage SlowMA, FastMA, KeltEMA;
SimpleMovingAverage KeltSMA;
KeltnerChannels Kelt;
protected override void OnStart()
{
SlowMA = Indicators.ExponentialMovingAverage(MarketSeries.Close, SlowMAPeriods);
FastMA = Indicators.ExponentialMovingAverage(MarketSeries.Close, FastMAPeriods);
Kelt = Indicators.KeltnerChannels(KeltPeriod, KeltEMA ??, KeltATRPeriod, KeltSMA ??, 2);
}
KeltEMA has no value
KeltSMA has no value
you should insert them in the parameter giving a value as:
[Parameter("Kelt Priod", DefaultValue = 35, MinValue = 1, MaxValue = 100, Step = 1)]
public int KeltPeriod { get; set; }
[Parameter("Kelt ATR Priod", DefaultValue = 35, MinValue = 1, MaxValue = 100, Step = 1)]
public int KeltATRPeriod { get; set; }
These does'nt give any value:
ExponentialMovingAverage SlowMA, FastMA, KeltEMA;
SimpleMovingAverage KeltSMA;
To check if it works give compatible numerical value:
Kelt = Indicators.KeltnerChannels(KeltPeriod, num. value, KeltATRPeriod, num. value, 2);
All the parameters in the indicator that give a value should coincide with
(KeltPeriod, num. value, KeltATRPeriod, num. value, 2);
@mparama
mparama
07 Dec 2018, 18:33
( Updated at: 21 Dec 2023, 09:21 )
RE:
Panagiotis Charalampous said:
Hi Luigi,
A cBot is nothing less than a C# project. So if you edit it using Visual Studio you can have all the options available for a C# project. This means that you can have separate classes for reusable code. See below an example of calling a function of another class inside the cBot.
This way you can organize your code in a proper object oriented approach. Let me know if you need any additional assistance.
Best Regards,
Panagiotis
Thank youv very much !!!!
@mparama
mparama
22 Nov 2018, 11:34
RE:
Panagiotis Charalampous said:
Hi Luigi,
You will need to use some loops. See below.
var highest = MarketSeries.High.Last(1); for (int i = 2; i <= 12; i++) { if (MarketSeries.High.Last(i) > highest) highest = MarketSeries.High.Last(i); } var lowest = MarketSeries.Low.Last(1); for (int i = 2; i <= 12; i++) { if (MarketSeries.Low.Last(i) < lowest) lowest = MarketSeries.Low.Last(i); }Let me know if this helps,
Best Regards,
Panagiotis
Thank you very much !!!!
have a nice day
Luigi
@mparama
mparama
26 Mar 2021, 20:31
RE:
PanagiotisCharalampous said:
Thank you !!!
@mparama