Topics
Replies
aysos75
14 Jul 2015, 21:55
RE:
torokbalint1986
If you want to use double volume, you can use this instructions :
double volume = moneyManagement(RiskPercent, StopLoss);
long normalizedVolume = Symbol.NormalizeVolume(volume, RoundingMode.ToNearest)
ExecuteMarketOrder(tradeType, Symbol, normalizedVolume, _instanceLabel, StopLoss, TakeProfit, 10, comment);
@aysos75
aysos75
14 Jul 2015, 21:41
RE:
SaifBD said:
I can make break even price only for buy and only for sell. Here's my code. But I can't make break even price between buy & sell together. Please help me. How can I make this?
private double pnt_12(TradeType TrdTp) { double Result = 0; double AveragePrice = 0; long Count = 0; for (int i = Positions.Count - 1; i >= 0; i--) { position = Positions[i]; if (position.Label == Label && position.SymbolCode == Symbol.Code) { if (position.TradeType == TrdTp) { AveragePrice += position.EntryPrice * position.Volume; Count += position.Volume; } } } if (AveragePrice > 0 && Count > 0) Result = Math.Round(AveragePrice / Count, Symbol.Digits); return Result; }
This code
pnt_12(TradeType TrdTp)
calculate the average price oppositions of type TrdTp. What is the correspondance to Break Even ?
@aysos75
aysos75
14 Jul 2015, 18:52
The solution is simple, I use extensions method to TimeFrame :
#region Licence
//The MIT License (MIT)
//Copyright (c) 2014 abdallah HACID, https://www.facebook.com/ab.hacid//Permission is hereby granted, free of charge, to any person obtaining a copy of this software
//and associated documentation files (the "Software"), to deal in the Software without restriction,
//including without limitation the rights to use, copy, modify, merge, publish, distribute,
//sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
//is furnished to do so, subject to the following conditions://The above copyright notice and this permission notice shall be included in all copies or
//substantial portions of the Software.//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.// Project Hosting for Open Source Software on Github : https://github.com/abhacid/cAlgoBot
#endregionusing System;
using cAlgo.API;
using cAlgo.API.Internals;namespace cAlgo.Lib
{
/// <summary>
/// Méthodes d'extensions du type cAlgo.API.TimeFrame
/// </summary>
public static class TimeFrameExtensions
{
public enum TimeFrameEnum
{
Minute,
Minute2,
Minute3,
Minute4,
Minute5,
Minute6,
Minute7,
Minute8,
Minute9,
Minute10,
Minute15,
Minute20,
Minute30,
Minute45,
Hour,
Hour12,
Hour2,
Hour3,
Hour4,
Hour6,
Hour8,
Daily,
Day2,
Day3,
Weekly,
Monthly,
}public static TimeFrameEnum ToTimeFrameEnum(this TimeFrame timeFrame)
{
TimeFrameEnum timeFrameEnum;Enum.TryParse<TimeFrameEnum>(timeFrame.ToString(), out timeFrameEnum);
return timeFrameEnum;
}
public static TimeSpan ToTimeSpan(this TimeFrame timeFrame)
{
TimeSpan timeSpan;
long ticks=0;
// instruction to transform each TimeFrame.Time in TimeSpan.switch(timeFrame.ToTimeFrameEnum())
{
case TimeFrameEnum.Minute:
ticks = TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute2:
ticks = 2 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute3:
ticks =3 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute4:
ticks = 4 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute5:
ticks = 5 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute6:
ticks = 6 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute7:
ticks = 7 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute8:
ticks = 8 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute9:
ticks = 9 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute10:
ticks = 10 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute15:
ticks = 15 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute20:
ticks = 20 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute30:
ticks = 30 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Minute45:
ticks = 45 * TimeSpan.TicksPerMinute;
break;case TimeFrameEnum.Hour:
ticks = TimeSpan.TicksPerHour;
break;case TimeFrameEnum.Hour2:
ticks = 2 * TimeSpan.TicksPerHour;
break;case TimeFrameEnum.Hour3:
ticks = 3 * TimeSpan.TicksPerHour;
break;case TimeFrameEnum.Hour4:
ticks = 4 * TimeSpan.TicksPerHour;
break;
case TimeFrameEnum.Hour6:
ticks = 6 * TimeSpan.TicksPerHour;
break;case TimeFrameEnum.Hour8:
ticks = 8 * TimeSpan.TicksPerHour;
break;case TimeFrameEnum.Hour12:
ticks = 12 * TimeSpan.TicksPerHour;
break;case TimeFrameEnum.Daily:
ticks = TimeSpan.TicksPerDay;
break;case TimeFrameEnum.Day2:
ticks = 2 * TimeSpan.TicksPerDay;
break;case TimeFrameEnum.Day3:
ticks = 3 * TimeSpan.TicksPerDay;
break;case TimeFrameEnum.Weekly:
ticks = 7 * TimeSpan.TicksPerDay;
break;case TimeFrameEnum.Monthly:
ticks = (long)(30.5 * TimeSpan.TicksPerDay);
break;
}timeSpan = TimeSpan.FromTicks(ticks);
return timeSpan;
}
}
}
And I can use in my indicator instructions like this :
[Parameter()]
public TimeFrame Global { get; set; }protected override void Initialize()
{
marketSerieGlobal = MarketData.GetSeries(Global);
int period = (int) (Global.ToTimeSpan().Ticks / MarketSeries.TimeFrame.ToTimeSpan().Ticks);_localMA = Indicators.MovingAverage(LocalTrendSignal, period, MovingAverageType.Exponential);
}
@aysos75
aysos75
11 Jul 2015, 16:38
RE: RE: RE:
susantasaren said:
hichem said:Kate said:There are brokers with minimum account much less than 2000€.
I know, but the strategy requires a minimum of 2000 to eliminate risk of a margin call.
Why not decrease the Lot Size equivaltent to 2000 the result will be the same.
Some robot take positions whose volume depends on the capital account, therefore the results of such robots depends on the initial nonlinear fashion capital. In other words double the initial capital has the effect of also affect the results in gains or losses.
@aysos75
aysos75
11 Jul 2015, 15:01
RE: RE: RE: RE:
breakermind said:
Spotware said:
breakermind said:
Hi and thanks,
I have this:
public override void Calculate(int index) { // access to different series var weeklySeries = MarketData.GetSeries(TimeFrame.Weekly); // open price bars double open = weeklySeries.Open[index]; Print(open); // If first bar is first bar of the day set open Week1Open[index] = open; }How get Week open price and draw line on this price ? what is wrong ?
index is wrong. The weeklySeries object has different indexes.
Cool,
something is wrong with this spotware cAlgo,
if do not hang it terribly slow ... shows some strange results ... in backtests
Support helpful as usual ...
... defeat.
Bye.
In the 'Calculate', 'index' is the index of the current timeframe candles eg M1. But if you want to retrieve values OLHC (Open High Low Close) a candle from another timeframe eg H1, we can not do it with 'index' because the index of the two series corresponding to the two timeframes are distinct. We must use the conversion method GetIndexByExactTime ( (MarketSeries.OpenTime [index]) or GetIndexByTime (MarketSeries.OpenTime [index]).
@aysos75
aysos75
11 Jul 2015, 14:51
( Updated at: 21 Dec 2023, 09:20 )
RE:
Spotware said:
Dear Trader,
Thank you for reporting this. We will investigate.
When I do a backtest , cAlgo gives as result the new position of thousands with the same second input (even EntryPrice ) , even though the robot is programmed to take no more 1 position both ???
@aysos75
aysos75
19 Jul 2015, 14:11
In CSharp you can determine the length of a string by this instruction
@aysos75