Replies

MANDRIL
18 Apr 2013, 20:33

RE:
cAlgo_Fanatic said:

The reason the robot stops working is probably in this line:

if ((int) Server.Time.DayOfWeek == NewsDay && !_ordersCreated

ordersCreated is set to true when the first two pending orders are created and never set back to false. 

You probably want to set it back to false when you delete those orders, unless the logic intended is to create 2 pending orders and stop. In that case you may want to stop the robot by adding this line Stop();

right after you delete the orders.

Thank you very much!!!


@MANDRIL

MANDRIL
18 Apr 2013, 20:33

RE:
atrader said:

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
17 Apr 2013, 03:47

Plus Trigger Pips

I forgot to mention, if it is possible to add also a trigger pips that will make begin the Trailing stop immediately. I tried the examples but :(


@MANDRIL

MANDRIL
16 Apr 2013, 00:47

Thanks a lot!!! You are great!!!! :)


@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
08 Apr 2013, 20:21

Thanks a lot!!!!!!!!!!!!


@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