Replies

moiz.forex
14 Sep 2022, 14:23

RE: Thanks bro but i have no idea where to add this lol

Hi, Thanks for your quick response but i have no idea where i need to put this code and which Parameter i need to remove. I have no knowledge of this coding this

 

 

 

PanagiotisCharalampous said:

Hi there,

Here is a starting point to get the method right

        private bool TradingEnabled()
        {
            var @from = TimeSpan.ParseExact("11:00", "hh\\:mm", null);
            var to = TimeSpan.ParseExact("18:00", "hh\\:mm", null);
            return Server.Time.TimeOfDay >= @from && Server.Time.TimeOfDay < to;
        }

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 


@moiz.forex

moiz.forex
09 Sep 2022, 18:22

RE: RE: I have no Idea where is RSI in this brother

Prosteel,

 

The Orignal Bot mentioned above was made too much complicated and there was no point where he added RSI which I orignally wanted. He added time zone. Cuts off a trade if the other trade is open. So much unnecesry things he added and the main thing which i asked was missing. 

 Can you explain a bit what yoe have done here in this what you made.

 

Thank you

 

 

 

 

 

prosteel1 said:

Seems to be a fair bit missing in my opinion for a properly working cbot without all sorts of bugs and strange things going on.

I would like to work with others to produce an open source cbot that actually places trades with stoploss and takeprofit correctly with all the checks to avoid all the pitfalls when things go wrong.

I am open to making this simple cbot using what I have learnt and used from this site, if others are willing to contribute. If we all contributed we could produce an open source sample cbot that works well.

 

The above CalculateRisk method is 2 lines:

protected double CalculateRisk(double stoploss)
        {
            double exactVolume = Symbol.QuantityToVolumeInUnits(Volume);
            return Symbol.NormalizeVolumeInUnits(exactVolume, RoundingMode.ToNearest);
        }

Compare that to what I have (not counting my CalculateMargin and CalculateVolume methods):

private void CalculateRisk()
        {
            PositionRisk = 0.0;
            OrderRisk = 0.0;
            if (Positions.Count > 0)
            {
                Position[] longpositions = Positions.FindAll("Long");
                var longpos = longpositions;
                foreach (var pos in longpos)
                {
                    if (pos.Comment != "" && pos.StopLoss != null && pos.StopLoss < pos.EntryPrice)
                    {
                        double SL = Convert.ToDouble(pos.StopLoss);
                        double posrisk = 0;
                        posrisk = Math.Round((((pos.EntryPrice - SL) / Symbols.GetSymbolInfo(pos.SymbolName).PipSize) * Symbols.GetSymbolInfo(pos.SymbolName).PipValue * pos.VolumeInUnits) - (2 * pos.Commissions) - pos.Swap, 2);
                        Print("pos.SymbolName = " + pos.SymbolName + ", posrisk= " + posrisk);
                        PositionRisk += posrisk;
                    }
                }
                Position[] shortpositions = Positions.FindAll("Short");
                var shortpos = shortpositions;
                foreach (var pos in shortpos)
                {
                    if (pos.Comment != "" && pos.StopLoss != null && pos.StopLoss > pos.EntryPrice)
                    {
                        double SL = Convert.ToDouble(pos.StopLoss);
                        double posrisk = 0;
                        posrisk = Math.Round((((SL - pos.EntryPrice) / Symbols.GetSymbolInfo(pos.SymbolName).PipSize) * Symbols.GetSymbolInfo(pos.SymbolName).PipValue * pos.VolumeInUnits) - (2 * pos.Commissions) - pos.Swap, 2);
                        Print("pos.SymbolName = " + pos.SymbolName + ", posrisk = " + posrisk);
                        PositionRisk += posrisk;
                    }
                }
            }

            if (PendingOrders.Count > 0)
            {
                foreach (var order in PendingOrders)
                {
                    if (order.Comment != "")
                    {
                        var splitted = order.Comment.Split(' ');
                        double ep = Convert.ToDouble(splitted[2]);
                        double sl = Convert.ToDouble(splitted[4]);
                        double tp = Convert.ToDouble(splitted[5]);
                        if (order.TradeType == TradeType.Buy)
                        {
                            double orderrisk = 0;
                            orderrisk = Math.Round((((ep - sl) / Symbols.GetSymbolInfo(order.SymbolName).PipSize) * Symbols.GetSymbolInfo(order.SymbolName).PipValue * order.VolumeInUnits), 2);
                            Print("order.SymbolName = " + order.SymbolName + ", orderrisk = " + orderrisk);
                            OrderRisk += orderrisk;
                        }
                        if (order.TradeType == TradeType.Sell)
                        {
                            double orderrisk = 0;
                            orderrisk = Math.Round((((sl - ep) / Symbols.GetSymbolInfo(order.SymbolName).PipSize) * Symbols.GetSymbolInfo(order.SymbolName).PipValue * order.VolumeInUnits), 2);
                            Print("order.SymbolName = " + order.SymbolName + ", orderrisk = " + orderrisk);
                            OrderRisk += orderrisk;
                        }
                    }
                }
            }
        }

 

I think we are getting to a point in this community where our code is all similar and we should form an opensource focussed group to make good bots rather than the simple examples.

If anyone else is interested please say so!

 


@moiz.forex

moiz.forex
07 Sep 2022, 17:02

RE:

PanagiotisCharalampous said:

Hi,

You can try something like this

PlaceStopOrder(TradeType.Sell, SymbolName, _lots, Bars.LowPrices.Last(1) - (Symbol.PipSize * 20), _shortlabel, _sl, _tp);

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Ok so what you added after Last(1) -(Symbol.PipSize *20), the minus or the dash size gives command of less 20 pips and then at the buy side we will do + (Symbol.PipSize*20),

 

and if i want to change how many pips up and down i want all i can do is to change the 20 number is that rite?


@moiz.forex

moiz.forex
06 Sep 2022, 15:36

RE: Thank u

Thank You !! for your concern and assisting me sir

 

 

 

PanagiotisCharalampous said:

Dear moiz.forex,

If you need help with a specific method or you need direction, we are happy to help. But in your post you are asking for a complete cBot, trading in a specific way. If somebody is willing to develop it for free, then I have no objections :)

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 


@moiz.forex

moiz.forex
06 Sep 2022, 14:46

RE: Is it hard to make such a bot

Hello Panagiotis,

 

As i said i am new and i want  to learn to develop as well is it something hard to make or i can find it online somewhere as we have sample bots in ctrader

 

 

 

 

 

PanagiotisCharalampous said:

Dear moiz.forex,

If you need somebody to develop this for you, you can reach out to a consultant.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 


@moiz.forex