MyLanguage ドック

作者: リン・ハーン小さな夢, 作成日:2022-06-30 18:24:06, 更新日:2024-02-06 17:36:19

[TOC]

img

MyLanguageは,MyLanguageと互換性があり,強化されたプログラミング取引言語です. FMZ QuantのMyLanguageは,厳格な文法チェックを受けます.例えば,JavaScript言語コードを埋め込むために言語強化を使用する場合,文字の後に追加のスペース文字が表示されます.%%操作者がエラーを報告させる

  • 基本指示

    • 契約

      暗号通貨契約

      暗号通貨契約

      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

    • 変数

      変数とは,データを保存するためにコンピュータのメモリに開かれたスペースである.簡単に言えば,データを保存するために使用される.

      最初の変数を開きます.

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

      中へMyLanguage簡単に区別できます.data volume:

      1. 単値データ: 値が1つだけあります.0, 1, 'abc'.
      2. 配列データ: 一つの値を持つデータからなるデータ配列,例えば:Close(決済価格)Close閉じる価格を含んでいるn periods. [ 10.1 , 10.2 , 10.3 , 10.4 , 10.5 ...]

      変数型と区別する

      1. 文字列タイプは ```で包まれなければならない.文字列タイプは直接使用することが許されないし,関数でビューに出力する必要があります.
      INFO(CLSOE>OPEN,'OK!');
      
      1. 値タイプ:整数,浮動小数点数 (小数点数) を含む.
      // integer
      int:=2;
      
      // decimal
      float:=3.1;
      
      1. ブル式タイプ, true (真) と 0 (偽) を使います. 1, 0, true (真) と false (偽) です.例えば:A:=1>0;このコードが実行された後,A1 になります.
      // 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. グローバル変数
      VARIABLE:VALUE1:10;     // Declare a global variable, assign the value 10, and execute it only once.
      

      バックテストの際に注意してください

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

      初期には,INFO証明書印刷101違うかもしれない0初めは? 100のK線が既に実行されており 100回累積されています テストの初期K線が100回あります 実際の値段は,最初にどれだけのK線が手に入るかによって決まります

      • 命名規則

        ほとんどのシステムでは,変数命名は,システム予約された単語 (内蔵変数名,関数名) の使用を許可しません.Close, Cさらに,純粋数や先行数も許されない.最後に,非常に長いことは許されない.また,異なるシステムには異なる長さの制限がある. 実際には,中国語の解析の効率について心配する必要はありません. 私は"MyLanguage"が中国語に非常に友好的であると考えています. 経験豊富なプログラマには,以下の2つの命名規則を使用することをお勧めします:

        1. 中国名
        // elegant output
        5-day moving average:=MA(C,5);
        
        1. 英語+下記
        // Output
        move_avg_5:=MA(C,5);
        

        英語を好む場合は,変数の意味をできるだけ理解できるようにしてください.A1, AAA, BBB数日後には 暗示コードを 再確認すると 記憶喪失が原因で ひどく苦しんでしまうでしょう 同じように コードを 他人に輸出すると 読者は ひどく傷つくでしょう

        MyLanguageを最大限に活用してください! 分析と意思決定の強力なツールになることを願っています.

    • データの種類

      データ型は基本的な概念です. 変数に明確なデータを書き込みで割り当てると,変数もデータの型になります.

        1. 値の種類:
        1.2.3.1.1234.2.23456 ...
        
        1. 文字列の種類:
        '1' .'2' .'3' ,String types must be wrapped with ''
        
        1. 配列データ:
        A collection of data consisting of a series of single-valued data
        
        1. ブル式 (ブール式):

        使用1代表するtrueそして0についてfalse.

        // 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');
        
    • オペレーター

      インディケーターコードを実行するために使用される操作と計算は,単に操作に関わるシンボルです.

      • 割り当てオペレーター

        変数に値を代入する

          1. :

          :グラフ (サブグラフ) に割り当てと出力を表します.

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

          :=, は割り当てを表しますが,グラフ (メイングラフ,サブグラフ...) に出力されず,状態バー表にも表示されません.

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

          ^^2つ目^記号は割り当てを表し,変数に値を割り当て,グラフに出力します (メイングラフ)

          lastPrice^^C;
          
          1. ..

          ..2つ.シンボルは割り当てを表し,変数に値を割り当て,変数名と値をチャートに表示しますが,チャートに絵を描かない (メイン画像,サブ画像...).

          openPrice..O
          
      • 関連演算子

        関連演算子は,二次演算子で,条件式で2つのデータとの関係を決定するために使用されます.

        返される値: ブール式true(1) またはfalse(0).

          1. 以上の>
          // Assign the operation result of 2>1 to the rv1 variable, at this time rv1=1
          rv1:=2>1;
          
          1. より少ない<
          // Returns false, which is 0, because 2 is greater than 1
          rv3:=2<1;
          
          1. 以上のまたは等しい>=
          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. 未満または等しい<=
          omitted here
          
          1. と等しい=
          A:=O=C;     // Determine whether the opening price is equal to the closing price.
          
          1. ではない<>
          1<>2       // To determine whether 1 is not equal to 2, the return value is 1 (true)
          
      • 論理演算子

        返される値: ブール式true(1) またはfalse(0).

        1. 論理的であり&&, に置き換えられる.and接続の左側と右側が同時に確立されなければなりません.
        // 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. 論理的か||,あなたは使用することができますoror リンクの左側と右側を入れ替えるには,片方の値が true (true) で,全体の値が true (true) になります.
        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. ()括弧の式が最初に評価されます.
        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
        
      • 算術演算子

        Return value: numeric type
        

        算術演算子とは算術演算子である.基本算術演算子 (算術演算子) を完了するためのシンボルである.これは4つの算術演算を処理するために使用されるシンボルである.

        • プラス +

          A:=1+1;      // return 2
          
        • マイナス -

          A:=2-1;      // return 1
          
        • *掛け算する *

          A:=2*2;      // return 4
          
        • 分ける

          A:=4/2;      // return 2
          
    • 機能

      • 機能

        プログラミングの世界では,関数は,特定の関数を実装するコードの部分である.また,他のコードで呼び出されることもあり,一般的な形式は以下のとおりである.

        function(param1,param2,...)
        
        • 構成:

          機能名 (parameter1,parameter2,...),パラメータがないか複数のパラメータを持つ可能性があります.例えば,MA(x,n);単純移動平均に戻るx内部nその中でもMA()函数であるxそしてnこの関数のパラメータです.

          函数を使うとき,関数の基本的な定義,すなわち関数を呼び出すことで得られるデータを理解する必要があります. 一般的に言えば,関数はパラメータを持っています. パラメータを入力するときに,入ってくるデータタイプが一貫していることを確認する必要があります. この段階では,ほとんどのIDEのコードヒント機能は非常に不完全です. 与えられたパラメータのデータタイプがあり,私たちの使用にいくつかの問題を起こします.MA(x,n);次のように解釈される.

          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
          

          この関数を徹底的に解剖し 学習や使用の簡単な方法を 見つけようとします

      • 返金値

        概念を理解する必要があります. これは"返り値"と呼ばれます.戻るは,その名前からわかるように,返却を意味し,その値は特定値を表す.

        // 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.
        
      • パラメータ

        2つ目は,関数の第2の重要な概念はパラメータであり,異なるパラメータを通過することによって異なる返却値を得ることができる.

        // 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);
        

        第1パラメータX上記の変数からma5, ma10C(決済価格) 実際にはCまた関数である (開封から現在までの閉じる価格の順序を返します),しかしパラメータがありません.第2パラメータの5と10は,閉じる価格を表示するために使用されます.MA()数日間の閉店価格の移動平均値を得たい関数です. この関数はパラメータを通して使用するのにより柔軟になります.

      • 学ぶ方法

          1. まず,関数が何をするか,つまり,この関数が私たちに返してくれるデータについて理解する必要があります.
          1. 返した値の種類を理解することです. 返した値を得るには関数を使います.
          1. パラメータのデータタイプを知らなければなりません.MA(x,n)パラメータのデータタイプがわからない場合x, n返した値が正常に返ってくるわけではありません.

        次の機能の導入と使用において,上記の3つの原則に従います.

    • 言語の強化

      • MyLanguageそしてJavaScript言語混合プログラミング

        %%
        // 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
        
        • scopeオブジェクト

          についてscopeこの属性によって参照される匿名関数は MyLanguage のコード部分で呼び出されます.

        • scope.getRefs(obj)機能

          中へJavaScriptコードブロック,呼び出すscope.getRefs(obj)送信されたデータに戻す機能obj object.

          についてJavaScript次のコードが付いています%% %%受け取るC通過したときにTEST(C)MyLanguageコードの関数は Close price と呼ばれます についてscope.getRefsこのK線データのすべての閉値が返されます.throw "stop"変数でプログラムを中断するarr最初のバーの閉じる価格のみを含んでいます. あなたは削除しようとすることができますthrow "stop"実行するreturn試験終了後JavaScript終了価格のデータをすべて返します.

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

          K線バーをすべてアクセスJavaScriptコードブロック

          についてTEST1 は負の直線で 0 は正の直線です

          %%
          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

          についてJavaScriptコードブロック,現在のバーにアクセス.

          高い開店価格と低い閉店価格の平均を計算する.

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

          市場深度データへのアクセス (注文簿)

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

          名前文字列を取得します.

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

          K線の位置を把握する

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

          この関数は 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

          についてcanTrade属性マークは,現在のバーが取引可能かどうか (現在のバーが最後のものかどうか)

          例えば,市場データは,戦略が取引可能な状態にあるときに印刷されると判断する

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

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

        ポジションを1回開封すると戦略を停止する.

    • 多期参照

      システムでは,適切な基幹K線周期を自動的に選択し,この基幹K線周期データを利用して,参照されたすべてのK線データを合成し,データの正確性を確保します.

      • 使用方法:#EXPORT formula_name ... #END公式が計算されるのは,異なる期間のデータを得るためではない場合,空の公式も書ける.

        空の式は

        #EXPORT TEST 
        NOP;
        #END           // end
        
      • 使用方法:#IMPORT [MIN,period,formula name] AS variable value設定された期間の様々なデータ (変数値で得られる閉値,開値,など) を取得します.

        についてMINについてIMPORTコマンドの意味分間レベル.MyLanguage FMZ Quant プラットフォーム,そして,MINレベルがサポートされています.IMPORT標準でない期間がサポートされています.例えば,#IMPORT [MIN, 240, TEST] AS VAR240240分 (4時間) のKラインなどのデータをインポートする.

        コード例:

        // 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;
        
      • 服用する際に注意する必要があります.REF, LLV, HHV複数の期間のデータを参照する際のデータ参照の他の指示.

        (*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;
        

        この2つの違いを比較するとMIN5.REF1CそしてREF(MIN5.C, 1)発見できるのはMIN5.REF1C5分間のK線データの現在の瞬間における前期 BARの閉じる価格の値です.REF(MIN5.C, 1)現在のモデルのK線周期 (上記のコードバックテスト期間は1分,すなわち ```period: 1m``に設定されています) で,現在の瞬間に penultimate BARが位置する5分間の閉値です. この2つの定義は区別され,必要に応じて使用できます.

    • モード説明

      • 1つの開口と1つの水平化のシグナルフィルタリングモデル

        モデルでは,AUTOFILTERこの関数は,1つの開口と1つの閉じる信号のフィルタリングを制御し実現するために書かれています.条件を満たす複数の開口信号がある場合,最初の信号は有効な信号として取り,K線上の同じ信号がフィルタリングされます.

        BK,BP,BPK,SK,SP,SPK,CLOSEOUTなど,フィルタリングモデルによってサポートされる説明書.BK ((5) などのロット番号を持つ説明書にはサポートされません.

        例えば

        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.
        
      • 位置の上昇と減少モデル

        についてAUTOFILTERモデルに記入されていないので,継続的な開示信号や継続的な閉じる信号が表示され,ポジションが増加したり減少したりします.

        サポートされている命令: BK(N), BP(N), SK(N), SP(N), CLOSEOUT, BPK(N), SPK(N,ロットサイズのないオープン・クローズ・オーダーはサポートされていません. (1) インストラクションのグループ化はサポートされています. (2) 複数の命令条件が同時に満たされている場合,シグナルは条件文が記述されている順序で実行されます. 例えば:

        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);
        

        使用TRADE\_AGAIN同じコマンドラインで 連続して複数の信号を出すことも可能です

        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.
        
      • 1つのK線と1つの信号を持つモデル

        K線が完了したかどうかにかかわらず,信号はリアルタイム順序で計算される.つまり,K線は順序が完了する前に配置され,K線が終了時に再確認される.位置方向がK線の終わりの信号方向と一致しない場合,位置は自動的に同期される.

        例えば:

        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;
        
      • 1つのK線上の複数の信号のモデル

        モデルではmultsig1つのK線から複数の信号を制御し実装する.

        K線が完成したかどうかにかかわらず 信号はリアルタイムで計算されます

        信号は再確認されず 信号の消去はなく 信号の方向は常に位置の方向と一致します

        1つのK線で複数の信号条件が満たされている場合,繰り返し実行できます.

        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);
        

        MULTSIG複数のコマンドラインを 1 つのKライン内で実行できます コマンドラインは1回しか信号されない.

        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);
        

        サプリメント: 1.ポジションの追加と減少のモデル,シグナルとKラインの2つの方法,閉じる価格でオーダーとオーダー価格でオーダーを表示する両方がサポートされています. 2.位置を足し減すモデルは,K線から複数の信号の順序付けもサポートします. ポジションの足し算と減算のモデル,multsig1つのK線で複数の追加または複数の削減を実現する機能です

    • 実行モード

      img

      • バールモデル

        Barモデルとは,現在の BAR が完了して実行されるモデルであり,次の BAR が開始されたときに取引が実行されるモデルを指します.

      • ティックのモデル

        Tickモデルとは,モデルが各価格動きに対して1回実行され,信号が出るとすぐに取引することを意味します. Tickモデルは前日の信号を無視し (前日の信号は同じ日に直ちに実行される),Tickモデルは現在の市場データにのみ焦点を当て,信号がトリガーされるかどうかを決定する.

    • グラフ表示

      • 基本チャートに関する追加指標

        オペレーターを使用^^変数に値を代入する際に,セットインジケーターがメインチャートに表示されます.

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

        img

      • 副図の追加指標

        オペレーターを使用:変数に値を代入する際に,セットの指標がサブチャートに表示されます.

        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

        メインチャートやサブチャートに表示されない場合は,操作符... を使います.

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

        必要なのはDOTそしてCOLORREDMyLanguage を熟知しているユーザーの習慣に合わせて,行の種類と色を設定します.

    • 一般的な問題

      紹介する問題を抱える通常は,書き出すときに注意を払う必要があるポイント (継続的に追加されます).

      • セミコンに注意してください.;終わりに

      • システムキーワードは変数として宣言できないことに注意してください.

      • 文字列は単一の引数文字列は'Open position'.

      • コメント

        アノテーション

        • // The Remark content(入力方法は中国語と英語の両方で入力することができます) 実行プロセス中にコードがコンパイルされていないことを意味します.//通常はコードの意味をマークするために使います. コードのレビューに便利であれば,すぐに理解され,思い出されます.

        • { Remark content }ブロックコメント

          A:=MA(C,10);
          {The previous line of code is to calculate the moving average.}
          
        • (* Remark content *)ブロックコメント

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

        コードを書くとき,入力メソッドが中国語と英語の間に切り替わることが多いため,シンボルのエラーが発生します.一般的なエラーは以下の通りです::ターミネーター;コマ,括弧()中国語と英語の異なる状態の文字は 注意が必要です

        中国語と英語の間ですぐに切り替えることができます.shift鍵は一度

      • 誤りやすい論理

        1. 少なくとも,少なくとも,少なくとも:対応する関係演算子>=.
        2. 最大:対応する関係演算子<=.
      • 戦略発射同期

        フューチャー戦略では,戦略ロボットの起動前に手動でオープンしたポジションがある場合,ロボットが起動すると,ポジション情報を検出し,実際のポジション状態に同期します. 戦略では,SP, BP, CLOSEOUTポジションを閉じる命令です

        %%
        if (!scope.init) {
            var ticker = exchange.GetTicker();
            exchange.Buy(ticker.Sell+10, 1);
            scope.init = true;
        }
        %%
        C>0, CLOSEOUT;
        
      • 双方向のポジションはサポートされていません.

        MyLanguageは,同じ契約を,ロングとショートの両方でサポートしません.

  • K線データ引用

    • オープン

      K線チャートのオープニング価格を取得します.

      オープニング価格

      機能:OPEN,Oの略

      パラメータ: 無

      説明: 開始価格を返します.

      配列データ

      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).
      
    • 高い

      K線チャートで最高値を取ろう

      最高価格

      機能:HIGH,略してH

      パラメータ: 無

      説明: この期間の最高価格を返します.

      配列データ

      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
      
    • 低い

      K線チャートで 最安値を取れ

      最安値

      機能: LOW,略してL

      パラメータ: 無

      説明: この期間の最低価格を返します.

      配列データ

      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
      
    • 接近する

      K線グラフの閉値を取得します.

      閉店価格

      機能: CLOSE,略してC

      パラメータ: 無

      説明: この期間の閉じる価格を返します.

      配列データ

      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

      K線グラフの取引量を取得する.

      取引量

      機能:VOL,略してV

      パラメータ: 無

      解説: この期間の取引量を返します

      配列データ

      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

      フューチャー (コントラクト) 市場の現在の総ポジションを取ります.

      OpenInterest:OPI;
      
    • REF

      前向きの引用

      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.
      
    • ユニット

      データ契約の取引ユニットを取れ

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

      仮想通貨スポット

      UNIT 値は 1 です.

      仮想通貨先物

      UNIT の値は,契約通貨に関連しています.

      OKEX futures currency standard contracts: 1 contract for BTC represents $100, 1 contract for other currencies represents $10
      
    • 価格について

      データ契約の最低変動価格

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

      取引契約の最低変動価格

      Take the minimum variation price of a trading contract.
      Usage:
      MINPRICE1; Take the minimum variation price of a trading contract.
      
  • 時間関数

    • バルポス

      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.
      
    • デイバーポス

      この日のK線BARは,現在のK線BARです.

    • 期間

      周期値は分数である.

      1, 3, 5, 15, 30, 60, 1440
      
    • 日付

      日付函数DATEは,1900年以降の年,月,日を取得します.

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

      K線を引く時間だ

      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;
      
    • 年間

      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);
      
    • 月を取って

      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;
      
    • 期間中の日数を取得します.

      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
      
    • 時数

      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
      
    • 1分前

      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
      
    • 週日

      週の番号を取れ

      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;
      
  • 論理判断機能

    • バルストータス

      現時点の位置状態を返します.

      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
      
    • その間

      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(COND) は,この条件を満たす連続期間の数を計算し,現在の期間に先を行います.

      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
      
    • クロス

      クロス機能

      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
      
    • 横切って

      クロスダウン

      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(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
      
    • すべて

      継続的に満たされているかどうかを判断します.

      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;
      
    • 存在している

      満足度があるかどうか判断する.

      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
      
    • IF について

      条件関数

      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

      条件関数

      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

関連性

もっと