ATcl - Tcl interpreter for MT4 - page 4

 
Алексей Барбашин:

Is there anything else you can squeeze out of ticks? )))

It's not just ticks :-)

If it will be "released", you will not be able to add/modify the structure... So if something is missing in the given table - it's worth telling at once.

ATcl demo - Cawt Excel

The simplest use scenario - the user/trader starts the indicator, it opens Excel and starts filling the table.

The user can fill it and add formulas. The result will be displayed in the MT4 chart and in indicator buffers (lines/arrows/yngraphs).

That is, an Excel user can create an indicator for MT4

 

Holiday screenshot :

ATcl - happy victory day!

From an upcoming demo :
The lines on the fly are calculated in Excel using its formulas, the greeting table is taken from there as well, and the links to all the useful stuff are clickable.
Here is the table itself:
ATcl - table

 
Why Excel? Maybe something more functional?
 
Алексей Тарабанов:
Why Excel? Maybe something more functional?

Because every trader knows Excel. (Of course, there may be some people who work with money and do not know how to use it).

This demo allows them, for example, to make their own indicator with their own calculations without having to think too much.
And the programmer can use the demo to learn how to work with MS-Office and attach the reports in Word and PowerPoint, schedules from OutLook and notes from OneNote to his own products

The version with OO::Calc is not suitable, because there is no OpenOffice programming interface.

 

Version is ready for release - moving to new domain and changing API in Set methods, check previous demos and fixing docks.

Fixed long promised demo for work with Web-sockets. My mistake - inadvertently added "eternal loop" inside of timer :-). Terminal hangs in the most unexpected places and never caught it in due time. And now came back with a fresh look and there it was !

ATcl - web socket

