
abdalah hacid

Info
Username: | aysos75 |
Name: | abdalah hacid |
Member since: | 28 Sep 2013 |
Country: | France |
Favorite symbols:
About
Signature
Last Algorithm Comments
@El Conejo - Scalper: 11 Sep 2015, 14:53
Thank's for your bot,
In line 184 I think the trailing stop is not set correctly for a sell position :
before : double newStopLossPrice = Symbol.Ask + TrailingStop * Symbol.PipSize;
after : double newStopLossPrice = Symbol.Ask - TrailingStop * Symbol.PipSize;
@martingale with SL and MM: 11 Sep 2015, 14:36
If you want to compile the bot, you have to download the source on github and to read the explanations on https://github.com/abhacid/Martingale_Forex
@La Tortuga V0.5: 11 Sep 2015, 14:23
I have tested your bot, but he take no positions.
Can you make a snapshot with all your parameters ?
@martingale with SL and MM: 17 Jul 2015, 15:26
sorry for the two precedents mistakes
link to myfxbook : http://www.myfxbook.com/members/abhacid/mforex-1700/1304163
@martingale with SL and MM: 17 Jul 2015, 15:24
the new link to myfxbook statistique about martingale forex 1.7.0.0
is here
@martingale with SL and MM: 17 Jul 2015, 15:21
the new link to myfxbook statistique about martingale forex 1.7.0.0 is here
@martingale with SL and MM: 17 Jul 2015, 15:19
You can find Candlestick Tendency II here :
link to Candlestick Tendency II
Read the information about installation here
@Mechanic: 08 Jul 2015, 11:10
I have make a backtest with good result :
params :
[ChartParameters]
Symbol = EURUSD
Timeframe = m1[cBotParameters]
HighOrderTimeFrame = Hour
Volume = 10000
EnableStopLoss = True
StopLoss = 69
EnableBreakEven = False
BreakEvenPips = 10
BreakEvenGain = 20
EnableTrailingStop = False
TrailingStop = 10
TrailingStart = 10
EnableTakeProfit = True
TakeProfit = 5
EnterOnSyncSignalOnly = False
ExitOnOppositeSignal = True
The result between 1/05/2015 and 06/07/2015 is
+ 12465 euros (2571 trades and 2039 winnings trades)
The tendancy Candle is a good direction to search a profitable signal
Thanks to igorkroitor for this good bot.
@Mechanic: 08 Jul 2015, 09:35
Hello there
In code there is no difference between
UpdateTrailingStop
and
MoveToBreakEven
@MCAD PrbSAR noise: 05 Jul 2015, 15:34
I think tere is an error here in the code :
if (pos != null)
return pos.Commissions;
var po = PendingOrders.__Find("FxProQuant_" + magicIndex.ToString("F0"), symbol);
return po == null ? 0 : pos.Commissions;
if (pos==null) and (po !=null) then pos.Commissions doesn't have a value !
@MCAD PrbSAR noise: 05 Jul 2015, 14:55
Your bot is interesting, can you explain some of the idee Under this EA ?
@Golden Dragon II: 04 Jul 2015, 23:07
I have make a backtest on XAUUSD M5 (with bar from server and commission 30 per million) the results is good but drawdown very high.
@Pullback: 03 Jul 2015, 10:37
Ok thanks
Is a good idea to test-it in real mode, you can also make-it on myfxbook for statistiques.
@Pullback: 02 Jul 2015, 17:00
can you take informations on
instrument to trade
Timeframe to use
Parameters to use
in order to test the bot
Thanks
@Kaufman Adaptative Moving Average: 30 Jun 2015, 20:46
@MZen
Close.fold((acc, previewClose, close) => acc + Math.Abs(close - previewClose), (double)0, +1, index - period, index);
is an anonyme method, with abstract type, the definition is in the cAlgo.Lib (file DataSeriesExtensions).
The fold method traverses the list by applying an operator to "compress" into a single value. here he make the sum of (close(i)-previewClose(i)).
@martingale with SL and MM: 29 Jun 2015, 20:27
@8081871
Hello,
To compile the program must retrieve the bookstore on github and also the latest Martingale_Forex.
I made a Video explains how.
You can view the result in myfxbook, or in cMirror
Best Regards
@martingale with SL and MM: 27 Jun 2015, 09:07
I made a Youtube video in french to explain how to get the Visual Studio solution from Github and how to edit and debug the robot in conjunction with cAlgo.
J'ai fait une vidéo Youtube en français pour expliquer comment récupérer la solution Visual studio à partir de Github et comment modifier et déboguer le robot en liaison avec cAlgo.
@martingale with SL and MM: 23 Jun 2015, 01:00
By the weekend I would make an instructional video to make everything work between cTDN, Github and visual studio.
Basically everything is explained on github with settings files and screenshots in a specific folder of the Visual Studio solution. The robot runs on cMiror and can be replicated on one of your demo accounts
@martingale with SL and MM: 23 Jun 2015, 00:52
@hichem
Yes the screenshot refers to an early version since evolved program. for the latest version must be recovered on github.
It is in the 1.3.3.1 release.
@martingale with SL and MM: 21 Jun 2015, 13:42
I put on Martingale_Forex on CMiror:
https://cm.spotware.com/strategy/56296
it copies the positions he takes on either a demo account is a real account.
@martingale with SL and MM: 21 Jun 2015, 13:41
I put on Martingale_Forex on CMiror:
https://cm.spotware.com/strategy/56296
it copies the positions he takes on either a demo account is a real account.
@Alembex: 20 Jun 2015, 19:16
J'ai regardé le code, c'est plus une martingale qu'un money-management.
Le robot reprends le même volume à chaque fois qu'il perd et lorsqu'il gagne il prend un volume égal à l'ensemble de ses pertes depuis le dernier gain.
@RSI & Boll Bands w Threshold activation: 20 Jun 2015, 19:03
Why you don't precise the result of the bot with the parameters, the symbol and the timeframe ?
A bot without parameters, symbol and timeframe is incomplete!
@Robot_Forex: 14 Jun 2015, 23:24
Le projet modifié se trouve sur github, il peut être récupéré directement dans visual studio avec les outils intégrés à vs2013 de gestion de versionning de code sources
The modified project is on github, it can be recovered directly into visual studio with the tools built into source code versioning management in vs2013
@Robot_Forex: 14 Jun 2015, 22:18
Voici le programme Robot_Forex avec l'ajout d'un stop Loss et la correction des méthodes obsolètes :
using System;
using cAlgo.API;
using cAlgo.API.Internals;namespace cAlgo.Robots
{
[Robot("Robot Forex", AccessRights = AccessRights.None)]
public class Robot_Forex : Robot
{
[Parameter(DefaultValue = 10000, MinValue = 1000)]
public int FirstLot { get; set; }[Parameter(DefaultValue = 10000, MinValue = 1000)]
public int LotStep { get; set; }//[Parameter(DefaultValue = 300)]
//public int PipStep { get; set; }[Parameter("Stop_Loss", DefaultValue = 50, MinValue = 0)]
public int Stop_Loss { get; set; }[Parameter("Take_Profit", DefaultValue = 180, MinValue = 10)]
public int TakeProfit { get; set; }[Parameter("Tral_Start", DefaultValue = 50, MinValue = 10)]
public int Tral_Start { get; set; }[Parameter("Tral_Stop", DefaultValue = 50, MinValue = 10)]
public int Tral_Stop { get; set; }
[Parameter(DefaultValue = 5, MinValue = 2)]
public int MaxOrders { get; set; }private Position position;
private bool RobotStopped;
private string botLabel;
protected override void OnStart()
{
botLabel = ToString();// The stop loss must be greater than tral stop
//Stop_Loss = Math.Max(Tral_Stop, Stop_Loss);Positions.Opened += OnPositionOpened;
}protected override void OnTick()
{
double Bid = Symbol.Bid;
double Ask = Symbol.Ask;
double Point = Symbol.TickSize;if (Trade.IsExecuting)
return;if (Positions.Count > 0 && RobotStopped)
return;
else
RobotStopped = false;if (Positions.Count == 0)
SendFirstOrder(FirstLot);
else
ControlSeries();foreach (var position in Positions)
{
if (position.SymbolCode == Symbol.Code)
{if (position.TradeType == TradeType.Buy)
{
if (Bid - GetAveragePrice(TradeType.Buy) >= Tral_Start * Point)
if (Bid - Tral_Stop * Point >= position.StopLoss)
ModifyPosition(position, Bid - Tral_Stop * Point, position.TakeProfit);
}if (position.TradeType == TradeType.Sell)
{
if (GetAveragePrice(TradeType.Sell) - Ask >= Tral_Start * Point)
if (Ask + Tral_Stop * Point <= position.StopLoss || position.StopLoss == 0)
ModifyPosition(position, Ask + Tral_Stop * Point, position.TakeProfit);
}
}
}
}protected override void OnError(Error CodeOfError)
{
if (CodeOfError.Code == ErrorCode.NoMoney)
{
RobotStopped = true;
Print("ERROR!!! No money for order open, robot is stopped!");
}
else if (CodeOfError.Code == ErrorCode.BadVolume)
{
RobotStopped = true;
Print("ERROR!!! Bad volume for order open, robot is stopped!");
}
}private void SendFirstOrder(int OrderVolume)
{
int Signal = GetStdIlanSignal();
if (!(Signal < 0))
switch (Signal)
{
case 0:
ExecuteMarketOrder(TradeType.Buy, Symbol, OrderVolume, botLabel);
break;
case 1:
ExecuteMarketOrder(TradeType.Sell, Symbol, OrderVolume, botLabel);
break;
}
}private void OnPositionOpened(PositionOpenedEventArgs args)
{
double? StopLossPrice = null;
double? TakeProfitPrice = null;if (Positions.Count == 1)
{
position = args.Position;if (position.TradeType == TradeType.Buy)
TakeProfitPrice = position.EntryPrice + TakeProfit * Symbol.TickSize;
if (position.TradeType == TradeType.Sell)
TakeProfitPrice = position.EntryPrice - TakeProfit * Symbol.TickSize;
}
else
switch (GetPositionsSide())
{
case 0:
TakeProfitPrice = GetAveragePrice(TradeType.Buy) + TakeProfit * Symbol.TickSize;
break;
case 1:
TakeProfitPrice = GetAveragePrice(TradeType.Sell) - TakeProfit * Symbol.TickSize;
break;
}for (int i = 0; i < Positions.Count; i++)
{
position = Positions[i];
if (StopLossPrice != null || TakeProfitPrice != null)
ModifyPosition(position, position.StopLoss, TakeProfitPrice);
}
}private double GetAveragePrice(TradeType TypeOfTrade)
{
double Result = Symbol.Bid;
double AveragePrice = 0;
long Count = 0;for (int i = 0; i < Positions.Count; i++)
{
position = Positions[i];
if (position.TradeType == TypeOfTrade)
{
AveragePrice += position.EntryPrice * position.Volume;
Count += position.Volume;
}
}
if (AveragePrice > 0 && Count > 0)
Result = AveragePrice / Count;
return Result;
}private int GetPositionsSide()
{
int Result = -1;
int i, BuySide = 0, SellSide = 0;for (i = 0; i < Positions.Count; i++)
{
if (Positions[i].TradeType == TradeType.Buy)
BuySide++;
if (Positions[i].TradeType == TradeType.Sell)
SellSide++;
}
if (BuySide == Positions.Count)
Result = 0;
if (SellSide == Positions.Count)
Result = 1;
return Result;
}/// <summary>
/// The gradient variable is a dynamic value that represente an equidistant grid between
/// the high value and the low value of price.
/// </summary>
///
private void ControlSeries()
{
const int BarCount = 25;
int gradient = MaxOrders - 1;foreach (Position position in Positions.FindAll(botLabel, Symbol))
{
if (-position.Pips > Stop_Loss)
ClosePosition(position);}
//if (PipStep == 0)
int _pipstep = GetDynamicPipstep(BarCount, gradient);
//else
// _pipstep = PipStep;if (Positions.Count < MaxOrders)
{
//int rem;
long NewVolume = Symbol.NormalizeVolume(FirstLot + FirstLot * Positions.Count, RoundingMode.ToNearest);
int positionSide = GetPositionsSide();switch (positionSide)
{
case 0:
if (Symbol.Ask < FindLastPrice(TradeType.Buy) - _pipstep * Symbol.TickSize)
{
//NewVolume = Math.DivRem((int)(FirstLot + FirstLot * Positions.Count), LotStep, out rem) * LotStep;if (NewVolume >= LotStep)
ExecuteMarketOrder(TradeType.Buy, Symbol, NewVolume, botLabel);
}
break;case 1:
if (Symbol.Bid > FindLastPrice(TradeType.Sell) + _pipstep * Symbol.TickSize)
{
//NewVolume = Math.DivRem((int)(FirstLot + FirstLot * Positions.Count), LotStep, out rem) * LotStep;if (NewVolume >= LotStep)
ExecuteMarketOrder(TradeType.Sell, Symbol, NewVolume, botLabel);
}
break;
}
}}
private int GetDynamicPipstep(int CountOfBars, int gradient)
{
int Result;
double HighestPrice = 0, LowestPrice = 0;
int StartBar = MarketSeries.Close.Count - 2 - CountOfBars;
int EndBar = MarketSeries.Close.Count - 2;for (int i = StartBar; i < EndBar; i++)
{
if (HighestPrice == 0 && LowestPrice == 0)
{
HighestPrice = MarketSeries.High[i];
LowestPrice = MarketSeries.Low[i];
continue;
}
if (MarketSeries.High[i] > HighestPrice)
HighestPrice = MarketSeries.High[i];
if (MarketSeries.Low[i] < LowestPrice)
LowestPrice = MarketSeries.Low[i];
}Result = (int)((HighestPrice - LowestPrice) / Symbol.TickSize / gradient);
return Result;
}private double FindLastPrice(TradeType TypeOfTrade)
{
double LastPrice = 0;for (int i = 0; i < Positions.Count; i++)
{
position = Positions[i];
if (TypeOfTrade == TradeType.Buy)
if (position.TradeType == TypeOfTrade)
{
if (LastPrice == 0)
{
LastPrice = position.EntryPrice;
continue;
}
if (position.EntryPrice < LastPrice)
LastPrice = position.EntryPrice;
}
if (TypeOfTrade == TradeType.Sell)
if (position.TradeType == TypeOfTrade)
{
if (LastPrice == 0)
{
LastPrice = position.EntryPrice;
continue;
}
if (position.EntryPrice > LastPrice)
LastPrice = position.EntryPrice;
}
}
return LastPrice;
}private int GetStdIlanSignal()
{
int Result = -1;
int LastBarIndex = MarketSeries.Close.Count - 2;
int PrevBarIndex = LastBarIndex - 1;if (MarketSeries.Close[LastBarIndex] > MarketSeries.Open[LastBarIndex])
if (MarketSeries.Close[PrevBarIndex] > MarketSeries.Open[PrevBarIndex])
Result = 0;
if (MarketSeries.Close[LastBarIndex] < MarketSeries.Open[LastBarIndex])
if (MarketSeries.Close[PrevBarIndex] < MarketSeries.Open[PrevBarIndex])
Result = 1;
return Result;
}
}
}
@Robot_Forex: 14 Jun 2015, 19:32
@Juddly01
The problem is
ExecuteMarketOrder (TradeType.Buy, Symbol, OrderVolume);
replace by
Trade.CreateBuyMarketOrder(Symbol, OrderVolume);
@PayBack II: 03 Oct 2014, 10:06
Bonjour,
J'ai fait une vidéo explicative sur Youtube :
Utilisation de la librairie cAlgoBot
@RsiAtr II: 18 Sep 2014, 16:32
hello,
My English is not very good, I made a youtube video that explains how to compile all the robots and indicators, it is in French, but you can understand with the video without sound.
https://www.youtube.com/watch?v=BMgI88rZs7U
kind regards
@Zelphin Scalper II: 05 Aug 2014, 15:26
Hi,
I do not claim to be the best, I test things out of nothing and look what happens that's it!
@ZigZag Kwan MBFX Timing: 25 Jul 2014, 11:12
Author : https://www.facebook.com/ab.hacid
Solution Visual studio : https://calgorobots.codeplex.com/SourceControl/latest
@TrailCut II: 25 Jul 2014, 11:11
Solution Visual studio : https://calgorobots.codeplex.com/SourceControl/latest
@TrailCut II: 18 Jul 2014, 19:27
il s'agit de la librairie mq4, les sources doivent être inclus avec l'indicateur ZigzagKwanMBFXTiming
Si ce n'est pas le cas: le projet visual studio de MQ4 en téléchargement :
http://sendbox.fr/pro/7oyl6oe909m8/MQ4.zip.html
@TrailCut II: 18 Jul 2014, 14:51
les indicateurs utilisés sont ici :
Williams Percent Range with signals : /algos/indicators/show/523
ZigZag : /algos/indicators/show/157
ZigZag Kwan MBFX Timing : /algos/indicators/show/535
@Williams Percent Range with signals: 18 Jul 2014, 11:38
Utiliser "WPR Magic Number" strictement positif (1 ou 2) pour augmenter les gains.
je proposerai bientôt le robot associé qui permet d'obtenir +27669€ entre le 1/1/2014 et 17/07/2014
Remarquer que cet indicateur est meilleur pour les signaux d'achat que ceux de vente,
@Zephyn Scalper: 17 Jul 2014, 12:18
Ne pas oublier aussi de modifier dans la fonction Open(TradeType tradeType)
ExecuteMarketOrder(tradeType, Symbol, Volume, "ZephynScalper", null, TakeProfit);
par
ExecuteMarketOrder(tradeType, Symbol, Volume, "ZephynScalper", StopLoss, TakeProfit);
@Zephyn Scalper: 17 Jul 2014, 12:13
Le code calculant le nouveau StopLoss est erroné :
à la place de
foreach (var _p in Positions.FindAll("ZephynScalper", Symbol, TradeType.Buy))
{
if (_p.Pips > Trail_start)
{
if (tradePrice < Symbol.Bid)
{
double NewStopLoss = Symbol.Ask - Trail * Symbol.PipSize;
ModifyPosition(_p, NewStopLoss, _p.TakeProfit.Value);
tradePrice = Symbol.Ask;
//Print("Stop loss: " + NewStopLoss);
//Print("Current price: " + Symbol.Ask);
}
}
}
foreach (var _p2 in Positions.FindAll("ZephynScalper", Symbol, TradeType.Sell))
{
if (_p2.Pips > Trail_start)
{
if (tradePrice > Symbol.Ask)
{
double NewStopLoss = Symbol.Bid + Trail * Symbol.PipSize;
ModifyPosition(_p2, NewStopLoss, _p2.TakeProfit.Value);
tradePrice = Symbol.Bid;
}
}
}
écrire :
foreach (var _p in Positions.FindAll("ZephynScalper", Symbol, TradeType.Buy))
{
if (_p.Pips > Trail_start)
{
if (tradePrice < Symbol.Bid)
{
double NewStopLoss = _p.StopLoss.Value + Trail * Symbol.PipSize;
ModifyPosition(_p, NewStopLoss, _p.TakeProfit.Value);
tradePrice = Symbol.Ask;
//Print("Stop loss: " + NewStopLoss);
//Print("Current price: " + Symbol.Ask);
}
}
}
foreach (var _p2 in Positions.FindAll("ZephynScalper", Symbol, TradeType.Sell))
{
if (_p2.Pips > Trail_start)
{
if (tradePrice > Symbol.Ask)
{
double NewStopLoss = _p2.StoLoss.Value - Trail * Symbol.PipSize;
ModifyPosition(_p2, NewStopLoss, _p2.TakeProfit.Value);
tradePrice = Symbol.Bid;
}
}
}
@Counter Trade: 17 Jul 2014, 11:50
Il y a une erreur dans le code :
remplacer
originalPosition.Label != Label
par
originalPosition.Label == Label
@TrailCut I: 11 Jul 2014, 15:26
L'indicateur WPR est implémenté ainsi :
public override void Calculate(int index)
{
double max = MarketSeries.High.Maximum(Period);
double min = MarketSeries.Low.Minimum(Period);
double close = MarketSeries.Close[index];
if ((max - min) > 0)
Result[index] = -100 * (max - close) / (max - min);
else
Result[index] = 0.0;
}
Comme on utilise le prix de clôture, il ne tient pas compte de la dernière bougie en construction, d'où un décalage
d'autant plus grand que le timeframe est grand.
Pour intégrer la dernière bougie, il faut remplacer
double close = MarketSeries.Close[index];
par
double open= MarketSeries.Open[index];
et
Result[index] = -100 * (max - close) / (max - min);
par
Result[index] = -100 * (max - open) / (max - min);
Cordialement
@PayBack II: 01 Jul 2014, 20:51
Voici une nouvelle version plus performante
Observez qu'on n'utilise aucun signal pour prendre une position, on attends les résultats du marché (par définition efficient) pour clôturer les pertes en premier selon l'adage couper les pertes et laisser courir les gains.
ça marche assez bien!
-------------------------------------------------
Here is a new, more powerful version
Observe that uses no signal to take a position, the results of the market (by definition efficient) we expect to close losses in the adage first cut losses and let it run gains.
it works pretty well!
-------------------------------------------------
// -------------------------------------------------------------------------------
//
// PayBack modifie (28 juin 2014)
// version 1.2014.7.1.19h
// Abdallah HACID (c) 2014
// http://www.babooclic.com
//
// Utiliser :
// Volume = 100000
// SL = 57 pips
// TP = 150 pips
// commission = 37.6 per Million
// Spread fixe = 1pip
// Starting Capital = 50000
//
// Results :
// sur GBPUSD en h1 entre le 1/1/2014 et 1/7/2014 a 19h30 gain de 9482 euros(+19%).
// Net profit = 9481.93
// Ending Equity = 10164.18 euros
// Ratio de Sharpe = 0.24
// Ratio de Storino = 0.55
// -------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class PAYBACKII : Robot
{
[Parameter("Initial Volume", DefaultValue = 100000, MinValue = 0)]
public int InitialVolume { get; set; }
[Parameter("Stop Loss", DefaultValue = 57)]
public int StopLoss { get; set; }
[Parameter("Take Profit", DefaultValue = 150)]
public int TakeProfit { get; set; }
const long microVolume = 1000;
const string botLabel = "PB-";
protected override void OnStart()
{
Positions.Opened += OnPositionOpened;
Positions.Closed += OnPositionClosed;
relanceOrders();
}
private void relanceOrders()
{
manageOpen(TradeType.Buy, InitialVolume);
manageOpen(TradeType.Sell, InitialVolume);
}
private void manageOpen(TradeType tradeType, long volume, string prefixLabel = botLabel)
{
int nVolumePartition = 10, part1 = 5, part2 = 3;
long nVol = (long)Math.Floor((double)(volume / (microVolume * nVolumePartition)));
long partialVolume = nVol * microVolume;
var result1 = ExecuteMarketOrder(tradeType, Symbol, partialVolume * part1, prefixLabel + tradeType.ToString() + "-1");
var result2 = ExecuteMarketOrder(tradeType, Symbol, partialVolume * part2, prefixLabel + tradeType.ToString() + "-2");
var result3 = ExecuteMarketOrder(tradeType, Symbol, volume - (part1 + part2) * partialVolume, prefixLabel + tradeType.ToString() + "-3");
}
private void manageClose()
{
foreach (var position in Positions)
{
if (position.TakeProfit.HasValue)
{
string labelType = position.Label.Substring(position.Label.Length - 1, 1);
double potentialGainPips = ((position.TradeType == TradeType.Buy) ? 1 : -1) * (position.TakeProfit.Value - position.EntryPrice) / Symbol.PipSize;
double potentialLosePips = ((position.TradeType == TradeType.Buy) ? 1 : -1) * (position.StopLoss.Value - position.EntryPrice) / Symbol.PipSize;
double percentGain = position.Pips / potentialGainPips;
double percentLose = -position.Pips / potentialLosePips;
if ((percentGain >= 0.43) && (labelType == "3"))
ClosePosition(position);
if ((percentGain >= 0.76) && (labelType == "2"))
ClosePosition(position);
if ((percentLose <= -0.33) && (labelType == "1"))
ClosePosition(position);
if ((percentLose <= -0.66) && (labelType == "2"))
ClosePosition(position);
}
}
}
protected void OnPositionOpened(PositionOpenedEventArgs args)
{
var position = args.Position;
//Limits limits = new Limits(position.TradeType, position.EntryPrice, Symbol.PipSize, TakeProfit, StopLoss);
//position.LimitsExt().SL_PIPS = StopLoss;
//position.LimitsExt().TP_PIPS = TakeProfit;
double stopLoss = position.TradeType == TradeType.Buy ? position.EntryPrice - Symbol.PipSize * StopLoss : position.EntryPrice + Symbol.PipSize * StopLoss;
double takeProfit = position.TradeType == TradeType.Buy ? position.EntryPrice + Symbol.PipSize * TakeProfit : position.EntryPrice - Symbol.PipSize * TakeProfit;
ModifyPosition(position, stopLoss, takeProfit);
}
protected void OnPositionClosed(PositionClosedEventArgs args)
{
if (args.Position.Pips < 0)
manageOpen(args.Position.TradeType==TradeType.Buy ? TradeType.Sell:TradeType.Buy, args.Position.Volume, botLabel + "Mart-");
if (Positions.Count == 0)
relanceOrders();
}
protected override void OnTick()
{
manageClose();
}
protected override void OnError(Error error)
{
if (error.Code != ErrorCode.BadVolume)
{
Print("erreur : " + error.Code);
Stop();
}
}
}
}
@ZigZagBot: 29 Jun 2014, 13:58
ZigzagCycleBot gives good results:
EURUSD, H1, 01/01/2014 to 29/06/2014, zzDepth = 12 StopLoss = 550 ZzDeviation = 5, ZzBackStep = 3, Volume = 100000
@Zephyn Scalper: 29 Jun 2014, 12:06
robot Zephyn sclaper not closing the losers where this apparent performance positions. If we had a look at equity, we see that it is far from being efficient.
@ThirdGenMA Robot: 28 Jun 2014, 21:24
il est ici :
/algos/indicators/show/345
il faut renommer ThirdGenMovingAverage en ThirdGenerationMA
Last Forum Posts
@How to find the length of the string?: 19 Jul 2015, 14:11
In CSharp you can determine the length of a string by this instruction
String myString = "myString";
int length = myString.Length;
@Price between different brokers: 17 Jul 2015, 20:06
ok I see that All broker discussions are prohibited on cTDN.
@Price between different brokers: 17 Jul 2015, 20:03
This post has been removed by the moderator due to a violation of the EULA.
@the time beginning of H4 timeframe: 17 Jul 2015, 19:58
On the cAlgo plateforme when I select H4 timeframe, the begining time of candle was 1h00 (UTC+0)
Why it is not 0h00 ?
@Price between different brokers: 17 Jul 2015, 14:37
This post has been removed by the moderator due to a violation of the EULA.
@Price between different brokers: 17 Jul 2015, 14:36
This post has been removed by the moderator due to a violation of the EULA.
@money management double to float: 14 Jul 2015, 21:55
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);
@How to make break-even price between buy & sell.: 14 Jul 2015, 21:41
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 ?
@TimeFrame operators: 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);
}
@TimeFrame operators: 14 Jul 2015, 17:47
The TimeFrame class is very poor, the class is :
namespace cAlgo.API
{
// Summary:
// Contains supported timeframe values from Minute 1 to Monthly.
public class TimeFrame
{
public static TimeFrame Daily;
public static TimeFrame Day2;
public static TimeFrame Day3;
public static TimeFrame Hour;
public static TimeFrame Hour12;
public static TimeFrame Hour2;
public static TimeFrame Hour3;
public static TimeFrame Hour4;
public static TimeFrame Hour6;
public static TimeFrame Hour8;
public static TimeFrame Minute;
public static TimeFrame Minute10;
public static TimeFrame Minute15;
public static TimeFrame Minute2;
public static TimeFrame Minute20;
public static TimeFrame Minute3;
public static TimeFrame Minute30;
public static TimeFrame Minute4;
public static TimeFrame Minute45;
public static TimeFrame Minute5;
public static TimeFrame Minute6;
public static TimeFrame Minute7;
public static TimeFrame Minute8;
public static TimeFrame Minute9;
public static TimeFrame Monthly;
public static TimeFrame Weekly;public static bool operator <(TimeFrame x, TimeFrame y);
public static bool operator <=(TimeFrame x, TimeFrame y);
public static bool operator >(TimeFrame x, TimeFrame y);
public static bool operator >=(TimeFrame x, TimeFrame y);public override string ToString();
}
}
It will be more convenient if there is a method like
TimeSpan TimeFrame.ToTimeSpan()
{
TimeSpan timespan;
// instruction to transform each TimeFrame.Time in TimeSpan.
return timespan;
};
With TimeSpan the operators is very large and it will be more simple to operate on timeframe.