Topics
Replies
MANDRIL
18 Apr 2013, 20:33
RE:
Hi Mandril,
I added the code from the cAlgo samples (Sample Buy/Sell Trailing) to your code and uploaded here: /algos/robots/show/257
Thanks a lot!!!
@MANDRIL
MANDRIL
14 Apr 2013, 03:37
Close positions - % original balance
Hi,
Sorry i wanted to say, that i would like to close all the positions when all my trades reach like 90% of the original balance, for example if i start wiht 1000 USD and my trades go against summing -900, and my account goes to 100 USD then automatically close all the positions.
Thanks a lot again!!!
@MANDRIL
MANDRIL
28 Mar 2013, 18:59
Here it is the robot...it is the one of the samples....it just keep making orders...and i would like just to open a trade and closed it.
// -------------------------------------------------------------------------------------------------
//
// This code is a cAlgo API sample.
//
// This robot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file will be lost on next application start.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// The "Sample Breakout Robot" will check the difference in pips between the Upper Bollinger Band and the Lower Bollinger Band
// and compare it against the "Band Height" parameter specified by the user. If the height is lower than the number of pips
// specified, the market is considered to be consolidating, and the first candlestick to cross the upper or lower band will
// generate a buy or sell signal. The user can specify the number of periods that the market should be consolidating in the
// "Consolidation Periods" parameter. The position is closed by a Stop Loss or Take Profit.
//
// -------------------------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot]
public class SampleBreakoutRobot : Robot
{
[Parameter]
public DataSeries Source { get; set; }
[Parameter("Stop Loss", DefaultValue = 10, MinValue = 1)]
public int StopLossInPips { get; set; }
[Parameter("Take Profit", DefaultValue = 10, MinValue = 1)]
public int TakeProfitInPips { get; set; }
[Parameter("Volume", DefaultValue = 10000, MinValue = 1000)]
public int Volume { get; set; }
[Parameter("Bollinger Bands Deviations", DefaultValue = 2)]
public int Deviations { get; set; } // BB
[Parameter("Bollinger Bands Periods", DefaultValue = 20)]
public int Periods { get; set; } // BB
[Parameter("Bollinger Bands MA Type")]
public MovingAverageType MAType { get; set; } // BB
private BollingerBands bollingerBands;
protected override void OnStart()
{
bollingerBands = Indicators.BollingerBands(Source, Periods, Deviations, MAType);
}
protected override void OnTick()
{
double top = bollingerBands.Top.LastValue;
double bottom = bollingerBands.Bottom.LastValue;
if (Symbol.Ask > top)
{
var request = new MarketOrderRequest(TradeType.Sell, Volume)
{
Label = "SampleBreakoutRobot",
StopLossPips = StopLossInPips,
TakeProfitPips = TakeProfitInPips
};
Trade.Send(request);
}
else if (Symbol.Bid < bottom)
{
var request = new MarketOrderRequest(TradeType.Buy, Volume)
{
Label = "SampleBreakoutRobot",
StopLossPips = StopLossInPips,
TakeProfitPips = TakeProfitInPips
};
Trade.Send(request);
}
}
}
}
@MANDRIL
MANDRIL
18 Apr 2013, 20:33
RE:
Thank you very much!!!
@MANDRIL