Replies

LSR2412
29 Sep 2017, 11:02

Hi Panagiotis,

well, I would like to do following:

to have SMA indicator (period 4) and if SMA is rising and above indicator (JTPO) result is less than -0,8 I get notification (play sound).

Same if SMA is falling and (JTPO) is higher than 0,8 I get notification.

Thanks

 

 


@LSR2412

LSR2412
09 May 2017, 11:01

thanks lucian, but I can't find how to do it with modifying pending order.

There is no parametar under modify pending order instruction.

All stop orders are triggered by default settings :

for buy stop order, if ASK price reaches buy stop order level - it triggeres that order

If buy stop order is placed, then double clicked on that order under pending orders tab, window modify pending order is opened.

If then you click on arrows I marked at above screengrab, that default trigger method is changed.

As I did that on screengrab, you see now that order will be triggered when BID price reaches buy stop order level.

 

Why is this important?

If I trade with narrow stop, and spread is a bid wider (before economic news etc.) this prevents order to be filled because of change in that spread.


@LSR2412

LSR2412
08 May 2017, 22:41 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Hi,

I relly need help with this. I made robot to place stop order as way to open position.

But with order placing trough robot I can't find a way to change how that stop order is triggered.

Only way to do it is after placing order with robot, to manually open order and change settings (marked with ornage circle on screengrab).

Is there a way to do it trough robot.

Thanks

 

 

 


@LSR2412

LSR2412
31 Mar 2017, 16:25

just send him algo file...BUT NOT folder named same like algo


@LSR2412

LSR2412
28 Mar 2017, 16:22

thank you very much, this made my day :)

2nd solution works like charm, just what I needed...thanks


@LSR2412

LSR2412
14 Feb 2017, 12:16

I think I solved it..I just deleted { }..and now it only sends 2 orders

thanks

 


@LSR2412

LSR2412
05 Mar 2016, 00:35

indexDaily solved issue..million thanks

 


@LSR2412

LSR2412
23 Oct 2015, 09:31

this is cTrader example for market depth

hope this helps

using cAlgo.API;
namespace cAlgo.Indicators
{
    [Indicator()]
    public class Level2 : Indicator
    {
        [Output("BidEntries", Color = Colors.Red, PlotType = PlotType.Histogram, Thickness = 5)]
        public IndicatorDataSeries BidResult { get; set; }
        [Output("AskEntries", Color = Colors.Blue, PlotType = PlotType.Histogram, Thickness = 5)]
        public IndicatorDataSeries AskResult { get; set; }
        MarketDepth GBPUSD;
        private int _askNo;
        private int _bidNo;
        protected override void Initialize()
        {
            GBPUSD = MarketData.GetMarketDepth(Symbol);
            GBPUSD.Updated += OnGbpUsdUpdated;
        }
        void OnGbpUsdUpdated()
        {
            _askNo = 0;
            _bidNo = 0;
            var index = MarketSeries.Close.Count - 1;
            for (var i = 0; i < GBPUSD.AskEntries.Count; i++)
                AskResult[index - i] = double.NaN;
            foreach (var entry in GBPUSD.AskEntries)
            {
                AskResult[index - _askNo] = (-1) * entry.Volume;
                _askNo++;
            }
            for (var i = 0; i < GBPUSD.BidEntries.Count; i++)
                BidResult[index - i] = double.NaN;
            foreach (var entry in GBPUSD.BidEntries)
            {
                BidResult[index - _bidNo] = entry.Volume;
                _bidNo++;
            }
        }
        public override void Calculate(int index)
        {
        }
    }
}

 


@LSR2412

LSR2412
23 Oct 2015, 09:07

it works!!! :)

 

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class test : Indicator
    {

        [Output("AskVol-BidVol Hist", Color = Colors.Blue, PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries AminusBhist { get; set; }
        [Output("AskVol-BidVol Line", Color = Colors.Yellow, Thickness = 1)]
        public IndicatorDataSeries Result { get; set; }





        public MarketDepth _marketDepth;

        public double bid0avg = 0;
        public double ask0avg = 0;
        public double bid0avgline = 0;
        public double ask0avgline = 0;

        public double delta0avg = 0;
        public double tobBcount = 0;


        public double bid0 = 0;
        public double ask0 = 0;
        public double bid0total = 0;
        public double ask0total = 0;
        public double avgcount = 0;

        public double tobA = 0;
        public double tobB = 0;


        public double curtobA = 0;
        public double prevtobA = 0;

        public double curtobB = 0;
        public double prevtobB = 0;

        protected override void Initialize()
        {
            //  Get Market Depth
            _marketDepth = MarketData.GetMarketDepth(Symbol);
            // subscribe to event Updated
            _marketDepth.Updated += MarketDepthUpdated;
        }

        void MarketDepthUpdated()
        {

            foreach (var entry in _marketDepth.AskEntries)
            {
                tobA = _marketDepth.AskEntries[0].Volume;

//trying to get the top of the book data into the variable
            }


            foreach (var entry in _marketDepth.AskEntries)
            {
                tobB = _marketDepth.BidEntries[0].Volume;
            }



            curtobB = tobB;

            curtobA = tobA;

            if ((curtobB - prevtobB != 0) || (curtobA - prevtobA != 0))
            {

                avgcount = avgcount + 1;

                bid0 = curtobB;

                ask0 = curtobA;



                bid0total += bid0;

                ask0total += ask0;


                bid0avg = bid0total / avgcount;

                ask0avg = ask0total / avgcount;



                ask0avgline += ask0avg;
                bid0avgline += bid0avg;

// tyring to get the value of 'delta0avg' on to the histogram
                delta0avg = ask0avgline - bid0avgline;


            }
            prevtobB = curtobB;
            prevtobA = curtobA;

        }




        public override void Calculate(int index)
        {
            AminusBhist[index] = delta0avg;
        }
    }
}


 


@LSR2412

LSR2412
22 Oct 2015, 17:45

 

try this

  delta0avg = ask0avgline - bid0avgline; 

AminusBhist = delta0avg


@LSR2412

LSR2412
22 Oct 2015, 17:43

I am not expert..but histogram is plotted by AminusBhist data...which is not existing

 

AminusBhist must be equal to something..in order to be plotted


@LSR2412

LSR2412
01 Oct 2015, 08:51

RE:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class Priceatcandle : Indicator
    {

        public override void Calculate(int index)
        {

            {

                ChartObjects.DrawText(index.ToString(), "←", index + 1, MarketSeries.Close[index], VerticalAlignment.Center, HorizontalAlignment.Right, Colors.Gray);
                ChartObjects.RemoveObject((index - 1).ToString());
            }
        }
    }
}

