Topics
24 Jul 2020, 23:15
 1
 1149
 1
11 Jun 2020, 20:55
 1074
 4
Replies

tgjobscv
11 Nov 2020, 17:26

Maybe usefull ? Tools for Signal Telegram:

using System;
using System.Linq;
using System.Net;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class tTelegramrepeater : Robot
    {
        [Parameter("Telegram Bot Key", DefaultValue = "__bot_key__")]
        public string BOT_API_KEY { get; set; }

        // if you know which channel you want to broadcast to, add it here
        // otherwise the bot looks at the people and channels its' interacted with and
        // sends messages to everyone
        [Parameter("ChannelId", DefaultValue = "")]
        public string ChannelId { get; set; }


        List<string> _telegramChannels = new List<string>();

        protected override void OnStart()
        {
            if (string.IsNullOrEmpty(ChannelId))
            {
                _telegramChannels = ParseChannels(GetBotUpdates());
            }
            else
            {
                _telegramChannels.Add(ChannelId);
            }



            // Subscribe to events.
            Positions.Opened += OnPositionOpened;
            Positions.Closed += OnPositionClosed;

        }

        protected override void OnTick()
        {
            // Put your core logic here

        }

        protected override void OnBar()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
            // Unsubscribe to events.
            Positions.Opened -= OnPositionOpened;
            Positions.Closed -= OnPositionClosed;
        }


        //  Parses messages for bot and determines which channesl are listening
        private List<string> ParseChannels(string jsonData)
        {
            var matches = new Regex("\"id\"\\:(\\d+)").Matches(jsonData);
            List<string> channels = new List<string>();
            if (matches.Count > 0)
            {
                foreach (Match m in matches)
                {
                    if (!channels.Contains(m.Groups[1].Value))
                    {
                        channels.Add(m.Groups[1].Value);
                    }
                }
            }
            foreach (var v in channels)
            {
                Print("DEBUG: Found Channel {0} ", v);
            }
            return channels;
        }

        protected int updateOffset = -1;
        private string GetBotUpdates()
        {
            Dictionary<string, string> values = new Dictionary<string, string>();
            if (updateOffset > -1)
            {
                values.Add("offset", (updateOffset++).ToString());
            }

            var jsonData = MakeTelegramRequest(BOT_API_KEY, "getUpdates", values);

            var matches = new Regex("\"message_id\"\\:(\\d+)").Matches(jsonData);
            if (matches.Count > 0)
            {
                foreach (Match m in matches)
                {
                    int msg_id = -1;
                    int.TryParse(m.Groups[1].Value, out msg_id);
                    if (msg_id > updateOffset)
                    {
                        updateOffset = msg_id;
                    }
                }
            }
            return jsonData;
        }

        private void SendMessageToAllChannels(string message)
        {
            foreach (var c in _telegramChannels)
            {
                SendMessageToChannel(c, message);
            }
        }

        private string SendMessageToChannel(string chat_id, string message)
        {
            var values = new Dictionary<string, string> 
            {
                {
                    "chat_id",
                    chat_id
                },
                {
                    "text",
                    message
                }
            };

            return MakeTelegramRequest(BOT_API_KEY, "sendMessage", values);
        }

        private string MakeTelegramRequest(string api_key, string method, Dictionary<string, string> values)
        {
            string TELEGRAM_CALL_URI = string.Format("https://api.telegram.org/bot{0}/{1}", api_key, method);

            var request = WebRequest.Create(TELEGRAM_CALL_URI);
            request.ContentType = "application/x-www-form-urlencoded";
            request.Method = "POST";

            StringBuilder data = new StringBuilder();
            foreach (var d in values)
            {
                data.Append(string.Format("{0}={1}&", d.Key, d.Value));
            }
            byte[] byteArray = Encoding.UTF8.GetBytes(data.ToString());
            request.ContentLength = byteArray.Length;

            Stream dataStream = request.GetRequestStream();

            dataStream.Write(byteArray, 0, byteArray.Length);

            dataStream.Close();

            WebResponse response = request.GetResponse();

            Print("DEBUG {0}", ((HttpWebResponse)response).StatusDescription);

            dataStream = response.GetResponseStream();

            StreamReader reader = new StreamReader(dataStream);

            string outStr = reader.ReadToEnd();

            Print("DEBUG {0}", outStr);

            reader.Close();

            return outStr;


        }

        public void OnPositionOpened(PositionOpenedEventArgs args)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            // If you didn't set a channel, thenfind channels by looking at the updates
            var data = string.Format("entry price: ={0} \nentry time: {1} \nsymbol: {2}\nstop loss: {3}\ntake profit: {4}", args.Position.EntryPrice, args.Position.EntryTime, args.Position.SymbolName, args.Position.StopLoss, args.Position.TakeProfit);
            Print("DEBUG", args);
            Print("DEBUG", data);
            SendMessageToAllChannels(data);
        }

        public void OnPositionClosed(PositionClosedEventArgs args)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var data = string.Format("net profit: {0}", args.Position.NetProfit);
            SendMessageToAllChannels(data);
        }
    }
}

 


@tgjobscv

tgjobscv
09 Nov 2020, 17:14 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE: RE:

trend_meanreversion said:

tgjobscv said:

trend_meanreversion said:

Made a small subtle change in the alternate models ( Model_3 & Model_5 ). Included StopLoss as part of strategy. 

