v.fiodorov83
v.fiodorov83's avatar

Info

Username:v.fiodorov83
Name:v.fiodorov83
Member since: 24 Jul 2019

About

None

Signature

None

Last Forum Posts

@Signals from my cBot to my telegram acc:  14 Jan 2022, 10:27


Hi,

Can you please post the raw full JSON response, so I will be able to deserialize it on my system and see what's wrong.


If you don't mind, then let's continue our conversation in the telegram, because if I insert data here, it will be just a mess and it will be hard for you to dig into it. In the telegram, I will send you a direct link and you will have a look. And if we manage to fix it, then we will write in this thread of the forum. How do you like this idea?

@Signals from my cBot to my telegram acc:  13 Jan 2022, 20:17


amusleh said:

v.fiodorov83 said:

amusleh said:

Hi,

You don't have to use this library for sending alerts to Telegram, you can use the Telegram .NET library that I mentioned on my first post.

You can also code the whole API interaction by yourself, you don't have to use any library, but they will make it much easier for you.

Well, you see, it turns out that if somewhere you have some library or dependency has the wrong version, different in x.x.x.x.1, then all this will not work and find where exactly the problem is unrealistic to find.

Nevertheless, thank you for your help and have a nice day.

Hi,

Telegram.Bot library can't deserialize the conversation updates, because one of the fields that must be integer comes as an empty string.

Either its the error code or the update ID, those are integers.

To find what's causing this issue, open the Telegram Bot API getUpdates on your browser: api.telegram.org/bot<your Bot Token>/getUpdates

Replace "your Bot Token" with your bot token, and post the response here.


Well, here's a screenshot for an example. Here is the log of my conversation with the bot and there is also a log of his entry into the group. He has no messages from the terminal or any requests ..

What else is interesting. In the "Alerts" window you can write any nonsense in Username/Chanel form, if the token is correct, then it does not display the error "wrong group name or username", and then it also crashes

@Signals from my cBot to my telegram acc:  13 Jan 2022, 18:05


amusleh said:

Hi,

You don't have to use this library for sending alerts to Telegram, you can use the Telegram .NET library that I mentioned on my first post.

You can also code the whole API interaction by yourself, you don't have to use any library, but they will make it much easier for you.

Well, you see, it turns out that if somewhere you have some library or dependency has the wrong version, different in x.x.x.x.1, then all this will not work and find where exactly the problem is unrealistic to find.

Nevertheless, thank you for your help and have a nice day.

@Signals from my cBot to my telegram acc:  13 Jan 2022, 17:28


v.fiodorov83 said:

amusleh said:

v.fiodorov83 said:

amusleh said:

Hi,

Just tested it with the code you posted, worked fine on my system, the popup showed up and I got a message on Telegram.

Did you made any kind of change on the code? or you used the same exact posted code?

I noticed the following in the error text. In the very first line of the log

.....Culture=neutral, PublicKeyToken=null]]. The value '    ' cannot be parsed as the type 'Int32'.

It turns out that he passes NULL instead of a token, and then he tries to pass the value "  ", converting it to Int32 (Failed and an error is thrown )

No, that's not the case.

It looks like something is going wrong outside the scope of my code, it's something related to WPF.

I recorded a video that shows it's working fine on my system:

I believed you even before you posted your video. ) I will try to run it on another Windows machine.  It's just not clear what needs to be reinstalled, which library

I tried it on a different machine, and even with a different hardware, without success. I also tried to collect the sAlgo file, and run it on other machines, nothing. It seems unrealistic to me. Too uninformative error ((Are there any other ways to connect telegrams for alerts?

@Signals from my cBot to my telegram acc:  13 Jan 2022, 15:08


amusleh said:

v.fiodorov83 said:

amusleh said:

Hi,

Just tested it with the code you posted, worked fine on my system, the popup showed up and I got a message on Telegram.

Did you made any kind of change on the code? or you used the same exact posted code?

I noticed the following in the error text. In the very first line of the log

.....Culture=neutral, PublicKeyToken=null]]. The value '    ' cannot be parsed as the type 'Int32'.

