Replies

dwalkhul
10 Feb 2021, 00:05 ( Updated at: 10 Feb 2021, 00:08 )

RE:

PanagiotisCharalampous said:

Hi claye.weight,

There is no hard deadline for this. Whenever the new version is considered stable and ready for release to production environments.

Best Regards,

Panagiotis 

Join us on Telegram

Am I correct to assume that the Automate API version will always correspond to the cTrader version number ?
My current live and demo cTrader versions are 3.8, therefore my assumption is

  1. the Automated API version of these two cTraders are also 3.8 (Keydown Events not available)
  2. I am dependent on the Brokers for update to cTrader 4.0 which will include Automate API 4.0

@dwalkhul

dwalkhul
29 Dec 2020, 14:29 ( Updated at: 29 Dec 2020, 17:42 )

RE:

PanagiotisCharalampous said:

Hi mrha1000,

You seem to be using an event handler without an event. Did you just copy and paste this from somewhere?

Best Regards,

Panagiotis 

Join us on Telegram

Did you just copy and paste this from somewhere? Fair question, but no.

I  found numerous variation repeats of the below with regards C# Key Events

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

Control.KeyPress Event

Definition

Namespace:

System.Windows.Forms

Assembly:

System.Windows.Forms.dll

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

So went with

 using System.Windows.Forms;

which first required invoking Manage References >> .NET Framework >> System.Windows.Forms

The rest is straight forward standard code.

My original request: A test template -> any pointer how to get this to work - see Call KBE. I have tried numerous approaches without success. Meaning - I can't get past errors calling KBE to test if it will work. Thank you.

C# examples merely illustrate calling KBE as KBE(sender, e); but this produces error -

You seem to be using an event handler without an event. ? 

mmm ... yes..,.I thought I could call KBE and KBE would detect the relevant Key Events.

 

 

 

 

 


@dwalkhul

dwalkhul
29 Dec 2020, 08:44 ( Updated at: 29 Dec 2020, 08:56 )

Hello - A test template -> any pointer how to get this to work - see Call KBE. I have tried numerous approaches without success. Meaning - I can't get past errors calling KBE to test if it will work. Thank you.

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

namespace Key_Test
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class KeyTest : Robot
    {
        [Parameter("SL", Group = "Parameters", DefaultValue = 0)]
        public int defaultSL { get; set; }

        [Parameter("TP", Group = "Parameters", DefaultValue = 0)]
        public int defaultTP { get; set; }

        [Parameter("Lots", Group = "Parameters", DefaultValue = 0.01)]
        public double defaultLots { get; set; }

        private string label = "KeyTest";

        protected override void OnStart()
        {

            // Call KBE ????

        }

        private void KBE(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Z)
            {
                allClose();
            }
            else if (e.KeyCode == Keys.B)
            {
                entry(TradeType.Buy);
            }
            else if (e.KeyCode == Keys.S)
            {
                entry(TradeType.Sell);
            }
        }

        private void entry(TradeType type)
        {
            var order = ExecuteMarketOrder(type, SymbolName, defaultLots * 100000, label, defaultSL, defaultTP);
            if (!order.IsSuccessful)
            {
                Print("Error:{0}", order.Error.ToString());
            }
        }
        private void allClose()
        {
            var positions = Positions.FindAll(label);
            foreach (Position p in positions)
            {
                ClosePosition(p);
            }
        }
    }
}

 


@dwalkhul

dwalkhul
28 Dec 2020, 18:12 ( Updated at: 29 Dec 2020, 02:19 )

RE:

PanagiotisCharalampous said:

Hi dwalkhul,

  1. Can you kindly point to a source of understand Chart Key Events in cAlgo.

This is not available at the moment. It will be available in cTrader Desktop 4.0. 

  1. If not, how then, is Chart Key Events being implemented in the above referred bot ?

You need to ask the developer of the bot regarding this. Probably using Win32 API.

 Best Regards,

Panagiotis 

Join us on Telegram

Thank you for prompt response

In the interest of clarity and certainty, re - 'This is not available at the moment. It will be available in cTrader Desktop 4.0.'

Does this specifically mean

  1. Hotkey trade operations will be available as a built in feature of the cTrader Desktop 4 - in other words, trade operation hotkey allocation will be available through the cTrader Desktop 4 Graphic User Interface  - or
  2. Key Events will be available in - cAlgo - so coders can customize hotkey trade operations by means of code

3. What is the expected date of cTrader Desktop 4.0 ?

4. This forum does not have an immediate SPAM report facility - see immediate next post for fake certificates spam ! Can it be removed ?

 


@dwalkhul

dwalkhul
24 Dec 2020, 21:01 ( Updated at: 01 Jan 2021, 23:03 )

RE: Hotkey Trade Operations can be done by Code

PanagiotisCharalampous said:

Hi Tj,

You can read what a product backlog is here :)

Best Regards,

Panagiotis 

Join us on Telegram

Re below clause 2.   On reassement I consider the product not fit for reference and have withdrawn information.

Objectives:

  • Implementing cTrader hotkey trade operations by means of cAlgo/C# code offers superior versatility and customization than any future cTrader inbuilt trade operation hotkey functionality -  which will, if ever implemented, almost certainly be hotkey combinations (a key + another key) as opposed to a trade operation activated by a 'single key'.
  • Key combinations defeats the entire purpose of easy of use, speed, and efficiency - the additional use of an additional key to effect the trade operation is an unnecessary distraction.
  • The use of a single key for a trade operation is fast, most efficient and excludes additional distractions.
  • The use of single key trade functionality by means of code works to perfection - with respect my coding experience - in MT4/MT5 and Sierra Chart without conflicting or interfering with other programs that may use any on the same single hotkey or combination of hotkeys.

In MQL5 Chart Key Events are fairly straightforward.

#include <Trade\Trade.mqh>
//--- object of class CTrade
CTrade trade;
#include <Trade\PositionInfo.mqh>
CPositionInfo  m_position;      
#include <Trade\SymbolInfo.mqh>  
CSymbolInfo    m_symbol; 
#include <Trade\OrderInfo.mqh>
COrderInfo     m_order;   
......
......
#define KEY_AR_UP 38 // NL Up Arrow// BUY AT ASK
#define KEY_UP 104 // Up Arrow // BUY AT ASK
......
......
// BUY at Ask (market) /////////////////////
if(lparam == KEY_UP || lparam == KEY_AR_UP)
{
  cl=0;
  trade.Buy(LotSizex, NULL, SymbolInfoDouble(Symbol(),SYMBOL_ASK), SymbolInfoDouble(Symbol(),
  SYMBOL_ASK) - StopLoss*_Point, 0, NULL); 
  PlaySound(SND);
}

So here is the question and request:

  1. Can you kindly point to a source of understand Chart Key Events in cAlgo.
  2. If not, how then, is Chart Key Events being implemented in the above referred bot ?

 


@dwalkhul