creer un seul robot
creer un seul robot
08 Oct 2012, 16:00
bonjour
pour créer des bénéfices je travaille avec mes 2 robots .
quand je perd sur l'un.... je gagne sur l'autre .
Ensuite la martingale me rembourse...
Attention à la marge.
regler le stop loss et take profit suivant le solde solde...
pour des raisons pratiques pouvez vous m aider a construire un seule robot qui fonctionnent comme mes 2 robots.
Et nous pourrons tous profiter du robot..!!
merci
hello
to create profits I work with my two robots.
when I lose on one .... I win over the other.
Then the martingale reimburse me ...
Attention to the margin.
adjust the stop loss and take profit following the balance remaining ...
for practical reasons can m help build a single robot that function as my 2 robots.
And we can all enjoy the robot ..!
thank you
using System;
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot]
public class cROBOTPAYBACKBUY : Robot
{
[Parameter("Initial Volume", DefaultValue = 10000, MinValue = 0)]
public int InitialVolume { get; set; }
[Parameter("Stop Loss", DefaultValue = 20)]
public int StopLoss { get; set; }
[Parameter("Take Profit", DefaultValue = 20)]
public int TakeProfit { get; set; }
private Position position;
protected override void OnStart()
{
ExecuteOrder(InitialVolume, TradeCommand());
}
private void ExecuteOrder(int volume, TradeType tradeType)
{
Trade.CreateMarketOrder(tradeType, Symbol, volume);
}
protected override void OnPositionOpened(Position openedPosition)
{
position = openedPosition;
Trade.ModifyPosition(openedPosition, GetAbsoluteStopLoss(openedPosition, StopLoss), GetAbsoluteTakeProfit(openedPosition, TakeProfit));
}
protected override void OnPositionClosed(Position closedPosition)
{
if (closedPosition.GrossProfit > 0)
{
ExecuteOrder(InitialVolume, TradeCommand());
}
else
{
ExecuteOrder((int) position.Volume * 2, position.TradeType);
}
}
protected override void OnError(Error error)
{
if (error.Code == ErrorCode.BadVolume)
Stop();
}
private TradeType TradeCommand()
{
return TradeType.Buy;
}
private double GetAbsoluteStopLoss(Position position, int stopLossInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice - Symbol.PipSize * stopLossInPips
: position.EntryPrice + Symbol.PipSize * stopLossInPips;
}
private double GetAbsoluteTakeProfit(Position position, int takeProfitInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice + Symbol.PipSize * takeProfitInPips
: position.EntryPrice - Symbol.PipSize * takeProfitInPips;
using System;
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot]
public class ROBOTPAYBACKBAISSE : Robot
{
[Parameter("Initial Volume", DefaultValue = 10000, MinValue = 0)]
public int InitialVolume { get; set; }
[Parameter("Stop Loss", DefaultValue = 20)]
public int StopLoss { get; set; }
[Parameter("Take Profit", DefaultValue = 20)]
public int TakeProfit { get; set; }
private Position position;
protected override void OnStart()
{
ExecuteOrder(InitialVolume, TradeCommand());
}
private void ExecuteOrder(int volume, TradeType tradeType)
{
Trade.CreateMarketOrder(tradeType, Symbol, volume);
}
protected override void OnPositionOpened(Position openedPosition)
{
position = openedPosition;
Trade.ModifyPosition(openedPosition, GetAbsoluteStopLoss(openedPosition, StopLoss), GetAbsoluteTakeProfit(openedPosition, TakeProfit));
}
protected override void OnPositionClosed(Position closedPosition)
{
if (closedPosition.GrossProfit > 0)
{
ExecuteOrder(InitialVolume, TradeCommand());
}
else
{
ExecuteOrder((int) position.Volume * 2, position.TradeType);
}
}
protected override void OnError(Error error)
{
if (error.Code == ErrorCode.BadVolume)
Stop();
}
private TradeType TradeCommand()
{
return TradeType.Sell;
}
private double GetAbsoluteStopLoss(Position position, int stopLossInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice - Symbol.PipSize * stopLossInPips
: position.EntryPrice + Symbol.PipSize * stopLossInPips;
}
private double GetAbsoluteTakeProfit(Position position, int takeProfitInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice + Symbol.PipSize * takeProfitInPips
: position.EntryPrice - Symbol.PipSize * takeProfitInPips;
}
}
}
}
}
}
Replies
admin
08 Oct 2012, 18:19
From what I understand from your code, one robot is selling and the other is buying, other than that the robots are identical.
Both robots execute trades according to this statement:
if the previously closed position generated profit execute the same trade with the initial volume, otherwise double the volume of the previous trade.
Is this what you are trying to accomplish? If not then please write a small description of your logic.
If this is indeed what you need then the only solution I can provide is that you just create two trades one buy and one sell each time:
i.e.
protected override void OnPositionClosed(Position closedPosition) { if (closedPosition.GrossProfit > 0) { ExecuteOrder(InitialVolume, TradeType.Buy); ExecuteOrder(InitialVolume, TradeType.Sell); } else { ExecuteOrder((int) position.Volume*2, position.TradeType); } }
@admin
tradermatrix
08 Oct 2012, 21:10
merci
mais cela ne fonctionne pas comme mes 2 robots.
exemple martingale classique.
[Parameter("Initial Volume", DefaultValue =10000, MinValue =0)]
publicint InitialVolume {get;set;}
[Parameter("Stop Loss", DefaultValue =20)]
publicint StopLoss {get;set;}
[Parameter("Take Profit", DefaultValue =20)]
publicint TakeProfit {get;set;}
euro monte :euro 1.3
1:sell random (1.3000)volume 10 000....stoploss 1.3020 /perte -20 euros
2:sell(1.3020) volume 20 000 stop loss 1.3040 /perte -40 euros
3:sell(1.3040) volume 40 000 stop loss 1.3060 /perte -80 euros
4:sell (1.3060) volume 80 000 stop loss 1.3080 /perte -160 euros
5:sell (1.3080) volume160 000 ....euro remonte take profit 1.3060 /gain +320 euros
GAIN TOTAL: 5-(1+2+3+4)...320-(20+40+80+160)= 20 euros
tout ça pour seulement 20 euros...!!!!!!
ma stategie est la suivante:
mettre simultanément en route mes 2 robots paybackSell et paybackBuy
Parameter("Initial Volume", DefaultValue =10000, MinValue =0)]
publicint InitialVolume {get;set;}
[Parameter("Stop Loss", DefaultValue =20)]
publicint StopLoss {get;set;}
[Parameter("Take Profit", DefaultValue =20)]
publicint TakeProfit {get;set;}
euro monte :euro 1.3
paybackSell:
1:sell (1.3000)volume 10 000....stoploss 1.3020 /perte -20 euros
2:sell(1.3020) volume 20 000 stop loss 1.3040 /perte -40 euros
3:sell(1.3040) volume 40 000 stop loss 1.3060 /perte -80 euros
4:sell (1.3060) volume 80 000 stop loss 1.3080 /perte -160 euros
5:sell (1.3080) volume160 000 ....euro remonte take profit 1.3060 /gain +320 euros
GAIN TOTAL: 5-(1+2+3+4)...320-(20+40+80+160)= 20 euros
pendant ce temps.!!
payback Buy:
buy (1.3000)volume 10 000...take profit 1.3020 /gain +20 euros
buy (1.3020)volume 10 000...take profit 1.3040 /gain +20 euros
buy (1.3040)volume 10 000 ..take profit 1.3060 /gain +20 euros
buy (1.3060)volume 10 000 ..take profit 1.3080 /gain +20 euros
gain 80 euros
GAIN TOTAL PAYBACK SELL+ PAYBACK BUY:
20+80= 100 euros
100 euros...!!!!good
et les robots continuent de travailler
que le marché monte ou baisse (statégie toujours gagnante)
parfois quelques écarts ou resserments à corriger.
j ai tenté beaucoup de solutions pour créer un seul robot regroupé
merci beaucoup
@tradermatrix
PsykotropyK
09 Oct 2012, 14:58
A few things :
1) why do you keep talking in french while 99% of the people here don't? Except if you are not really trying to look for answers.
3) your strategy can only work with a very high equity. Let's imagine your robot end up giving 12 consecutive win on robot 1 (R1), followed by a 13th as a loss. Robot 2 (R2) will have 12 consecutive losses before its win. If I neglate the fees & bid ask your output will be (following your 20pip S/L & 10k trades) :
12th trade : R1 PnL --> 20*12 = 240 euros /// R2 PnL --> -20*2^12 + 20 = -81.900 euros /// TOTAL = -81.660 euros
13th trade : R1 PnL --> 20*12-20 = 220 euros /// R2 PnL --> 20 /// TOTAL = + 240 euros
If you want to know what equity you should have :
Equity = -[v * S/L * 2 ^ cL] + v * SL * (cL + 1)] with v = volume ; SL : stop loss in value (ie 20pip EUR/USD = 0.002), cL = estimated max consecutive losses.
As you can see it's an exponential curve. Regarding that your trade opening decision is random it is not very hard to estimate your chances to reach 10 or more consecutive loss on one robot as very close from 1. On a simple excel spreadsheets, using a random number generator as your robot output (50% chances win, 50% chances loss), and doing around 131k random consecutive shots, I easily reach series of 15/16 consecutive loss on one of the robot and it can go even higher. With 15 consecutives, you would end up making 300€ for a need of 660.000€ equity more or less.
Martingale is a very dangerous tool if your entry decision is not filtered.
@PsykotropyK
admin
09 Oct 2012, 16:44
Hello tradermatrix,
You are correct the previous code logic does not match your strategy with the two robots.
Try changing this method:
protected override void OnPositionClosed(Position closedPosition) { if (closedPosition.GrossProfit > 0) { ExecuteOrder(InitialVolume, closedPosition.TradeType); } else { ExecuteOrder((int)closedPosition.Volume * 2, closedPosition.TradeType); } }
@admin
tradermatrix
09 Oct 2012, 17:43
for PsykotropyK
oh! excuse me have you angry with my French but I do not write very well the English.
yes martingale should be used with caution.
but according to the size of its portfolio can change the take profit and stop loss 10 or 20 or 30 or 40 ... etc..
to avert the risk of exceeding the margin.
you can also change the volume: 10000 or 1000 etc ...
brookers offer of margins: 100 or 200 or 500 ....
what I tried to explain that c is a martingale classical random., and the gain is small and sometimes long to come.
The market is random, it rises or descends ...
with two martingales (not random) a buy and sell, the gain is faster ... the market rises or falls.
I would therefore just my 2 robots combine into one robot and improve strategy.
thank you very much.
@tradermatrix
PsykotropyK
09 Oct 2012, 22:05
Non ça va j'ai pas de problème avec le français, mais ça serait simplement plus facile pour toi pour avoir des réponses.
Anyway, there is an over flaw in your strategy if I'm right. You don't take into account in your examples the cost of your trades (comission + spread). The more you have consecutive losses, the more this part take importance. Lets say your broker cost you 2 pip per operation and 4 consecutive before a gain :
R1 : +20 R2 : -20 Broker : -4
R1 : +20 R2 : -40 Broker : -6
R1 : +20 R2 : -80 Broker : -10
R1 : +20 R2 : -160 Broker ; -18
R1 : -20 R2 : +320 broker : -34
Total : +8
If you add one consecutive loss, you start loosing money. Anyway, I wish you good luck.
@PsykotropyK
tradermatrix
10 Oct 2012, 00:56
commissions are very low 30 euros to 65 euros (1,000,000 euros)
the spead is 0.00000mini to max 0.00007
this is insignificant.
but must pay whatever toujour strategy .....
good ...!
thanks to all, I found the solution ..!
I tested the robot a few hours and if all goes well I will post tomorrow ..
See you soon my friends traders
@tradermatrix
tradermatrix
10 Oct 2012, 20:11
hello
Here is an example of capital gains for a few hours of operation of the robot
[Parameter("Initial Volume", DefaultValue = 10000, MinValue = 0)]
public int InitialVolume { get; set; }
[Parameter("Stop Loss", DefaultValue = 20)]
public int StopLoss { get; set; }
[Parameter("Take Profit", DefaultValue = 20)]
public int TakeProfit { get; set; }
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@tradermatrix
tradermatrix
10 Oct 2012, 20:17
using System;
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot]
public class TRADERMATRIXPAYBACK : Robot
{
[Parameter("Initial Volume", DefaultValue = 10000, MinValue = 0)]
public int InitialVolume { get; set; }
[Parameter("Stop Loss", DefaultValue = 20)]
public int StopLoss { get; set; }
[Parameter("Take Profit", DefaultValue = 20)]
public int TakeProfit { get; set; }
private Position position;
protected override void OnStart()
{
ExecuteOrder(InitialVolume, TradeType.Sell);
ExecuteOrder(InitialVolume, TradeType.Buy);
}
private void ExecuteOrder(int volume, TradeType tradeType)
{
Trade.CreateMarketOrder(tradeType, Symbol, volume);
}
protected override void OnPositionOpened(Position openedPosition)
{
position = openedPosition;
Trade.ModifyPosition(openedPosition, GetAbsoluteStopLoss(openedPosition, StopLoss), GetAbsoluteTakeProfit(openedPosition, TakeProfit));
}
protected override void OnPositionClosed(Position closedPosition)
{
if (closedPosition.GrossProfit > 0)
{
ExecuteOrder(InitialVolume, closedPosition.TradeType);
}
else
{
ExecuteOrder((int)closedPosition.Volume * 2, closedPosition.TradeType);
}
}
protected override void OnError(Error error)
{
if (error.Code == ErrorCode.BadVolume)
Stop();
}
private double GetAbsoluteStopLoss(Position position, int stopLossInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice - Symbol.PipSize * stopLossInPips
: position.EntryPrice + Symbol.PipSize * stopLossInPips;
}
private double GetAbsoluteTakeProfit(Position position, int takeProfitInPips)
{
return position.TradeType == TradeType.Buy
? position.EntryPrice + Symbol.PipSize * takeProfitInPips
: position.EntryPrice - Symbol.PipSize * takeProfitInPips;
}
}
}
@tradermatrix
tradermatrix
11 Oct 2012, 11:29
hello
yes I've recorded last night and is now online.
for a complete examination of 24 hreures better understand the flow and earnings, here are the details of the account.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@tradermatrix
PsykotropyK
11 Oct 2012, 14:26
Nice job for finalizing the robot.
Did you run a backtest on it? If so can you put the results?
@PsykotropyK
b0risl33t
08 Oct 2012, 17:09
I think this works
@b0risl33t