stoploss

Created at 21 Jan 2018, 07:08
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!
DO

dordkash@gmail.com

Joined 30.09.2017

stoploss
21 Jan 2018, 07:08


Hello

I want to add STOPLOSS at low of last bar +5 pip

How to say my bot

thankyou


@dordkash@gmail.com
Replies

dordkash@gmail.com
22 Jan 2018, 14:27

RE:

Any body can help me?


@dordkash@gmail.com

PanagiotisCharalampous
22 Jan 2018, 14:39

Hi dordkash@gmail.com,

This is how to get the stop loss price based on your requirements.

var stopLossPrice = MarketSeries.Low.LastValue - Symbol.PipSize * 5; 

Let me know if this helps.

Best Regards, 

Panagiotis


@PanagiotisCharalampous

dordkash@gmail.com
28 Jan 2018, 15:25

RE:

Panagiotis Charalampous said:

Hi dordkash@gmail.com,

This is how to get the stop loss price based on your requirements.

var stopLossPrice = MarketSeries.Low.LastValue - Symbol.PipSize * 5; 

Let me know if this helps.

Best Regards, 

Panagiotis

Hi

Thank for your help

But it dosnt work

by using this​ code,my bot Calculates stoploss=1 pip


@dordkash@gmail.com

PanagiotisCharalampous
29 Jan 2018, 11:46

Hi dordkash@gmail.com,

Can you share your code with us to check what could go wrong?

Best Regards,

Panagiotis


@PanagiotisCharalampous

dordkash@gmail.com
29 Jan 2018, 14:08

RE:
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 ingolf : Robot
    {

        const string label = "INGOLF";
        [Parameter(DefaultValue = 1000)]
        public int VOL { get; set; }
        private MovingAverage sma50;
        private double stopLossPrice;

        protected override void OnStart()
        {
            // Put your initialization logic here
            sma50 = Indicators.MovingAverage(MarketSeries.Close, 50, MovingAverageType.Simple);
            var stopLossPrice = MarketSeries.Low.LastValue - Symbol.PipSize * 5;

        }

        protected override void OnBar()
        {

            // Put your core logic here


            if (...........)
            {
                if (..........)
                    if (..........)
                        if (..........)
                            ExecuteMarketOrder(TradeType.Buy, Symbol, VOL, label, stopLossPrice, 20);


            }

        }

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

Panagiotis Charalampous said:

Hi dordkash@gmail.com,

Can you share your code with us to check what could go wrong?

Best Regards,

Panagiotis

 


@dordkash@gmail.com

PanagiotisCharalampous
29 Jan 2018, 14:37

Hi,

In this case you should use something like the below

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

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

        const string label = "";
        private double stopLossPrice;

        protected override void OnStart()
        {


        }

        protected override void OnBar()
        {
            var stopLossPrice = MarketSeries.Low.LastValue - Symbol.PipSize * 5;
            var pips = Math.Round((Symbol.Ask - stopLossPrice) / Symbol.PipSize);        
            ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, label, pips, 20);

        }

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

Let me know if this helps you,

Panagiotis


@PanagiotisCharalampous

dordkash@gmail.com
30 Jan 2018, 05:12

RE:

Panagiotis Charalampous said:

Hi,

In this case you should use something like the below

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

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

        const string label = "";
        private double stopLossPrice;

        protected override void OnStart()
        {


        }

        protected override void OnBar()
        {
            var stopLossPrice = MarketSeries.Low.LastValue - Symbol.PipSize * 5;
            var pips = Math.Round((Symbol.Ask - stopLossPrice) / Symbol.PipSize);        
            ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, label, pips, 20);

        }

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

Let me know if this helps you,

Panagiotis

Hi

Thankful​

 

by using this​ code,my bot Calculates stoploss = 6 pip for all positions and seys 

Error CS0169: The field 'cAlgo.ingolf.stopLossPrice' is never used


@dordkash@gmail.com

dordkash@gmail.com
30 Jan 2018, 08:19

RE: RE:

dordkash@gmail.com said:

Panagiotis Charalampous said:

Hi,

In this case you should use something like the below

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

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

        const string label = "";
        private double stopLossPrice;

        protected override void OnStart()
        {


        }

        protected override void OnBar()
        {
            var stopLossPrice = MarketSeries.Low.LastValue - Symbol.PipSize * 5;
            var pips = Math.Round((Symbol.Ask - stopLossPrice) / Symbol.PipSize);        
            ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, label, pips, 20);

        }

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

Let me know if this helps you,

Panagiotis

Hi

Thankful​

 

by using this​ code,my bot Calculates stoploss = 6 pip for all positions and seys 

Error CS0169: The field 'cAlgo.ingolf.stopLossPrice' is never used

Hi

I was change some thing​

It is true

Thank you very much

            stopLossPrice = MarketSeries.Low.Last(1) - Symbol.PipSize * 5;
            var pips = Math.Round((Symbol.Ask - stopLossPrice) / Symbol.PipSize);

 


@dordkash@gmail.com