Performance as per change is below :

 

 

Model3 

You can make copy signal ?

Yes I am currently thinking of how to make them available to potential investors. possibly via copy signals (cCopy), leasing algorithm , or just selling signals.

 

You can use naga trading platform, copyFX:

https://naga.com/register?refcode=xhfehn

 Profit for you.

 


@tgjobscv

tgjobscv
07 Nov 2020, 20:04 ( Updated at: 21 Dec 2023, 09:22 )

RE:

trend_meanreversion said:

Made a small subtle change in the alternate models ( Model_3 & Model_5 ). Included StopLoss as part of strategy. 

Performance as per change is below :

 

 

Model3 

You can make copy signal ?


@tgjobscv

tgjobscv
07 Nov 2020, 17:33

Tested in real account ?

Possible signal from Twitter and Telegram ? How step to step ?

ScalpDaxToCSV, GER30 m15.cbotset

Where good cbotset ?

Backtest make 0%


@tgjobscv

tgjobscv
07 Nov 2020, 17:12

http://mq4tocalgo.apphb.com/ 

This no convert.


@tgjobscv

tgjobscv
07 Nov 2020, 17:07

3g is fast for ctrader ?

Maybe 4G is better ?


@tgjobscv

tgjobscv
01 Nov 2020, 10:08

RE:

tgjobscv said:

Pyramid, pyramiding hiden pending Bot ?

Where ?

Similar to:

https://www.mql5.com/en/code/10832

Where for ctrader ?


@tgjobscv

tgjobscv
01 Nov 2020, 10:07

Cloud based is tradingview with webbacktest, 

ctrader can offer cloud backtest ?


@tgjobscv

tgjobscv
02 Aug 2020, 02:54

RE:

Spotware said:

We are happy to announce that we have completed integration of cTrader Web and Trading Central. Up to now, the Trading Central feature which was released in January 2016 was only available to cTrader Desktop users. Now we have extended the integration with Trading Central and now it becomes available to users of cTrader Web as well. 

The cTrader Web/Trading Central integration will now deliver Trading Central's industry leading market research into cTrader Web as a fully actionable trading signal in the exact same way as cTrader Desktop.

You can find a demo of the integration here https://ct.spotware.com

Where  is broker list with this options ? Not all broker offer trading central.


@tgjobscv

tgjobscv
01 Aug 2020, 22:07

RE:

You can make group in the facebook.

 


@tgjobscv

tgjobscv
01 Aug 2020, 22:04

30/06/2020 01:00:00.000 | Backtesting was stopped
30/06/2020 01:00:00.000 | Crashed in OnStop with NullReferenceException: Object reference not set to an instance of an object.
30/06/2020 01:00:00.000 | Crashed in OnStart with UnauthorizedAccessException: Access to the path 'c:\data.csv' is denied.
30/06/2020 01:00:00.000 | Backtesting started
 


@tgjobscv

tgjobscv
28 Jul 2020, 22:31

RE:

tgjobscv said:

 

MQ4 to cAlgo Converter Convert alternatives - http://mq4tocalgo.apphb.com/

+but when:

Success! Your conversion has no errors.

Converted Code:

--------------------------------------

Is blank empty?!

--------------------------------------

+but when:

Warning! Your conversion has 7 errors. It could not compile well.

Converted Code:

----------------------------------------

code is ready to copy and ok

----------------------------------------


@tgjobscv

tgjobscv
28 Jul 2020, 20:08

Server Error in '/' Application.


Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
 

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
 

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

@tgjobscv

tgjobscv
26 Jul 2020, 17:56

RE: Great Concept, a few bugs

Mr4x said:

Hi tgjobscv,

Your code works a treat when selling XAUUSD over the past 3 months of this year, however if you try to do a back-test on a $10,000 account over the past year (22-11-18 to 22-11-19) you do get 100% draw-down during December 2018. Might need to tweak the code a bit?

Anyway the feature that is broken is the ability to use this as "buy only". If you set "buy" to yes and "sell" to no then try and back-test, the cbot still places sell side orders. I'm looking at running a hedge-type situation using a buy with XAUEUR side-by-side with sell XAUUSD, so if you could fix the cbot and then maybe play around with that idea of mine too and see what you think.

Cheers,

Mr4x

up 07.2020

SellSmartGrid - Only - Sell trend (parametr Buy is ignoring) with MA and one way trend LimitStop Sell H1 H4 - only Sell trend backtest date.

 

What are your ideas for improving the code after testing - for Sell trend in xauusd, xagusd, majors etc ?

SellSmartGrid - improving ?!

 

How 1. cTrader demo to live ctrader, mt4/mt5 Trade Copier ?

How 2. mt4/mt5 demo to live ctrader, mt4/mt5 Trade Copier ?


@tgjobscv

tgjobscv
24 Jun 2020, 13:22

RE:

Now all browser is ok. 

Problem make ekstension.


@tgjobscv

tgjobscv
24 Jun 2020, 13:13

 

Firefox is ok


@tgjobscv

tgjobscv
24 Jun 2020, 10:53

RE: RE: RE: RE:

delete


@tgjobscv

tgjobscv
24 Jun 2020, 10:52

delete


@tgjobscv

tgjobscv
24 Jun 2020, 10:38

delete


@tgjobscv