MyLanguage Doc

Penulis:Mimpi kecil, Dicipta: 2022-06-30 18:24:06, Dikemas kini: 2024-02-06 17:36:19

[TOC]

img

MyLanguage adalah bahasa perdagangan berprogram yang serasi dan dipertingkatkan dengan MyLanguage. MyLanguage FMZ Quant akan menjalani pemeriksaan sintaks yang ketat. Sebagai contoh, apabila menggunakan peningkatan bahasa untuk menyematkan kod bahasa JavaScript, karakter ruang tambahan selepas%%Operator akan menyebabkan kesilapan dilaporkan.

  • Arahan asas

    • Kontrak

      Kontrak Cryptocurrency

      Kontrak Cryptocurrency

      this_week     cryptocurrency futures contract this week
      next_week     cryptocurrency futures contract next week
      month         cryptocurrency futures contract month
      quarter       cryptocurrency futures contract quarter
      next_quarter  cryptocurrency futures contract next quarter
      third_quarter cryptocurrency futures contract third quarter
      last_quarter  contract last quarter
      
      XBTUSD        BITMEX perpetual contract
      swap          cryptocurrency futures perpetual contracts other than BITMEX exchange
      
      For details, please refer to the exchange.SetContractType() function section of the JavaScript/Python/C++ documentation
      

      img

    • Variabel

      Variabel adalah ruang yang dibuka dalam memori komputer untuk menyimpan data.

      buka pembolehubah pertama

      // assign 1 to variable a
      a:=1;
      

      DalamMyLanguage, ia mudah untuk membezakan daridata volume:

      1. Data bernilai tunggal: Hanya ada satu nilai, seperti:0, 1, 'abc'.
      2. Data urutan: urutan data yang terdiri daripada sekumpulan data bernilai tunggal, seperti:Close(harga penutupan), di manaClosemengandungi harga penutupann periods. [ 10.1 , 10.2 , 10.3 , 10.4 , 10.5 ...]

      Membezakan dari jenis pembolehubah

      1. Jenis rentetan: ia mesti dibungkus dengan ````, jenis rentetan tidak dibenarkan digunakan secara langsung, dan ia perlu output ke pandangan dengan fungsi.
      INFO(CLSOE>OPEN,'OK!');
      
      1. Jenis nilai: termasuk bilangan bulat, nombor koma terapung (desimal).
      // integer
      int:=2;
      
      // decimal
      float:=3.1;
      
      1. Jenis Boolean, menggunakan 1 (untuk benar) atau 0 (untuk palsu): 1, 0, benar atau palsu. Contohnya:A:=1>0;Selepas kod ini dijalankan, nilaiAialah 1.
      // The closing price of the current period is greater than -999, you will find that the return value of each period is 1, which means true, because the closing price is almost impossible to be negative.
      is_true:=Close>-999;
      
      1. Peralihan global
      VARIABLE:VALUE1:10;     // Declare a global variable, assign the value 10, and execute it only once.
      

      Perhatikan bahawa apabila backtesting:

      VARIABLE:NX:0;    // The initial global variable NX is 0
      NX..NX+1;         // Accumulate 1 each time
      INFO(1,NX);       // Print NX every time
      

      Pada mulanya,INFOcetakan pernyataan101Mungkin tidak.0Pada mulanya? Sebabnya ialah terdapat 100 garis K awal dalam backtest, dan 100 garis K telah dijalankan, yang telah terkumpul 100 kali. Harga sebenar bergantung kepada berapa banyak K-line yang diperoleh pada mulanya.

      • Peraturan penamaan

        Dalam kebanyakan sistem, penamaan pembolehubah tidak membenarkan penggunaan sistem kata-kata terhad (nama pembolehubah terbina dalam, nama fungsi).Close, CDi samping itu, nombor tulen atau nombor utama tidak dibenarkan. Akhirnya, ia tidak dibenarkan menjadi sangat panjang, dan sistem yang berbeza mempunyai sekatan panjang yang berbeza. Pada hakikatnya, anda tidak perlu risau tentang kecekapan sistem arus perdanas parsing bahasa Cina. Saya percaya bahawa MyLanguage sangat mesra dengan bahasa Cina. Untuk pengaturcara yang berpengalaman, disyorkan agar anda menggunakan dua peraturan penamaan berikut:

        1. Nama Cina
        // elegant output
        5-day moving average:=MA(C,5);
        
        1. Bahasa Inggeris + digariskan
        // Output
        move_avg_5:=MA(C,5);
        

        Jika anda lebih suka bahasa Inggeris, cuba untuk membuat makna pembolehubah anda yang mudah difahami.A1, AAA, BBB... Percayalah, apabila anda mengkaji semula kod penunjuk anda dalam beberapa hari, anda akan sangat malang kerana kehilangan ingatan.

        Oleh itu, mula sekarang, gunakan MyLanguage sepenuhnya! Saya berharap ia boleh menjadi alat yang kuat untuk analisis dan membuat keputusan anda.

    • Jenis Data

      Jenis data adalah konsep asas. Apabila kita menetapkan data yang jelas kepada pembolehubah secara bertulis, pembolehubah juga menjadi jenis data itu sendiri.

        1. Jenis Nilai:
        1.2.3.1.1234.2.23456 ...
        
        1. Jenis rentetan:
        '1' .'2' .'3' ,String types must be wrapped with ''
        
        1. Data urutan:
        A collection of data consisting of a series of single-valued data
        
        1. Jenis Boolean (Boolean):

        Penggunaan1mewakilitruedan0untukfalse.

        Contoh

        // declare a variable of value type
        var_int := 1;
        // Declare a variable for sequence data
        var_arr := Close;
        // The string type cannot be declared alone, it needs to be combined with the function
        INFO(C>O, 'positive line');
        
    • Pengendali

      Operasi dan pengiraan yang digunakan untuk melaksanakan kod penunjuk hanyalah simbol yang terlibat dalam operasi.

      • Pengendali Tugas

        untuk menetapkan nilai kepada pembolehubah

          1. :

          :, mewakili penugasan dan output kepada grafik (subgraph).

          Close1:Close;      // Assign Close to the variable Close1 and output to the figure
          
          1. :=

          :=, mewakili penugasan, tetapi tidak output ke grafik (graf utama, subgraph...), juga tidak dipaparkan dalam jadual bar status.

          Close2:=Close;     // Assign Close to the variable Close2
          
          1. ^^

          ^^Dua.^simbol mewakili penugasan, menetapkan nilai kepada pembolehubah dan output kepada grafik (grafik utama).

          lastPrice^^C;
          
          1. ..

          .., dua.simbol mewakili penugasan, menetapkan nilai kepada pembolehubah dan memaparkan nama dan nilai pembolehubah dalam carta, tetapi tidak menggambar gambar ke carta (gambar utama, subgambar...).

          openPrice..O
          
      • Operator hubungan

        Operator relasional adalah operator binari yang digunakan dalam ungkapan bersyarat untuk menentukan hubungan antara dua data.

        Nilai pulangan: Jenis Boolean, sama adatrue(1) ataufalse(0).

          1. lebih daripada>
          // Assign the operation result of 2>1 to the rv1 variable, at this time rv1=1
          rv1:=2>1;
          
          1. kurang daripada<
          // Returns false, which is 0, because 2 is greater than 1
          rv3:=2<1;
          
          1. lebih daripada atau sama dengan>=
          x:=Close;
          // Assign the result of the operation that the closing price is more than or equal to 10 to the variable rv2
          // Remark that since close is a sequence of data, when close>=10 is performed, the operation is performed in each period, so each period will have a return value of 1 and 0
          rv2:=Close>=10;
          
          1. kurang daripada atau sama dengan<=
          omitted here
          
          1. sama dengan=
          A:=O=C;     // Determine whether the opening price is equal to the closing price.
          
          1. Tidak sama dengan<>
          1<>2       // To determine whether 1 is not equal to 2, the return value is 1 (true)
          
      • Operator Logik

        Nilai pulangan: Jenis Boolean, sama adatrue(1) ataufalse(0).

        1. Logik dan&&, boleh digantikan denganand, dan sisi kiri dan kanan sambungan dan mesti ditubuhkan pada masa yang sama.
        // Determine whether cond_a, cond_b, cond_c are established at the same time
        cond_a:=2>1;
        cond_b:=4>3;
        cond_c:=6>5;
        cond_a && cond_b and cond_c;    // The return value is 1, established
        
        1. Logik atau||, anda boleh menggunakanoruntuk menggantikan sisi kiri dan kanan atau pautan, satu sisi adalah benar (benar), keseluruhan adalah benar (nilai pulangan benar).
        cond_a:=1>2;
        cond_b:=4>3;
        cond_c:=5>6;
        cond_a || cond_b or cond_c;    // The return value is 1, established
        
        1. ()Operator, ungkapan dalam kurungan akan dinilai terlebih dahulu.
        1>2 AND (2>3 OR 3<5)    // The result of the operation is false
        1>2 AND 2>3 OR 3<5      // The result of the operation is true
        
      • Operator aritmatika

        Return value: numeric type
        

        Operator aritmatika adalah operator aritmatika. Ia adalah simbol untuk melengkapkan operasi aritmatika asas (operator aritmatika), yang merupakan simbol yang digunakan untuk memproses empat operasi aritmatika.

        • tambah +

          A:=1+1;      // return 2
          
        • minus -

          A:=2-1;      // return 1
          
        • *kalikan *

          A:=2*2;      // return 4
          
        • membahagikan

          A:=4/2;      // return 2
          
    • Fungsi

      • Fungsi

        Dalam dunia pengaturcaraan, fungsi adalah sekeping kod yang melaksanakan fungsi tertentu.

        function(param1,param2,...)
        
        • Komposisi:

          Nama fungsi (parameter1, parameter2,...), mungkin tidak mempunyai parameter atau mempunyai beberapa parameter.MA(x,n);bermaksud untuk kembali ke purata bergerak mudahxdalamnAntara mereka,MA()adalah fungsi,xdannadalah parameter fungsi.

          Apabila menggunakan fungsi, kita perlu memahami definisi asas fungsi, iaitu, data apa yang boleh diperoleh dengan memanggil fungsi. Secara umum, fungsi mempunyai parameter. Apabila kita menyampaikan parameter, kita perlu memastikan bahawa jenis data yang masuk adalah konsisten. Pada peringkat ini, fungsi petunjuk kod kebanyakan IDE sangat tidak sempurna. Terdapat jenis data parameter yang diberikan, yang membawa beberapa masalah kepada penggunaan kita, danMA(x,n);diterjemahkan sebagai:

          Return to simple moving average
          Usage:
          AVG:=MA(X,N): N-day simple moving average of X, algorithm (X1+X2+X3+...+Xn)/N, N supports variables
          

          Ini sangat tidak mesra kepada pemula, tetapi seterusnya, kita akan membedah fungsi secara menyeluruh, cuba mencari cara cepat untuk belajar dan menggunakan fungsi.

      • Nilai pulangan

        Untuk belajar fungsi dengan cepat, kita perlu memahami konsep pertama, ia dipanggil return value, Kembali, seperti namanya, bermaksud kembali kembali; Nilai mewakili nilai tertentu, maka makna nilai pulangan adalah: data yang boleh diperoleh.

        // Because it will be used in the following code, the variable return_value is used to receive and save the return value of function()
        // retrun_value := function(param1,param2);
        // For example:
        AVG:=MA(C,10);     // AVG is retrun_value, function is MA function, param1 parameter: C is the closing price sequence data, param2 parameter: 10.
        
      • Parameter

        Kedua, konsep penting kedua fungsi adalah parameter, dan nilai pulangan yang berbeza boleh diperolehi dengan lulus dalam parameter yang berbeza.

        // The variable ma5 receives the 5-day moving average of closing prices
        ma5:=MA(C,5);
        // The variable ma10 receives the 10-day moving average of closing prices
        ma10:=MA(C,10);
        

        Parameter pertamaXdaripada pembolehubah di atasma5, ma10adalahC(harga penutupan), sebenarnya,Cadalah juga fungsi (mengembalikan urutan harga penutupan dari pembukaan kepada sekarang), tetapi ia tidak mempunyai parameter.MA()fungsi yang kita mahu mendapatkan purata bergerak harga penutupan untuk beberapa hari. fungsi menjadi lebih fleksibel untuk digunakan melalui parameter.

      • Bagaimana untuk belajar

          1. Pertama, kita perlu memahami apa fungsi lakukan, iaitu, apa data fungsi ini boleh kembali kepada kita.
          1. Perkara terakhir ialah memahami jenis nilai pulangan. selepas semua, kita menggunakan fungsi untuk mendapatkan nilai pulangan.
          1. Di samping itu, kita perlu tahu jenis data parameterMA(x,n), jika anda tidak tahu jenis data parameterx, n, ia tidak akan dapat mendapatkan nilai pulangan dengan betul.

        Dalam pengenalan dan penggunaan fungsi berikut, ikuti tiga prinsip di atas.

    • Peningkatan bahasa

      • MyLanguagedanJavaScriptpengaturcaraan campuran bahasa

        %%
        // This can call any API quantified of FMZ
        scope.TEST = function(obj) {
            return obj.val * 100;
        }
        %%
        Closing price: C;
        Closing price magnified 100 times: TEST(C);
        The last closing price is magnified by 100 times: TEST(REF(C, 1)); // When the mouse moves to the K-line of the backtest, the variable value will be prompted
        
        • scopeobjek

          Peraturanscopeobjek boleh menambah atribut dan menetapkan fungsi tanpa nama kepada atribut, dan fungsi tanpa nama yang dirujuk oleh atribut ini boleh dipanggil dalam bahagian kod MyLanguage.

        • scope.getRefs(obj)fungsi

          DalamJavaScriptBlok kod, hubungiscope.getRefs(obj)fungsi untuk mengembalikan data yang dilewatkan dalamobj object.

          PeraturanJavaScriptkod yang dibungkus dengan:%% %%akan mendapatCtelah diluluskan apabilaTEST(C)Fungsi dalam kod MyLanguage dipanggil Close price. Peraturanscope.getRefsfungsi akan mengembalikan semua harga penutupan data K-garis ini.throw "stop"untuk mengganggu program, pembolehubaharrmengandungi harga penutupan bar pertama sahaja.throw "stop", ia akan melaksanakanreturnpada akhirJavaScriptkod, dan mengembalikan semua data harga penutupan.

          %%
          scope.TEST = function(obj){
              var arr = scope.getRefs(obj)
              Log("arr:", arr)
              throw "stop"
              return
          }
          %%
          TEST(C);
          
        • scope.bars

          Akses semua bar K-garis dalamJavaScriptblok kod.

          PeraturanTESTFungsi mengembalikan nilai. 1 adalah garis negatif dan 0 adalah garis positif.

          %%
          scope.TEST = function(){
              var bars = scope.bars
              return bars[bars.length - 1].Open > bars[bars.length - 1].Close ? 1 : 0    // Only numeric values can be returned
          }
          %%
          arr:TEST;                                                                      
          
          # Attention:
          # An anonymous function received by TEST, the return value must be a numeric value.
          # If the anonymous function has no parameters, it will result in an error when calling TEST, writing VAR:=TEST; and writing VAR:=TEST(); directly.
          # TEST in scope.TEST must be uppercase.
          
        • scope.bar

          DalamJavaScriptBlok kod, akses bar semasa.

          Mengira purata harga pembukaan tinggi dan harga penutupan rendah.

          %%
          scope.TEST = function(){
              var bar = scope.bar
              var ret = (bar.Open + bar.Close + bar.High + bar.Low) / 4
              return ret
          }
          %%
          avg^^TEST;
          
        • scope.depth

          Akses kepada data kedalaman pasaran (buku pesanan).

          %%
          scope.TEST = function(){
              Log(scope.depth)
              throw "stop"             // After printing the depth data once, throw an exception and pause
          }
          %%
          TEST;
          
        • scope.symbol

          Dapatkan string nama pasangan dagangan semasa.

          %%
          scope.TEST = function(){
              Log(scope.symbol)
              throw "stop"
          }
          %%
          TEST;
          
        • scope.barPos

          Dapatkan kedudukan Bar dari K-garis.

          %%
          scope.TEST = function(){
              Log(scope.barPos)
              throw "stop"
          }
          %%
          TEST;
          
        • scope.get_locals (nama)

          Fungsi ini digunakan untuk mendapatkan pembolehubah dalam bahagian kod MyLanguage.

          V:10;
          %%
          scope.TEST = function(obj){
              return scope.get_locals('V')
          }
          %%
          GET_V:TEST(C);
          
          # Attention:
          # If a variable cannot calculate the data due to insufficient periods, call the scope.get_locals function in the JavaScript code at this time
          # When getting this variable, an error will be reported: line:XX - undefined locals A variable name is undefined
          
        • scope.canTrade

          PeraturancanTradetanda atribut sama ada bar semasa boleh didagangkan (sama ada Bar semasa adalah yang terakhir)

          Sebagai contoh, menilai bahawa data pasaran dicetak apabila strategi berada dalam keadaan di mana pesanan boleh didagangkan

          %%
          scope.LOGTICKER = function() {
              if(exchange.IO("status") && scope.canTrade){
                  var ticker = exchange.GetTicker();
                  if(ticker){
                      Log("ticker:", ticker);
                      return ticker.Last;
                  }
              }
          }
          %%
          LASTPRICE..LOGTICKER;
          
      • Contoh aplikasi:

        %%
        scope.TEST = function(a){
            if (a.val) {
                throw "stop"
            }    
        }
        %%
        O>C,BK;
        C>O,SP;
        TEST(ISLASTSP);
        

        Hentikan strategi selepas membuka dan menutup kedudukan sekali.

    • Rujukan berbilang tempoh

      Sistem akan memilih tempoh garis K asas yang sesuai secara automatik, dan menggunakan data tempoh garis K asas ini untuk mensintesis semua data garis K rujukan untuk memastikan ketepatan data.

      • Penggunaan:#EXPORT formula_name ... #ENDJika formula tidak dihitung hanya untuk mendapatkan data dari tempoh yang berbeza, anda juga boleh menulis formula kosong.

        Rumus kosong ialah:

        #EXPORT TEST 
        NOP;
        #END           // end
        
      • Penggunaan:#IMPORT [MIN,period,formula name] AS variable valueDapatkan pelbagai data tempoh yang ditetapkan (harga penutupan, harga pembukaan, dan lain-lain, yang diperoleh oleh nilai pembolehubah).

        PeraturanMINdalamIMPORTPerintah bermaksudtahap minit.MyLanguage dari platform FMZ Quant, dan hanyaMINtahap yang disokong dalamIMPORTPerintah. Tempoh bukan standard kini disokong. Sebagai contoh, anda boleh menggunakan#IMPORT [MIN, 240, TEST] AS VAR240untuk mengimport data seperti tempoh 240 minit (4 jam) K-line.

        Contoh kod:

        // This code demonstrates how to reference formulas of different periods in the same code
        // #EXPORT extended grammar, ending with #END marked as a formula, you can declare multiple
        #EXPORT TEST 
        Mean value 1: EMA(C, 20);
        Mean value 2: EMA(C, 10);
        #END // end
        
        #IMPORT [MIN,15,TEST] AS VAR15 // Quoting the formula, the K-line period takes 15 minutes
        #IMPORT [MIN,30,TEST] AS VAR30 // Quoting the formula, the K-line period takes 30 minutes
        CROSSUP(VAR15.Mean value is 1, VAR30.Mean value is 1),BPK;
        CROSSDOWN(VAR15.Mean value is 2, VAR30.Mean value is 2),SPK;
        The highest price in fifteen minutes:VAR15.HIGH;
        The highest price in thirty minutes:VAR30.HIGH;
        AUTOFILTER;
        
      • Perlu berhati-hati apabila menggunakanREF, LLV, HHVdan arahan lain untuk merujuk data apabila merujuk data dalam beberapa tempoh.

        (*backtest
        start: 2021-08-05 00:00:00
        end: 2021-08-05 00:15:00
        period: 1m
        basePeriod: 1m
        exchanges: [{"eid":"Futures_OKCoin","currency":"ETH_USD"}]
        args: [["TradeAmount",100,126961],["ContractType","swap",126961]]
        *)      
        
        %%
        scope.PRINTTIME = function() {
            var bars = scope.bars;
            return _D(bars[bars.length - 1].Time);
        }
        %%
        BARTIME:PRINTTIME;      
        
        #EXPORT TEST 
        REF1C:REF(C,1);
        REF1L:REF(L,1);
        #END // end      
        
        #IMPORT [MIN,5,TEST] AS MIN5
        INFO(1, 'C:', C, 'MIN5.REF1C:', MIN5.REF1C, 'REF(MIN5.C, 1):', REF(MIN5.C, 1), 'Trigger BAR time:', BARTIME, '#FF0000');
        INFO(1, 'L:', L, 'MIN5.REF1L:', MIN5.REF1L, 'REF(MIN5.L, 1):', REF(MIN5.L, 1), 'Trigger BAR time:', BARTIME, '#32CD32');
        AUTOFILTER;
        

        Membandingkan perbezaan antaraMIN5.REF1CdanREF(MIN5.C, 1),kita boleh mencari:MIN5.REF1Cadalah nilai harga penutupan BAR sebelum terakhir pada saat semasa data garis K 5 minit.REF(MIN5.C, 1)adalah tempoh K-garis model semasa (periode backtest kod di atas ditetapkan kepada 1 minit, iaitu ```period: 1m``), harga penutupan tempoh 5 minit di mana BAR sebelum terakhir terletak pada masa ini. Kedua-dua definisi ini dibezakan, dan mereka boleh digunakan mengikut keperluan.

    • Penerangan mod

      • Model penapisan isyarat dengan satu pembukaan dan satu penyelarasan

        Dalam model,AUTOFILTERFungsi ini ditulis untuk mengawal dan merealisasikan penapisan isyarat satu pembukaan dan satu penutupan. Apabila terdapat beberapa isyarat pembukaan yang memenuhi syarat, isyarat pertama diambil sebagai isyarat yang sah, dan isyarat yang sama pada garis K akan disaring.

        Arahan yang disokong oleh model penapisan: BK, BP, BPK, SK, SP, SPK, CLOSEOUT, dll. Arahan dengan nombor lot seperti BK ((5) tidak disokong.

        Sebagai contoh

        MA1:MA(CLOSE,5);
        MA2:MA(CLOSE,10);
        CROSSUP(C,MA1),BK;
        CROSSUP(MA1,MA2),BK;
        C>BKPRICE+10||C<BKPRICE-5,SP;
        AUTOFILTER;
        
        Comprehension:
        As in the above example, when AUTOFILTER is not set, the third row BK, the fourth row BK and the fifth row SP are triggered in sequence, and each K-line triggers a signal once. After opening the position, and closing the position, the model state is reset.      
        If AUTOFILTER is set, after triggering BK, only SP is triggered, other BK signals are ignored, and each K-line triggers a signal once.
        
      • Model kedudukan peningkatan dan penurunan

        PeraturanAUTOFILTERfungsi tidak ditulis dalam model, yang membolehkan isyarat pembukaan berterusan atau isyarat penutupan berterusan, yang boleh meningkatkan dan mengurangkan kedudukan.

        Arahan yang disokong: BK(N), BP(N), SK(N), SP(N), CLOSEOUT, BPK(N), SPK(N), pesanan terbuka dan ditutup tanpa saiz lot tidak disokong. (1) Pengelompokan arahan disokong. (2) Apabila beberapa syarat arahan dipenuhi pada masa yang sama, isyarat dijalankan dalam urutan di mana pernyataan syarat ditulis. Contohnya:

        MA1:MA(CLOSE,5);
        MA2:MA(CLOSE,10);
        CROSSUP(C,MA1),BK(1);
        CROSSUP(MA1,MA2),BK(1);
        C>BKPRICE+10||C<BKPRICE-5,SP(BKVOL);
        

        PenggunaanTRADE\_AGAINIa adalah mungkin untuk membuat baris arahan yang sama, beberapa isyarat berturut-turut.

        Comprehension:
        The above example is executed one by one, and the signal after execution is no longer triggered. Reset the model status after closing the position. A K -line triggers a signal once.
        
      • Model dengan satu garis K dan satu isyarat

        Tidak kira sama ada garis K selesai, isyarat dikira dalam pesanan masa nyata, iaitu, garis K diletakkan sebelum pesanan selesai; garis K dikaji semula pada akhir.

        Contohnya:

        MA1:MA(CLOSE,5);
        MA2:MA(CLOSE,10);
        CROSSUP(MA1,MA2),BPK;    //The 5-period moving average crosses up, and the 10-period moving average goes long.
        CROSSDOWN(MA1,MA2),SPK;  //The 5-period moving average crosses down, and the 10-period moving average goes short.
        AUTOFILTER;
        
      • Model pelbagai isyarat pada satu K-garis

        Model ini menggunakanmultsiguntuk mengawal dan melaksanakan beberapa isyarat dari satu K-line.

        Tidak kira sama ada garis K selesai, isyarat dikira dalam masa nyata.

        Isyarat tidak dikaji semula, tidak ada signal hilang, dan arah isyarat sentiasa konsisten dengan arah kedudukan.

        Jika beberapa keadaan isyarat dipenuhi dalam satu K-garis, ia boleh dilaksanakan berulang kali.

        For example:
        MA1:MA(CLOSE,5);
        MA2:MA(CLOSE,10);
        CROSSUP(MA1,MA2),BK;
        C>BKPRICE+10||C<BKPRICE-5,SP;
        AUTOFILTER;
        MULTSIG(0,0,2,0);
        

        MULTSIGboleh menjalankan beberapa baris perintah dalam satu K-line. Satu baris arahan hanya ditandakan sekali.

        O<C,BK;            // These conditions may all be executed in a K-line Bar, but only one signal per line
        10+O<C,BK;         // Strategy plus TRADE_AGAIN(10);it can make multiple signals per line
        20+O<C,BK;
        40+O<C,BK;
        MULTSIG(1,1,10);
        

        Tambahan: 1.Model penjumlahan dan pengurangan kedudukan, dua cara satu isyarat dan satu K-line: meletakkan pesanan pada harga penutupan dan meletakkan pesanan pada harga pesanan, kedua-duanya disokong. 2.Model penjumlahan dan pengurangan kedudukan juga menyokong pesanan beberapa isyarat dari satu K-line. Model penjumlahan dan pengurangan kedudukan, menulismultsigfungsi untuk merealisasikan banyak penambahan atau banyak pengurangan pada satu K-garis.

    • Mod pelaksanaan

      img

      • Model bar

        Model Bar merujuk kepada model yang dilaksanakan selepas BAR semasa selesai, dan dagangan dilaksanakan apabila BAR seterusnya bermula.

      • Model Tick

        Model Tick bermaksud bahawa model dijalankan sekali untuk setiap pergerakan harga dan diperdagangkan dengan segera apabila terdapat isyarat. Model Tick mengabaikan isyarat hari sebelumnya (isyarat hari sebelumnya dilaksanakan dengan segera pada hari yang sama), dan model Tick hanya memberi tumpuan kepada data pasaran semasa untuk menentukan sama ada isyarat itu dicetuskan.

    • Paparan carta

      • Penunjuk tambahan untuk carta utama

        Gunakan pengendali^^, penunjuk set dipaparkan pada carta utama semasa menetapkan nilai kepada pembolehubah.

        MA60^^MA(C, 60);  // Calculate the average indicator with the parameter of 60
        

        img

      • Penunjuk tambahan untuk sub-grafik

        Gunakan pengendali:, penunjuk ditetapkan dipaparkan pada sub-grafik sambil menetapkan nilai kepada pembolehubah.

        ATR:MA(MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)),26);    // Assign a value to the ATR variable, the ":" symbol is followed by the formula for calculating the ATR
        

        img

        Jika anda tidak mahu ia dipaparkan pada carta utama atau sub, gunakan ... operator.

        MA60..MA(C, 60);  // Calculate the average indicator with the parameter of 60
        

        Anda boleh menggunakanDOTdanCOLORREDuntuk menetapkan jenis baris dan warna baris, dll, selaras dengan tabiat pengguna yang biasa dengan MyLanguage.

    • Masalah biasa

      Memperkenalkanmasalahyang biasa ditemui dalam proses penulisan penunjuk, biasanya perkara yang perlu diberi perhatian semasa penulisan (terus ditambah).

      • Perhatikan titik koma;di penghujung.

      • Perhatikan bahawa kata kunci sistem tidak boleh dinyatakan sebagai pembolehubah.

      • Perhatikan bahawa rentetan menggunakanpetikan tunggal, contohnya: rentetan'Open position'.

      • Perhatikan

        Anotasi

        • // The Remark content(Kaedah input boleh diketik dalam kedua-dua bahasa Cina dan Inggeris) bermaksud bahawa kod tidak disusun semasa proses pelaksanaan, iaitu kandungan selepas//Biasanya kita menggunakannya untuk menandakan makna kod, apabila ia mudah untuk kajian kod, ia boleh dengan cepat difahami dan ingat.

        • { Remark content }Blok Remark.

          A:=MA(C,10);
          {The previous line of code is to calculate the moving average.}
          
        • (* Remark content *)Blok Remark.

          A:=MA(C,10);
          (*The previous line of code is to calculate the moving average.*)
          
      • Input

        Apabila menulis kod, kerana kaedah input sering beralih antara Cina dan Inggeris, mengakibatkan kesilapan simbol.:, Terminator;, koma,, kurung(), dll. Huruf-huruf ini dalam keadaan yang berbeza dalam bahasa Cina dan Inggeris memerlukan perhatian.

        Jika anda menggunakan Sogou, Baidu, atau kaedah input Bing, anda boleh dengan cepat beralih antara Cina dan Inggeris dengan menekanshiftKunci sekali.

      • Logik terdedah kepada kesilapan

        1. Sekurang-kurangnya, tidak kurang daripada, tidak kurang daripada: operator hubungan yang sepadan>=.
        2. Setakat, tidak lebih daripada: operator hubungan yang sepadan<=.
      • Penyelarasan pelancaran strategi

        Dalam strategi niaga hadapan, jika terdapat kedudukan dibuka secara manual sebelum robot strategi bermula, apabila robot bermula, ia akan mengesan maklumat kedudukan dan menyelaraskannya dengan status kedudukan sebenar. Dalam strategi, anda boleh menggunakanSP, BP, CLOSEOUTperintah untuk menutup kedudukan.

        %%
        if (!scope.init) {
            var ticker = exchange.GetTicker();
            exchange.Buy(ticker.Sell+10, 1);
            scope.init = true;
        }
        %%
        C>0, CLOSEOUT;
        
      • Kedudukan dua hala tidak disokong

        MyLanguage tidak menyokong kontrak yang sama dengan kedua-dua kedudukan panjang dan pendek.

  • Petikan data K-line

    • Terbuka

      Dapatkan harga pembukaan carta K-line.

      Harga pembukaan

      Fungsi: OPEN, singkatan O

      Parameter: tiada

      Penjelasan: Mengembalikan harga pembukaan periode ini

      Data urutan

      OPEN gets the opening price of the K-line chart.
      
      Remark:
      1.It can be abbreviated as O.
      
      Example 1:
      OO:=O;           //Define OO as the opening price; Remark that the difference between O and 0.
      Example 2:
      NN:=BARSLAST(DATE<>REF(DATE,1));
      OO:=REF(O,NN);   //Take the opening price of the day
      Example 3:
      MA5:=MA(O,5);    //Define the 5-period moving average of the opening price (O is short for OPEN).
      
    • Tinggi

      Dapatkan harga tertinggi pada carta K-line.

      Harga tertinggi

      Fungsi: HIGH, singkatan H

      Parameter: tiada

      Penjelasan: Kembalikan harga tertinggi untuk tempoh ini

      Data urutan

      HIGH achieved the highest price on the K-line chart.
      
      Remark:
      1.It can be abbreviated as H.
      
      Example 1:
      HH:=H;         // Define HH as the highest price
      Example 2:
      HH:=HHV(H,5);  // Take the maximum value of the highest price in 5 periods
      Example 3:
      REF(H,1);      // Take the highest price of the previous K-line
      
    • rendah

      Dapatkan harga terendah pada carta K-line.

      Harga terendah

      Fungsi: LOW, disingkat L

      Parameter: tiada

      Penjelasan: Kembalikan harga terendah untuk tempoh ini

      Data urutan

      LOW gets the lowest price on the K-line chart.
      
      Remark:
      1.It can be abbreviated as L.
      
      Example 1:
      LL:=L;            // Define LL as the lowest price
      Example 2:
      LL:=LLV(L,5);     // Get the minimum value of the lowest price in 5 periods
      Example 3:
      REF(L,1);         // Get the lowest price of the previous K-line
      
    • TAMPAT

      Dapatkan harga penutupan carta K-line.

      Harga penutupan

      Fungsi: CLOSE, disingkat sebagai C

      Parameter: tiada

      Penjelasan: Mengembalikan harga penutupan periode ini

      Data urutan

      CLOSE Get the closing price of the K-line chart
      
      Remarks:
      1.Obtain the latest price when the intraday K-line has not finished.
      2.It can be abbreviated as C.
      
      Example 1:
      A:=CLOSE;          //Define the variable A as the closing price (A is the latest price when the intraday K-line has not finished)
      Example 2:
      MA5:=MA(C,5);      //Define the 5-period moving average of the closing price (C is short for CLOSE)
      Example 3:
      A:=REF(C,1);       //Get the closing price of the previous K-line
      
    • VOL

      Dapatkan jumlah dagangan carta garis K.

      Volume dagangan

      Fungsi: VOL, disingkat sebagai V

      Parameter: tiada

      Penjelasan: Mengembalikan jumlah dagangan periode ini

      Data urutan

      VOL obtains the trading volume of the K-line chart.
      
      Remarks:
       It can be abbreviated as V.
      The return value of this function on the current TICK is the cumulative value of all TICK trading volume on that day.
      
      Example 1:
      VV:=V;       // Define VV as the trading volume
      Example 2:
      REF(V,1);    // Indicates the trading volume of the previous period
      Example 3:
      V>=REF(V,1); // The trading volume is greater than the trading volume of the previous period, indicating that the trading volume has increased (V is the abbreviation of VOL)
      
    • OPI

      Ambil kedudukan keseluruhan semasa di pasaran niaga hadapan (kontrak).

      OpenInterest:OPI;
      
    • REF

      Pengutipan ke hadapan.

      Reference the value of X before N periods.
      
      Remarks:
      1.When N is a valid value, but the current number of K-lines is less than N, returns null;
      2.Return the current X value when N is 0;
      3.Return a null value when N is null.
      4.N can be a variable.
      
      Example 1:
      REF(CLOSE,5);Indicate the closing price of the 5th period before the current period is referenced
      Example 2:
      AA:=IFELSE(BARSBK>=1,REF(C,BARSBK),C);//Take the closing price of the K-line of the latest position opening signal
      // 1)When the BK signal is sent, the bar BARSBK returns null, then the current K-line REF(C, BARSBK) that sends out the BK signal returns null;
      // 2)When the BK signal is sent out, the K-line BARSBK returns null, and if BARSBK>=1 is not satisfied, it is the closing price of the K-line.
      // 3)The K-line BARSBK after the BK signal is sent, returns the number of periods from the current K-line between the K-line for purchasing and opening a position, REF(C,BARSBK)
      Return the closing price of the opening K-line.
      // 4)Example: three K-lines: 1, 2, and 3, 1 K-line is the current K-line of the position opening signal, then returns the closing price of the current K-line, 2, 3
      The K-line returns the closing price of the 1 K-line.
      
    • Unit

      Dapatkan unit perdagangan kontrak data.

      Get the trading unit of the data contract.
      Usage:
      UNIT takes the trading unit of the loaded data contract.
      

      Spot mata wang kripto

      Nilai UNIT ialah 1.

      Masa hadapan mata wang kripto

      Nilai UNIT berkaitan dengan mata wang kontrak.

      OKEX futures currency standard contracts: 1 contract for BTC represents $100, 1 contract for other currencies represents $10
      
    • MINPRICE

      Harga variasi minimum kontrak data.

      Take the minimum variation price of the data contract.
      Usage:
      MINPRICE; Take the minimum variation price of the loaded data contract.
      
    • MINPRICE1

      Harga variasi minimum kontrak perdagangan.

      Take the minimum variation price of a trading contract.
      Usage:
      MINPRICE1; Take the minimum variation price of a trading contract.
      
  • Fungsi masa

    • BARPOS

      Ambil kedudukan garis K.

      BARPOS, Returns the number of periods from the first K-line to the current one.
      
      Remarks:
      1.BARPOS returns the number of locally available K-line, counting from the data that exists on the local machine.
      2.The return value of the first K-line existing in this machine is 1.
      
      Example 1:LLV(L,BARPOS);        // Find the minimum value of locally available data.
      
      Example 2:IFELSE(BARPOS=1,H,0); // The current K-line is the first K-line that already exists in this machine, and it takes the highest value, otherwise it takes 0.
      
    • DAYBARPOS

      DAYBARPOS K-line BAR semasa adalah K-line BAR hari ini.

    • Tempoh

      Nilai tempoh adalah bilangan minit.

      1, 3, 5, 15, 30, 60, 1440
      
    • Tarikh

      TarikhFungsi DATE, Dapatkan tahun, bulan, dan hari tempoh sejak 1900.

      Example 1:
      AA..DATE;                  // The value of AA at the time of testing is 220218, which means February 18, 2022
      
    • Masa

      Masa untuk mengambil K-line.

      TIME, the time of taking the K-line.
      
      Remarks:
      1.The function returns in real time in the intraday, and returns the starting time of the K-line after the K-line is completed.
      2.This function returns the exchange data reception time, which is the exchange time.
      3.The TIME function returns a six-digit form when used on a second period, namely: HHMMSS, and displays a four-digit form on other periods, namely: HHMM.
      4.The TIME function can only be loaded in periods less than the daily period, and the return value of the function is always 1500 in the daily period and periods above the daily period.
      5. It requires attention when use the TIME function to close a position at the end of the day
      (1).It is recommended to set the time for closing positions at the end of the market to the time that can actually be obtained from the return value of the K-line (for example: the return time of the last K-line in the 5-minute period of the thread index is 1455, and the closing time at the end of the market is set to TIME>=1458, CLOSEOUT; the signal of closing the position at the end of the market cannot appear in the effect test)
      (2).If the TIME function is used as the condition for closing the position at the end of the day, it is recommended that the opening conditions should also have a corresponding time limit (for example, if the condition for closing the position at the end of the day is set to TIME>=1458, CLOSEOUT; then the condition TIME needs to be added to the corresponding opening conditions. <1458; avoid re-opening after closing)
      
      Example 1:
      C>O&&TIME<1450,BK;
      C<O&&TIME<1450,SK;
      TIME>=1450,SP;
      TIME>=1450,BP;
      AUTOFILTER;
      // Close the position after 14:50.
      Example 2:
      ISLASTSK=0&&C>O&&TIME>=0915,SK;
      
    • Tahun

      Year.

      YEAR, year of acquisition.
      
      Remark:
      The value range of YEAR is 1970-2033.
      
      Example 1:
      N:=BARSLAST(YEAR<>REF(YEAR,1))+1;
      HH:=REF(HHV(H,N),N);
      LL:=REF(LLV(L,N),N);
      OO:=REF(VALUEWHEN(N=1,O),N);
      CC:=REF(C,N);                               // Take the highest price, lowest price, opening price, and closing price of the previous year
      Example 2:
      NN:=IFELSE(YEAR>=2000 AND MONTH>=1,0,1);
      
    • Bulan

      Ambil bulan ini.

      MONTH, returns the month of a period.
      
      Remark:
      The value range of MONTH is 1-12.
      
      Example 1:
      VALUEWHEN(MONTH=3&&DAY=1,C);                // Take its closing price when the K-line date is March 1
      Example 2:
      C>=VALUEWHEN(MONTH<REF(MONTH,1),O),SP;
      
    • Hari

      Dapatkan bilangan hari dalam tempoh

      DAY, returns the number of days in a period.
      
      Remark:
      The value range of DAY is 1-31.
      
      Example 1:
      DAY=3&&TIME=0915,BK;                      // 3 days from the same day, at 9:15, buy it
      Example 2:
      N:=BARSLAST(DATE<>REF(DATE,1))+1;
      CC:=IFELSE(DAY=1,VALUEWHEN(N=1,O),0);      // When the date is 1, the opening price is taken, otherwise the value is 0
      
    • JAM

      Hour.

      HOUR, returns the number of hours in a period.
      
      Remark:
      The value range of HOUR is 0-23
      
      Example 1:
      HOUR=10;                                   // The return value is 1 on the K-line at 10:00, and the return value on the remaining K-lines is 0
      
    • minit

      Minute.

      MINUTE, returns the number of minutes in a period.
      
      Remarks:
      1: The value range of MINUTE is 0-59
      2: This function can only be loaded in the minute period, and returns the number of minutes when the K-line starts.
      Example 1:
      MINUTE=0;                                 // The return value of the minute K-line at the hour is 1, and the return value of the other K-lines is 0
      Example 2:
      TIME>1400&&MINUTE=50,SP;                   // Sell and close the position at 14:50
      
    • Hari minggu

      Dapatkan nombor minggu ini.

      WEEKDAY, get the number of the week.
      
      Remark:
      1: The value range of WEEKDAY is 0-6. (Sunday ~ Saturday)
      
      Example 1:
      N:=BARSLAST(MONTH<>REF(MONTH,1))+1;
      COUNT(WEEKDAY=5,N)=3&&TIME>=1450,BP;
      COUNT(WEEKDAY=5,N)=3&&TIME>=1450,SP;
      AUTOFILTER;                               // Automatically close positions at the end of the monthly delivery day
      Example 2:
      C>VALUEWHEN(WEEKDAY<REF(WEEKDAY,1),O)+10,BK;
      AUTOFILTER;
      
  • Fungsi penilaian logik

    • BARSTATUS

      Kembalikan status kedudukan untuk tempoh semasa.

      BARSTATUS returns the position status for the current period.
      
      Remark:
      The function returns 1 to indicate that the current period is the first period, returns 2 to indicate that it is the last period, and returns 0 to indicate that the current period is in the middle.
      
      Example:
      A:=IFELSE(BARSTATUS=1,H,0);              // If the current K-line is the first period, variable A returns the highest value of the K-line, otherwise it takes 0
      
    • Antara

      Between.

      BETWEEN(X,Y,Z) indicates whether X is between Y and Z, returns 1 (Yes) if established, otherwise returns 0 (No).
      
      Remark:
      1.The function returns 1(Yse) if X=Y, X=Z, or X=Y and Y=Z.
      
      Example 1:
      BETWEEN(CLOSE,MA5,MA10);                // It indicates that the closing price is between the 5-day moving average and the 10-day moving average
      
    • BARSLASTCOUNT

      BARSLASTCOUNT(COND) mengira bilangan tempoh berturut-turut yang memenuhi syarat, mengira ke hadapan dari tempoh semasa.

      Remark:
      1. The return value is the number of consecutive non zero periods calculated from the current period
      2. the first time the condition is established when the return value of the current K-line BARSLASTCOUNT(COND) is 1
      
      Example:
      BARSLASTCOUNT(CLOSE>OPEN);
      //Calculate the number of consecutive positive periods within the current K-line
      
    • Silang

      Fungsi silang.

      CROSS(A,B) means that A crosses B from bottom to top, and returns 1 (Yes) if established, otherwise returns 0 (No)
      
      Remark:
      1.To meet the conditions for crossing, the previous k-line must satisfy A<=B, and when the current K-line satisfies A>B, it is considered to be crossing.
      
      Example 1:
      CROSS(CLOSE,MA(CLOSE,5));              // Indicates that the closing line crosses the 5-period moving average from below
      
    • Perpindahan

      Crossdown

      CROSSDOWN(A,B): indicates that when A passes through B from top to bottom, it returns 1 (Yes) if it is established, otherwise it returns 0 (No)
      
      Remark:
      1.CROSSDOWN(A,B) is equivalent to CROSS(B,A), and CROSSDOWN(A,B) is easier to understand
      
      Example 1:
      MA5:=MA(C,5);
      MA10:=MA(C,10);
      CROSSDOWN(MA5,MA10),SK;               // MA5 crosses down MA10 to sell and open a position
      // CROSSDOWN(MA5,MA10),SK; Same meaning as CROSSDOWN(MA5,MA10)=1,SK;
      
    • CROSSUP

      Crossup.

      CROSSUP(A,B) means that when A crosses B from the bottom up, it returns 1 (Yes) if it is established, otherwise it returns 0 (No)
      
      Remark:
      1.CROSSUP(A,B) is equivalent to CROSS(A,B), and CROSSUP(A,B) is easier to understand.
      
      Example 1:
      MA5:=MA(C,5);
      MA10:=MA(C,10);
      CROSSUP(MA5,MA10),BK;                 // MA5 crosses MA10, buy open positions
      // CROSSUP(MA5,MA10),BK;与CROSSUP(MA5,MA10)=1,BK; express the same meaning
      
    • Semua

      Tentukan sama ada ia sentiasa dipenuhi.

      EVERY(COND,N), Determine whether the COND condition is always satisfied within N periods. The return value of the function is 1 if it is satisfied, and 0 if it is not satisfied.
      
      Remarks:
      1.N contains the current K-line.
      2.If N is a valid value, but there are not so many K-lines in front, or N is a null value, it means that the condition is not satisfied, and the function returns a value of 0.
      3.N can be a variable.
      
      Example 1:
      EVERY(CLOSE>OPEN,5);                // Indicates that it has been a positive line for 5 periods
      Example 2:
      MA5:=MA(C,5);                       // Define a 5-period moving average
      MA10:=MA(C,10);                     // Define a 10-period moving average
      EVERY(MA5>MA10,4),BK;               // If MA5 is greater than MA10 within 4 periods, then buy the open position
      // EVERY(MA5>MA10,4),BK; has the same meaning as EVERY(MA5>MA10,4)=1,BK;
      
    • wujud

      Tentukan sama ada terdapat kepuasan.

      EXIST(COND, N) judges whether there is a condition that satisfies COND within N periods.
      
      Remarks:
      1.N contains the current K-line.
      2.N can be a variable.
      3.If N is a valid value, but there are not so many K-lines in front, it is calculated according to the actual number of periods.
      
      Example 1:
      EXIST(CLOSE>REF(HIGH,1),10);     // Indicates whether there is a closing price greater than the highest price of the previous period in 10 periods, returns 1 if it exists, and returns 0 if it does not exist
      Example 2:
      N:=BARSLAST(DATE<>REF(DATE,1))+1;
      EXIST(C>MA(C,5),N);              // Indicates whether there is a K-line that satisfies the closing price greater than the 5-period moving average on the day, returns 1 if it exists, returns 0 if it does not exist
      
    • Jika

      Fungsi keadaan.

      IF(COND,A,B)Returns A if the COND condition is true, otherwise returns B.
      
      Remarks:
      1.COND is a judgment condition; A and B can be conditions or values.
      2.This function supports the variable circular reference to the previous period's own variable, that is, supports the following writing Y: IF(CON,X,REF(Y,1)).
      Example 1:
      IF(ISUP,H,L);                   // The K-line is the positive line, the highest price is taken, otherwise the lowest price is taken
      Example 2:
      A:=IF(MA5>MA10,CROSS(DIFF,DEA),IF(CROSS(D,K),2,0));     // When MA5>MA10, check whether it satisfies the DIFF and pass through DEA, otherwise (MA5 is not greater than MA10), when K and D are dead fork, let A be assigned a value of 2, if none of the above conditions are met, A is assigned a value of 0
      A=1,BPK;                                                // When MA5>MA10, the condition for opening a long position is to cross DEA above the DIFF
      A=2,SPK;                                                // When MA5 is not greater than MA10, use K and D dead forks as the conditions for opening short positions
      
    • IFELSE

      Fungsi keadaan.

      IFELSE(COND,A,B) Returns A if the COND condition is true, otherwise returns B.
      
      Remarks:
      1.COND is a judgment condition; A and B can be conditions or values.
      2.This function supports variable circular reference to the previous period's own variable, that is, supports the following writing Y: IFELSE(CON,X,REF(Y,1));
      Example 1:
      IFELSE(ISUP,H,L);                                             // The K-line is the positive line, the highest price is taken, otherwise the lowest price is taken
      Example 2:
      A:=IFELSE(MA5>MA10,CROSS(DIFF,DEA),IFELSE(CROSS(D,K),2,0));   // When MA5>MA10, check whether it satisfies the DIFF and pass through DEA, otherwise (MA5 is not greater than MA10), when K and D are dead fork, let A be assigned a value of 2, if none of the above conditions are met, A is assigned a value of 0
      A=1,BPK;                                                      // When MA5>MA10, the condition for opening a long position is to cross DEA above the DIFF
      A=2,SPK;                                                      // When MA5 is not greater than MA10, use K and D dead forks as the conditio

Berkaitan

Lebih lanjut