I don't undestand....

Created at 17 Oct 2016, 23:32
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
SE

sergiestudillo1

Joined 11.10.2016

I don't undestand....
17 Oct 2016, 23:32


 I have a little problem, when I executed this cbot for example in EURUSD and I stoped one position in other market, the cbot executed new orders in EURUSD.... I don't know where is the problem.

 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class sergi : Robot
    {

        [Parameter("Volume", DefaultValue = 1000)]
        public int Volume { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 1)]
        public int StopLossInPips { get; set; }


        protected override void OnStart()
        {

            Positions.Closed += closedposition;
            ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, "Sergi", StopLossInPips, 0);
            ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, "Sergi", StopLossInPips, 0);

        }

        public void closedposition(PositionClosedEventArgs arg)
        {
            var position = arg.Position;


            if (position.NetProfit < 0)
                Positions.Closed -= closedposition;


            OnStart();






        }

    }
}

 


@sergiestudillo1
Replies

croucrou
20 Oct 2016, 21:14

You are in the loop. Closed positions go back to the OnStart(); and open new ones.


@croucrou