It turns out that he passes NULL instead of a token, and then he tries to pass the value "  ", converting it to Int32 (Failed and an error is thrown )

No, that's not the case.

It looks like something is going wrong outside the scope of my code, it's something related to WPF.

I recorded a video that shows it's working fine on my system:

I believed you even before you posted your video. ) I will try to run it on another Windows machine.  It's just not clear what needs to be reinstalled, which library

@Signals from my cBot to my telegram acc:  13 Jan 2022, 13:37


amusleh said:

Hi,

Just tested it with the code you posted, worked fine on my system, the popup showed up and I got a message on Telegram.

Did you made any kind of change on the code? or you used the same exact posted code?

I noticed the following in the error text. In the very first line of the log

.....Culture=neutral, PublicKeyToken=null]]. The value '    ' cannot be parsed as the type 'Int32'.

It turns out that he passes NULL instead of a token, and then he tries to pass the value "  ", converting it to Int32 (Failed and an error is thrown )

@Signals from my cBot to my telegram acc:  13 Jan 2022, 12:57


amusleh said:

Hi,

Just tested it with the code you posted, worked fine on my system, the popup showed up and I got a message on Telegram.

Did you made any kind of change on the code? or you used the same exact posted code?

Weird. I am using exactly the same code. NET Framework 4.5, as you have in the description. Local notifications in the pop-up window appear correctly and without problems. As soon as you enter the name of the telegram channel and the robot token, you press Add, it takes a couple of seconds and everything crashes. I also tried to enter my login and the login of the robot, the same thing

@Signals from my cBot to my telegram acc:  13 Jan 2022, 12:21


amusleh said:

Hi,

No, I don't have such a code example, please use the Alert library I posted on my previously.

Read its documentation: Home · afhacker/ctrader-alert_popup Wiki (github.com)

You can send Telegram messages just with one line of code if you use the alert library.

Hello again. Only now I was able to do this and immediately got a crash. It occurs when a message is sent to the bot.

I just took that code from your link. I created a bot exactly according to your instructions. I don’t understand what is the problem? What can't he parse?