In the screenshot - running two demos at once, the first periodically and correctly takes a page of the site and parses freelance (where I'm probably forever banned)

The second (what's displayed in the log) is the same web socket that opens the Binance.com connection , subscribes to the current symbol and reads the stream in real time

 

Tk has started to work - it will be possible to build a GUI with scripts.

ATcl - Tk

The mini-panel is the Tk window in which its widgets are laid out.

Everything runs from MT4, data is transferred to the window and read from the window.

The MQL-source, which does not depend on the complexity of GUI to be drawn:

#include <ATcl/ATcl.mqh>

bool hasTimer=false;
ATcl *tcl=NULL;
Tcl_Obj panel=0,methodMessages=0,methodOnTick=0,methodDestroy=0;

int OnInit()
{
   // инициализируем библиотеку и интерпретатор разом
   if (ATcl_OnTkInit()==0 || (tcl=new ATcl)==NULL || !tcl.Ready()) {
      return INIT_FAILED;
   }
   // нам требуется Tk
   tcl.Eval("package require Tk");
   // "спрячем" корневое окно
   tcl.Eval("wm withdraw .");
   // загрузим исходник класса
   tcl.Eval("source MQL4/Files/ATcl/TradePanel.tcl");
   // создаём экземпляр - запускаем панельку
   tcl.Set("Symbol",_Symbol); // подствим переменную в след.выражение
   panel=tcl.ObjEval("TradePanel new .tradePanel $Symbol");
   if (panel==0) {
      return INIT_FAILED;
   }
   tcl.Ref(panel);
   // будем пользоваться этими методами:
   methodMessages=tcl.Ref(tcl.Obj("Messages"));
   methodOnTick=tcl.Ref(tcl.Obj("OnTick"));
   methodDestroy=tcl.Ref(tcl.Obj("destroy"));
   hasTimer=EventSetMillisecondTimer(100);
   
   return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
   if (hasTimer) EventKillTimer();
   if (tcl!=NULL) {
      if (panel!=0)  tcl.Call(panel,methodDestroy);
      tcl.Unref(panel);
      tcl.Unref(methodMessages);
      tcl.Unref(methodOnTick);
      tcl.Unref(methodDestroy);
      tcl.Eval("destroy .");
      delete tcl;
   }
   ATcl_OnDeinit(reason);
}
void OnTick()
{
   CheckMessages();
   tcl.Call(panel,methodOnTick,tcl.Obj(Bid),tcl.Obj(Ask));
}

void OnTimer()
{
   CheckMessages();
   tcl.Eval("update idletasks");
}
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   if ( ! hasTimer) EventSetMillisecondTimer(100);
   CheckMessages();
}

void OnGUI(Tcl_Obj msg) {
   tcl.Ref(msg);
   PrintFormat("On GUI: %s",tcl.String(msg));
   tcl.Unref(msg);
}

void CheckMessages() {
   tcl.Update();
   if (tcl.Call(panel,methodMessages)==TCL_OK) {
      Tcl_Obj msgs=tcl.Ref(tcl.Result());
      if (tcl.Count(msgs)>0) {
         // есть сообщения от GUI
         for(int i=tcl.Count(msgs)-1;i>=0;i--) {
            Tcl_Obj msg=tcl.ListIndex(msgs,i);
            if (msg!=0) OnGUI(msg);
         }
      }
      tcl.Unref(msgs);
   }
}
 
Maxim Kuznetsov:

Tk has started to work - it will be possible to build a GUI with scripts.


The mini-panel is the Tk window in which its widgets are laid out.

Everything runs from MT4, data is transferred to the window and read from the window.

The MQL-source, which does not depend on the complexity of GUI to be drawn:

Super! Looking forward...

 
Maxim Kuznetsov:

Tk has started to work - it will be possible to build a GUI with scripts.


The mini-panel is the Tk window in which its widgets are laid out.

Everything runs from MT4, data is transferred to the window and read from the window.

The MQL-source, which does not depend on the complexity of GUI to be drawn:

Here's the slightly modified tcl sours which implements the graphics (panel):
#  простая торговая панель
oo::class create TradePanel {
variable W                      ; #  имя окна Tk
variable Symbol         ; #  символ
variable Bid            ; #  значение Bid
variable Ask            ; #  значение Ask
variable LabelBid       ; #  имя виджета с Bid 
variable LabelAsk       ; #  имя виджета с Ask
variable Outgoing       ; #  простая очередь исходящих (чтобы MT её считывал, сами мы MT вызывать не можем)
constructor { w symbol } {
        set W $w
        set Symbol $symbol
        set Bid 0
        set Ask 0
        set LabelBid ""
        set LabelAsk ""
        set Outgoing {}
        my Draw
}
destructor {
        catch { destroy $W }
}
method Draw { } {
        #  создаём окно
        set W [ toplevel $W ]   ; #  toplevel окно
        wm protocol $W WM_DELETE_WINDOW {}      ; #  запретим закрывать по "крестику"
        wm title $W $Symbol             ; #  выведем заголовок
        #  сделаем выпадающее меню с единственным пунктом About
        set mainMenu [ menu $W.menu -tearoff 0 ]
        $mainMenu add cascade -label "Help" -menu $W.menu.help
        set helpMenu [ menu $W.menu.help -tearoff 0 ]
        $helpMenu add command -label "About" -command [ list tk_messageBox -parent $W -title "TradePanel" -message "ATcl demonstation" ]
        #  назначим его как меню окна
        $W configure -menu $W.menu
        #  и в окне всякие элементы
        set f [ frame $W.panel ]
        label $f.title -text $Symbol -fg grey -font "{Arial Black}"
        set LabelBid [ label $f.bid  -fg grey -font "{Arial Black}" ]
        set LabelAsk [ label $f.ask  -fg grey -font "{Arial Black}" ]
        button $f.buy  -text "Buy"  -fg blue -font "{Arial Black}" -command [ list [ self ] OnBuyPressed ] ; #  кнопка Buy - при нажатии вызовет собственный метод OnBuyPressed
        button $f.sell -text "Sell" -fg red -font "{Arial Black}" -command [ list [ self ] OnSellPressed ]
        #  проще всего располагать элементы в таблице
        grid $f.title -row 0 -column 0 -columnspan 2 -sticky "ew"
        grid $f.bid -row 1 -column 0 -sticky "e"
        grid $f.ask -row 1 -column 1 -sticky "w"
        grid $f.sell -row 2 -column 0 -sticky "nsew"
        grid $f.buy -row 2 -column 1 -sticky "nsew"
        grid columnconfigure $f 0 -uniform same
        grid columnconfigure $f 1 -uniform same
        #  фрейм с контролами - на всё окно
        pack $f -fill both -expand yes
        
        return $W
}
method OnBuyPressed {} {
        #  при нажатии кнопки Buy :
        #  добавить в исходящий список сообщение 
        lappend Outgoing [ list "buy" [ clock milliseconds ] ]
}
method OnSellPressed {} {
        #  при нажатии кнопки Sell :
        #  добавить в исходящий список сообщение 
        lappend Outgoing [ list "sell" [ clock milliseconds ] ]
}
#  метод будет вызываться из MT когда приходит новый тик
#  поменяем значения в виджетах и раскрасим заодно 
method OnTick { bid ask } {
        if { $bid == $Bid } {
                $LabelBid configure -fg grey
        } elseif { $bid > $Bid } {
                $LabelBid configure -fg blue
        } else {
                $LabelBid configure -fg red
        }
        if { $ask == $Ask } {
                $LabelAsk configure -fg grey
        } elseif { $ask > $Ask } {
                $LabelAsk configure -fg blue
        } else {
                $LabelAsk configure -fg red
        }
        set Bid $bid
        set Ask $ask
        $LabelAsk configure -text $Ask
        $LabelBid configure -text $Bid
}
#  метод будет вызываться из MT чтобы считать все сообщения
method Messages {} {
        set msgs $Outgoing
        set Outgoing {}
        return $msgs
}

export OnBuyPressed OnSellPressed
export OnTick Messages
} ; # /class TradePanel

#####  TEST CASE для автономного запуска #####
if { [ info exists argv0 ] && $argv0 == [ info script ] } {
        package require Tk
        set panel [ TradePanel new .tradePanel "EURUSD" ]
        $panel OnTick 1.2345 1.1234
        update
        wm withdraw .
        tkwait window .tradePanel
        exit
}
I just finished all the small bugs related to graphics, I'm happy with it !

I'll post the library tomorrow morning - I'll check it again in the afternoon and post it
 

ATcl Beta 2 release

With a slight delay, a new version of ATcl has been released.

Release details, see http://nektomk.ru/atcl:beta2

Since there were problems with the domain, to make the distribution available, a project on SourceForge has been made: https://sourceforge.net/projects/mt-atcl/

The project can be downloaded from the SF page or from the usual download page: http://nektomk.ru/atcl:install

archive also attached

New features:

- WebSocket handling demo added

- Excel management and data exchange demo added

- Tk is now up and running (demo is also available) - now you can quickly and easily make the most sprawling GUI

Known bug:

- At the last moment it was detected: there is a conflict when simultaneously loading on one chart indicators ATcl and EA using Tk. The nature of the error is clear, but it has not been logged in the code yet and therefore it has not been fixed yet.
Separately, they all work fine, so I've decided to release it with this bug.

PS. Whether site glitches or browser, but this message I fill 3rd time.

ATcl - "beta 2" version
ATcl - "beta 2" version
  • nektomk.ru
Рад представить новую версию ATcl. Была продолжена работа по унификации и упрощению API, удалось добиться стабильной работы Tk в экспертах. Демки пополнились двумя полезными демонстрациями. В новой версии API Изменён синтаксис методов Set - они всегда принимают непосредственное MQL значение в качестве параметров. Для того чтобы присвоить...
Files:
atcl.zip  6651 kb
 
Maxim Kuznetsov:

ATcl Beta 2 release

With a slight delay, a new version of ATcl has been released.

Release details, see http://nektomk.ru/atcl:beta2

Since there were problems with the domain, to make the distribution available, a project on SourceForge has been made: https://sourceforge.net/projects/mt-atcl/

The project can be downloaded from the SF page or from the usual download page: http://nektomk.ru/atcl:install

The archive is also attached

New features:

- WebSocket handling demo added

- Excel management and data exchange demo added

- Tk is now up and running (demo is also available) - now you can quickly and easily make the most sprawling GUI

Known bug:

- At the very last moment I've found: there is a conflict with simultaneous loading of ATcl indicators and EA using Tk on one chart. The nature of the error is clear, but it has not been logged in the code yet and therefore it has not been fixed yet.
Separately, they all work fine, so I've decided to release it with this bug.

PS. Whether site glitches or browser, but this message I fill 3rd time.

Great! Let's test it! )))

Reason: