Replies

doanthedung
08 Nov 2017, 18:55

It work, Thank very much!


@doanthedung

doanthedung
02 Nov 2017, 09:48

RE:

Panagiotis Charalampous said:

Hi doanthedung,

See an example below on how to close positions when the Symbol's Ask price has gone below a certain level, set by you. 

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 NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Price { get; set; }

        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnTick()
        {
            foreach (var position in Positions)
            {
                if (Symbol.Ask < Price)
                {
                    ClosePosition(position);
                }
            }
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

I hope this helps you develop your algorithm further. Let me know if you need anything else.

Best Regards, 

Panagiotis

Thanks! But the code close all positons at all symbols.

I buy EURUSD and GBPUSD, i use this cBot at GBPUSD, when price hit, this code close all positon at EURUSD and GBPUSD. Can you repair code close positon at only symbol use cBot?


@doanthedung

doanthedung
01 Nov 2017, 10:38

RE:

Panagiotis Charalampous said:

Hi doanthedung,

Thanks for posting in our forum. Can you be more specific on what kind of help do you need?

Best Regards,

Panagiotis

As I buy EURUSD at 1.2345 and i want to close all positions at EURUSD when bid pirce down 1.2300, like that.


@doanthedung