2022-01-13 09:51:28 => 
OS Version: Microsoft Windows NT 10.0.19042.0
System Type: 64-bit
Source: System.Runtime.Serialization
Message: There was an error deserializing the object of type TelegramBotApi.Types.ApiResponse`1[[TelegramBotApi.Types.Update[], TelegramBotApi, Version=1.1.3.0, Culture=neutral, PublicKeyToken=null]]. The value '    ' cannot be parsed as the type 'Int32'.
TargetSite: System.Object ReadObjectHandleExceptions(System.Runtime.Serialization.XmlReaderDelegator, Boolean, System.Runtime.Serialization.DataContractResolver)
Type: System.Runtime.Serialization.SerializationException
StackTrace:
    File:  | Line: 0 | Col: 0 | Offset: 129 | Method: System.Object ReadObjectHandleExceptions(System.Runtime.Serialization.XmlReaderDelegator, Boolean, System.Runtime.Serialization.DataContractResolver)
    File:  | Line: 0 | Col: 0 | Offset: 0 | Method: System.Object ReadObject(System.Xml.XmlDictionaryReader)
    File:  | Line: 0 | Col: 0 | Offset: 0 | Method: T Deserialize[T](System.String)
    File:  | Line: 0 | Col: 0 | Offset: 166 | Method: TelegramBotApi.Types.ApiResponse`1[TResponse] MakeRequest[TResponse](TelegramBotApi.Requests.Abstractions.IRequest`1[TResponse])
    File:  | Line: 0 | Col: 0 | Offset: 72 | Method: Void AddTelegramConversation()
    File:  | Line: 0 | Col: 0 | Offset: 81 | Method: Void CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
    File:  | Line: 0 | Col: 0 | Offset: 25 | Method: Void OnClick()
    File:  | Line: 0 | Col: 0 | Offset: 26 | Method: Void OnClick()
    File:  | Line: 0 | Col: 0 | Offset: 83 | Method: Void OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs)
    File:  | Line: 0 | Col: 0 | Offset: 7 | Method: Void InvokeHandler(System.Delegate, System.Object)
    File:  | Line: 0 | Col: 0 | Offset: 61 | Method: Void InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
    File:  | Line: 0 | Col: 0 | Offset: 230 | Method: Void InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
    File:  | Line: 0 | Col: 0 | Offset: 109 | Method: Void ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs, System.Windows.RoutedEvent)
    File:  | Line: 0 | Col: 0 | Offset: 70 | Method: Void OnMouseUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
    File:  | Line: 0 | Col: 0 | Offset: 7 | Method: Void InvokeHandler(System.Delegate, System.Object)
    File:  | Line: 0 | Col: 0 | Offset: 61 | Method: Void InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
    File:  | Line: 0 | Col: 0 | Offset: 230 | Method: Void InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
    File:  | Line: 0 | Col: 0 | Offset: 87 | Method: Void RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
    File:  | Line: 0 | Col: 0 | Offset: 20 | Method: Void RaiseTrustedEvent(System.Windows.RoutedEventArgs)
    File:  | Line: 0 | Col: 0 | Offset: 495 | Method: Boolean ProcessStagingArea()
    File:  | Line: 0 | Col: 0 | Offset: 36 | Method: Boolean ProcessInput(System.Windows.Input.InputEventArgs)
    File:  | Line: 0 | Col: 0 | Offset: 53 | Method: Boolean ReportInput(System.Windows.Input.InputReport)
    File:  | Line: 0 | Col: 0 | Offset: 528 | Method: Boolean ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawMouseActions, Int32, Int32, Int32)
    File:  | Line: 0 | Col: 0 | Offset: 588 | Method: IntPtr FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr, Boolean ByRef)
    File:  | Line: 0 | Col: 0 | Offset: 84 | Method: IntPtr InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
    File:  | Line: 0 | Col: 0 | Offset: 48 | Method: IntPtr WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
    File:  | Line: 0 | Col: 0 | Offset: 54 | Method: System.Object DispatcherCallbackOperation(System.Object)
    File:  | Line: 0 | Col: 0 | Offset: 119 | Method: System.Object InternalRealCall(System.Delegate, System.Object, Int32)
    File:  | Line: 0 | Col: 0 | Offset: 2 | Method: System.Object TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
    File:  | Line: 0 | Col: 0 | Offset: 187 | Method: System.Object LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
    File:  | Line: 0 | Col: 0 | Offset: 304 | Method: IntPtr SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
    File:  | Line: 0 | Col: 0 | Offset: -1 | Method: IntPtr DispatchMessage(System.Windows.Interop.MSG ByRef)
    File:  | Line: 0 | Col: 0 | Offset: 64 | Method: Void PushFrameImpl(System.Windows.Threading.DispatcherFrame)
    File:  | Line: 0 | Col: 0 | Offset: 280 | Method: System.Object ShowHelper(System.Object)
    File:  | Line: 0 | Col: 0 | Offset: 492 | Method: System.Nullable`1[System.Boolean] ShowDialog()
    File:  | Line: 0 | Col: 0 | Offset: 13 | Method: Void <Run>b__30_0()
    File:  | Line: 0 | Col: 0 | Offset: 153 | Method: Void Invoke(System.Action, System.Windows.Threading.DispatcherPriority, System.Threading.CancellationToken, System.TimeSpan)
    File:  | Line: 0 | Col: 0 | Offset: 28 | Method: Void Invoke(System.Action)
    File:  | Line: 0 | Col: 0 | Offset: 81 | Method: Void <ShowPopup>b__0()



    InnerException:
    Source: System.Runtime.Serialization
    Message: The value '    ' cannot be parsed as the type 'Int32'.
    TargetSite: Int32 ParseInt(System.String, System.Globalization.NumberStyles)
    Type: System.Xml.XmlException
    StackTrace:
        File:  | Line: 0 | Col: 0 | Offset: 40 | Method: Int32 ParseInt(System.String, System.Globalization.NumberStyles)
        File:  | Line: 0 | Col: 0 | Offset: 0 | Method: Char ParseChar(System.String, System.Globalization.NumberStyles)
        File:  | Line: 0 | Col: 0 | Offset: 83 | Method: Void ReadEscapedCharacter(Boolean)
        File:  | Line: 0 | Col: 0 | Offset: 346 | Method: Boolean Read()
        File:  | Line: 0 | Col: 0 | Offset: 207 | Method: System.String ReadContentAsString(Int32)
        File:  | Line: 0 | Col: 0 | Offset: 53 | Method: System.String ReadElementContentAsString()
        File:  | Line: 0 | Col: 0 | Offset: -1 | Method: System.Object ReadUserFromJson(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString[])
        File:  | Line: 0 | Col: 0 | Offset: 7 | Method: System.Object ReadJsonValueCore(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 16 | Method: System.Object ReadJsonValue(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 0 | Method: System.Object ReadDataContractValue(System.Runtime.Serialization.DataContract, System.Runtime.Serialization.XmlReaderDelegator)
        File:  | Line: 0 | Col: 0 | Offset: 631 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, System.String, System.String, System.Type, System.Runtime.Serialization.DataContract ByRef)
        File:  | Line: 0 | Col: 0 | Offset: 49 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, Int32, System.RuntimeTypeHandle, System.String, System.String)
        File:  | Line: 0 | Col: 0 | Offset: -1 | Method: System.Object ReadMessageFromJson(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString[])
        File:  | Line: 0 | Col: 0 | Offset: 7 | Method: System.Object ReadJsonValueCore(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 16 | Method: System.Object ReadJsonValue(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 0 | Method: System.Object ReadDataContractValue(System.Runtime.Serialization.DataContract, System.Runtime.Serialization.XmlReaderDelegator)
        File:  | Line: 0 | Col: 0 | Offset: 631 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, System.String, System.String, System.Type, System.Runtime.Serialization.DataContract ByRef)
        File:  | Line: 0 | Col: 0 | Offset: 49 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, Int32, System.RuntimeTypeHandle, System.String, System.String)
        File:  | Line: 0 | Col: 0 | Offset: -1 | Method: System.Object ReadUpdateFromJson(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString[])
        File:  | Line: 0 | Col: 0 | Offset: 7 | Method: System.Object ReadJsonValueCore(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 16 | Method: System.Object ReadJsonValue(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 0 | Method: System.Object ReadDataContractValue(System.Runtime.Serialization.DataContract, System.Runtime.Serialization.XmlReaderDelegator)
        File:  | Line: 0 | Col: 0 | Offset: 631 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, System.String, System.String, System.Type, System.Runtime.Serialization.DataContract ByRef)
        File:  | Line: 0 | Col: 0 | Offset: 49 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, Int32, System.RuntimeTypeHandle, System.String, System.String)
        File:  | Line: 0 | Col: 0 | Offset: -1 | Method: System.Object ReadArrayOfUpdateFromJson(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString, System.Runtime.Serialization.CollectionDataContract)
        File:  | Line: 0 | Col: 0 | Offset: 55 | Method: System.Object ReadJsonValueCore(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 16 | Method: System.Object ReadJsonValue(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 0 | Method: System.Object ReadDataContractValue(System.Runtime.Serialization.DataContract, System.Runtime.Serialization.XmlReaderDelegator)
        File:  | Line: 0 | Col: 0 | Offset: 631 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, System.String, System.String, System.Type, System.Runtime.Serialization.DataContract ByRef)
        File:  | Line: 0 | Col: 0 | Offset: 49 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, Int32, System.RuntimeTypeHandle, System.String, System.String)
        File:  | Line: 0 | Col: 0 | Offset: -1 | Method: System.Object ReadApiResponseOfArrayOfUpdateGM0objc9FromJson(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString[])
        File:  | Line: 0 | Col: 0 | Offset: 7 | Method: System.Object ReadJsonValueCore(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 16 | Method: System.Object ReadJsonValue(System.Runtime.Serialization.XmlReaderDelegator, System.Runtime.Serialization.Json.XmlObjectSerializerReadContextComplexJson)
        File:  | Line: 0 | Col: 0 | Offset: 0 | Method: System.Object ReadDataContractValue(System.Runtime.Serialization.DataContract, System.Runtime.Serialization.XmlReaderDelegator)
        File:  | Line: 0 | Col: 0 | Offset: 631 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, System.String, System.String, System.Type, System.Runtime.Serialization.DataContract ByRef)
        File:  | Line: 0 | Col: 0 | Offset: 44 | Method: System.Object InternalDeserialize(System.Runtime.Serialization.XmlReaderDelegator, System.Type, System.Runtime.Serialization.DataContract, System.String, System.String)
        File:  | Line: 0 | Col: 0 | Offset: 213 | Method: System.Object InternalReadObject(System.Runtime.Serialization.XmlReaderDelegator, Boolean)
        File:  | Line: 0 | Col: 0 | Offset: 116 | Method: System.Object ReadObjectHandleExceptions(System.Runtime.Serialization.XmlReaderDelegator, Boolean, System.Runtime.Serialization.DataContractResolver)



        InnerException:
        Source: mscorlib
        Message: Input string was not in a correct format.
        TargetSite: Void StringToNumber(System.String, System.Globalization.NumberStyles, NumberBuffer ByRef, System.Globalization.NumberFormatInfo, Boolean)
        Type: System.FormatException
        StackTrace:
            File:  | Line: 0 | Col: 0 | Offset: 92 | Method: Void StringToNumber(System.String, System.Globalization.NumberStyles, NumberBuffer ByRef, System.Globalization.NumberFormatInfo, Boolean)
            File:  | Line: 0 | Col: 0 | Offset: 32 | Method: Int32 ParseInt32(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo)
            File:  | Line: 0 | Col: 0 | Offset: 0 | Method: Int32 ParseInt(System.String, System.Globalization.NumberStyles)

And here is the source code:

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

using cAlgo.API.Alert.Utility;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class Alerttester : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        private int _barIndex;
        protected override void OnStart()
        {
            // Optional, if you want to see the alert library logs on cTrader logs tab then set this
            Logger.Tracer = Print;
        }
        protected override void OnBar()
        {
            int index = Bars.ClosePrices.Count - 1;
            if (_barIndex != index)
            {
                _barIndex = index;

                TradeType tradeType = Bars.ClosePrices[index - 1] > Bars.OpenPrices[index - 1] ? TradeType.Buy : TradeType.Sell;

                Notifications.ShowPopup(Bars.TimeFrame, Symbol, tradeType, "AlertTest cBot", Symbol.Bid, "No comment", Server.Time);
            }
        }
        protected override void OnTick()
        {
            // Put your core logic here
        }

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

@Signals from my cBot to my telegram acc:  21 Dec 2021, 13:57


amusleh said:

Hi,

You can use Telegram API on your indicators/cBots, you can implement the API in .NET by your self or I recommend you to use the popular Telegram.Bot library: TelegramBots/Telegram.Bot: .NET Client for Telegram Bot API (github.com)

If you are looking for an example or a quick way you can use this library: afhacker/ctrader-alert_popup: Alert Popup For cTrader (github.com)

@Signals from my cBot to my telegram acc:  19 Dec 2021, 23:15


Hello dear developers.

What code can be added to the robot so that it can send (for example, a signal for crossing the MA by the price, or just some kind of print) to me in telegram?

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.