karlson said:

Thank you very much for your help. Is it possible to have last price moving along the last candle ? Or displaying an arrow along last candle?

this is with arrow....put any symbol instead of this arrow in quotation marks and it will be displayed


@LSR2412

LSR2412
01 Oct 2015, 08:47

RE:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class Priceatcandle : Indicator
    {

        public override void Calculate(int index)
        {

            {

                ChartObjects.DrawText(index.ToString(), MarketSeries.Close[index].ToString(), index + 1, MarketSeries.Close[index], VerticalAlignment.Center, HorizontalAlignment.Right, Colors.Gray);
                ChartObjects.RemoveObject((index - 1).ToString());
            }
        }
    }
}

karlson said:

Thank you very much for your help. Is it possible to have last price moving along the last candle ? Or displaying an arrow along last candle?

this is with "Last" price moving


@LSR2412

LSR2412
30 Sep 2015, 17:33

using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class Priceatcandle : Indicator
    {

        public override void Calculate(int index)
        {

            {

                ChartObjects.DrawText("price", MarketSeries.Close[index].ToString(), StaticPosition.Right, Colors.Red);

            }
        }
    }
}

please ignore my first code..this is ok


@LSR2412

LSR2412
30 Sep 2015, 16:14

RE:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class Priceatcandle : Indicator
    {
        //private int _outsideperiods;
        public override void Calculate(int index)
        {

            {

                if (IsRealTime)

                    ChartObjects.DrawText(index.ToString(), MarketSeries.Close[index].ToString(), index, MarketSeries.Low[index] - Symbol.PipSize * 6, VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.Gray);


            }
        }
    }
}

showing last price just below last candle

 

karlson said:

Hi,

How to display price near candle on cTrader without using bid/ask lines ? Please, thank you.

 


@LSR2412

LSR2412
15 Sep 2015, 10:53

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class BBREVERSALCODE : Indicator
    {

        private BollingerBands bbds;

        protected override void Initialize()
        {

            bbds = Indicators.BollingerBands(MarketSeries.Close, 20, 2.5, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {


            if (bbds.Top[index - 1] < MarketSeries.High[index - 1])
            {
                ChartObjects.DrawText(index.ToString(), "▼", index, MarketSeries.High[index - 1] + Symbol.PipSize, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Red);
            }



            if (bbds.Bottom[index - 1] > MarketSeries.Low[index - 1])
            {
                ChartObjects.DrawText(index.ToString(), "▲", index, MarketSeries.Low[index - 1] - Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.Green);
            }



        }
    }
}

try this one...it marks with arrows bars which had extreme outside of Bollinger bands..after bar close it puts arrow on start of new bar


@LSR2412

LSR2412
28 May 2015, 13:58

 var prvdaySeries = MarketData.GetSeries(Symbol.Code.ToString(), TimeFrame.Daily);

 ChartObjects.DrawHorizontalLine("PreviousdayHigh1", prvdaySeries.High.Last(1), Colors.DarkGray, 1, LineStyle.Lines);
ChartObjects.DrawText("prvdayHtext1", "H " + prvdaySeries.High.Last(1).ToString(), index + 2, prvdaySeries.High.Last(1), VerticalAlignment.Top, HorizontalAlignment.Right, Colors.Red);

here is example for drawing horizontal line at level of previous day..and above line is text "H + previous day high level"

maybe this helps


@LSR2412

LSR2412
22 May 2015, 13:04

hi

I am using something similar..to calculate one indicator just prior close

try this..

TimeSpan duration = MarketSeries.OpenTime.Last(0) - MarketSeries.OpenTime.Last(1);

if (Server.Time > MarketSeries.OpenTime.LastValue.AddHours(duration.Hours).AddMinutes(duration.Minutes).AddSeconds(duration.Seconds - 2))

 


@LSR2412

LSR2412
28 Feb 2015, 09:45

That is what I needed.

Thank you


@LSR2412

LSR2412
04 Feb 2015, 07:59

I am not having good coding skills...and I thought this can be done without waiting for cTrader staff to do so.

joelabrahamsson.com/detecting-mouse-and-keyboard-input-with-net/

Maybe someone can use this example to make a code for mouse or key input start or stop for indicators.


@LSR2412