Topics
Replies
elodie
23 Jul 2013, 17:00
RE:
hello
on the robot;alembex/algos/robots/show/251
I would like a formula to limit the volumes
eg 800k (0.8m) max
thank you very much.élodie
hello
I found a few examples,
but I have not managed to adapt
thank you
@elodie
elodie
25 Jun 2013, 14:15
RE:
I'm not sure what you mean. Do you still need help? Post the code you managed to come up with so far and I will try to correct it.
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;
namespace cAlgo.Robots
{
[Robot]
public class CCI_20 : Robot
{
[Parameter(DefaultValue = 1, MinValue = 0, MaxValue = 50)]
public int RiskPct{get;set;}
[Parameter(DefaultValue = 500, MinValue = 100, MaxValue = 500)]
public int Leverage{get;set;}
[Parameter("Periods", DefaultValue = 20, MinValue = 1)]
public int Periods { get; set; }
[Parameter("Stop Loss (pips)", DefaultValue = 0, MinValue = 0)]
public int StopLoss { get; set; }
[Parameter("Take Profit (pips)", DefaultValue = 0, MinValue = 0)]
public int TakeProfit { get; set; }
[Parameter("Volume", DefaultValue = 10000, MinValue = 1000)]
public int Volume { get; set; }
private Position _position;
private CommodityChannelIndex _cci;
protected override void OnStart()
{
_cci = Indicators.CommodityChannelIndex(Periods);
}
protected int getVolume
{
get
{
var risk = (int) (RiskPct*Account.Balance/100);
var volumeOnRisk = (int) (risk*Symbol.Ask/(Symbol.PipSize*StopLoss)); // or Bid
double maxVolume = Account.Equity*Leverage*100/101;
var vol = Math.Min(volumeOnRisk, maxVolume);
return (int)Math.Truncate(Math.Round(vol) / 10000) * 10000; // round to 10K
}
}
} protected override void OnBar()
{
if (Trade.IsExecuting)
return;
bool isLongPositionOpen = _position != null && _position.TradeType == TradeType.Buy;
bool isShortPositionOpen = _position != null && _position.TradeType == TradeType.Sell;
if (_cci.Result.HasCrossedBelow(0.0, 2) && !isShortPositionOpen)
OpenPosition(TradeType.Sell);
else if (_cci.Result.HasCrossedAbove(0.0, 2) && !isLongPositionOpen)
OpenPosition(TradeType.Buy);
}
private void OpenPosition(TradeType type)
{
if (_position != null)
Trade.Close(_position);
Request request = new MarketOrderRequest(type, Volume)
{
Label = "CCI 20",
StopLossPips = StopLoss > 0? StopLoss: (int?) null,
TakeProfitPips = TakeProfit > 0? TakeProfit: (int?) null,
};
Trade.Send(request);
}
protected override void OnPositionOpened(Position openedPosition)
{
_position = openedPosition;
}
}
}
@elodie
elodie
24 Jun 2013, 12:10
RE: RE:
atrader said:There is something similar in this robot: /algos/robots/show/271 Is this the one you are saying it's difficult to reproduce?
I haven't tested this but I think it should be something like this:
protected int getVolume { get { var risk = (int) (RiskPct*Account.Balance/100); var volumeOnRisk = (int) (risk*Symbol.Ask/(Symbol.PipSize*StopLoss)); // or Bid double maxVolume = Account.Equity*Leverage*100/101;
var vol = Math.Min(volumeOnRisk, maxVolume);
return (int)Math.Truncate(Math.Round(vol) / 10000) * 10000; // round to 10K } }
thank you
but it does not work
hi
with this method,it allows to adjust the lever :
[Parameter(DefaultValue = 500, MinValue = 100, MaxValue = 500)]
public int Leverage{get;set;}
thank you very much
@elodie
elodie
21 Jun 2013, 12:51
RE:
There is something similar in this robot: /algos/robots/show/271 Is this the one you are saying it's difficult to reproduce?
I haven't tested this but I think it should be something like this:
protected int getVolume { get { var risk = (int) (RiskPct*Account.Balance/100); var volumeOnRisk = (int) (risk*Symbol.Ask/(Symbol.PipSize*StopLoss)); // or Bid double maxVolume = Account.Equity*Leverage*100/101;
var vol = Math.Min(volumeOnRisk, maxVolume);
return (int)Math.Truncate(Math.Round(vol) / 10000) * 10000; // round to 10K } }
thank you
but it does not work
@elodie
elodie
18 Jun 2013, 11:16
hi
why the download does not work ..?
http://www.calgofx.com/view_page?pid=jedi-scalper-1354962455
@elodie
elodie
07 Jun 2013, 13:45
not trade sell
hello !!!
not trade sell...?
error flag3 and flag 5.
the error may be here
someone has a 't have any idea ..?
if ((flag3 && this.Tbounce > 0) || (flag5 && this.Tbreak > 0))
{
MarketOrderRequest request2 = new MarketOrderRequest(TradeType.Sell, (int)((double)this.InitialVolume * num7))
bool flag = num6 >= (double)this.Starttime && num6 < (double)this.Stoptime;
bool flag2 = (base.Symbol.Digits == 4 && Math.Truncate(num2) > Math.Truncate(num5) && Math.Truncate(num3) > Math.Truncate(num5)) || (base.Symbol.Digits == 5 && Math.Truncate(num2 * 100.0) > Math.Truncate(num5 * 100.0) && Math.Truncate(num3 * 100.0) > Math.Truncate(num5 * 100.0));
bool flag3 = (base.Symbol.Digits == 4 && Math.Truncate(num2) < Math.Truncate(num4) && Math.Truncate(num3) < Math.Truncate(num4)) || (base.Symbol.Digits == 5 && Math.Truncate(num2 * 100.0) < Math.Truncate(num4 * 100.0) && Math.Truncate(num3 * 100.0) < Math.Truncate(num5 * 100.0));
bool flag4 = (base.Symbol.Digits == 4 && Math.Truncate(num2) < Math.Truncate(num4) && Math.Truncate(num3) > Math.Truncate(num5)) || (base.Symbol.Digits == 5 && Math.Truncate(num3 * 100.0) > Math.Truncate(num5 * 100.0));
bool flag5 = (base.Symbol.Digits == 4 && Math.Truncate(num2) > Math.Truncate(num5) && Math.Truncate(num3) < Math.Truncate(num4)) || (base.Symbol.Digits == 5 && Math.Truncate(num3 * 100.0) < Math.Truncate(num5 * 100.0));
if (num < 1 && flag)
@elodie
elodie
24 Jul 2013, 20:28
RE:
thank you very much....
élodie
@elodie