Information
Username: | aysos75 |
Member since: | 28 Sep 2013 |
Last login: | 28 Sep 2013 |
Status: | Active |
Activity
Where | Created | Comments |
---|---|---|
Algorithms | 16 | 55 |
Forum Topics | 16 | 40 |
Jobs | 0 | 0 |
About
Last Algorithm Comments
Very good job!
sorry for the two precedents mistakes
link to myfxbook : http://www.myfxbook.com/members/abhacid/mforex-1700/1304163
You can find Candlestick Tendency II here :
link to Candlestick Tendency II
Read the information about installation here
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.
Hello there
In code there is no difference between
UpdateTrailingStop
and
MoveToBreakEven
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 !
Your bot is interesting, can you explain some of the idee Under this EA ?
@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)).
this is ok now
the first link don't work clic on the second link
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.
yes I have updated it
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
the new copy trading reference is
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.
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.
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.
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!
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
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;
}
}
}
@Juddly01
The problem is
ExecuteMarketOrder (TradeType.Buy, Symbol, OrderVolume);
replace by
Trade.CreateBuyMarketOrder(Symbol, OrderVolume);
le lien suivant fonctionne :
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
Hi,
I do not claim to be the best, I test things out of nothing and look what happens that's it!
Author : https://www.facebook.com/ab.hacid
Solution Visual studio : https://calgorobots.codeplex.com/SourceControl/latest
Solution Visual studio : https://calgorobots.codeplex.com/SourceControl/latest
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
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
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,
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);
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;
}
}
}
Sorry there is no error
Il y a une erreur dans le code :
remplacer
originalPosition.Label != Label
par
originalPosition.Label == Label
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
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();
}
}
}
}
ZigzagCycleBot gives good results:
EURUSD, H1, 01/01/2014 to 29/06/2014, zzDepth = 12 StopLoss = 550 ZzDeviation = 5, ZzBackStep = 3, Volume = 100000
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.
quel paire utiliser sur quelle timeframe ?
il est ici :
/algos/indicators/show/345
il faut renommer ThirdGenMovingAverage en ThirdGenerationMA
where is the Third Gen Moving Average ?
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