[TOC]
MyLanguage एक प्रोग्रामेटिक ट्रेडिंग भाषा है जो MyLanguage के साथ संगत और बढ़ी हुई है। FMZ Quant का MyLanguage सख्त सिंटैक्स जांच से गुजरता है। उदाहरण के लिए, जावास्क्रिप्ट भाषा कोड को एम्बेड करने के लिए भाषा संवर्धन का उपयोग करते समय, एक अतिरिक्त स्थान वर्ण के बाद%%
ऑपरेटर एक त्रुटि की रिपोर्ट करने के लिए कारण होगा.
क्रिप्टोकरेंसी अनुबंध
क्रिप्टोकरेंसी अनुबंध
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
एक चर कंप्यूटर मेमोरी में डेटा स्टोर करने के लिए खोला गया स्थान है। सरल शब्दों में, इसका उपयोग डेटा स्टोर करने के लिए किया जाता है।
पहला चर खोलें
// assign 1 to variable a
a:=1;
अंदरMyLanguage
, यह अलग करने के लिए आसान हैdata volume
:
0
, 1
, 'abc'
.Close
(समापन मूल्य), जहांClose
समापन मूल्य हैn
periods. [ 10.1 , 10.2 , 10.3 , 10.4 , 10.5 ...]
''
, स्ट्रिंग प्रकार को सीधे उपयोग करने की अनुमति नहीं है, और इसे फ़ंक्शन के साथ दृश्य में आउटपुट करने की आवश्यकता है।INFO(CLSOE>OPEN,'OK!');
// integer
int:=2;
// decimal
float:=3.1;
A:=1>0;
इस कोड को निष्पादित करने के बाद, का मानA
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;
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 बार जमा हुई हैं।
वास्तविक मूल्य इस बात पर निर्भर करता है कि प्रारंभ में कितनी के-लाइनें प्राप्त की जाती हैं।
अधिकांश प्रणालियों में, चर नामकरण प्रणाली Close
, C
इसके अतिरिक्त, शुद्ध संख्याओं या प्रमुख संख्याओं की अनुमति नहीं है। अंत में, यह बहुत लंबा होने की अनुमति नहीं है, और विभिन्न प्रणालियों में अलग-अलग लंबाई प्रतिबंध हैं।
वास्तव में, आपको मुख्यधारा की प्रणाली
1. Chinese name
// elegant output
5-day moving average:=MA(C,5);
2. English + underline
// Output
move_avg_5:=MA(C,5);
यदि आप अंग्रेजी पसंद करते हैं, तो अपने चर का अर्थ यथासंभव समझ में आने का प्रयास करें। जैसे नामों का उपयोग न करेंःA1
, AAA
, BBB
.... मेरा विश्वास करो जब आप कुछ दिनों में फिर से अपने संकेतक कोड की समीक्षा करेंगे, तो आप स्मृति हानि के कारण बहुत दुखी होंगे। इसी तरह, जब आप कोड को दूसरों को निर्यात करते हैं, तो पाठक को तबाह होना चाहिए।
इसलिए अब से
MyLanguage को पूरी तरह से अपनाएं! मुझे आशा है कि यह आपके विश्लेषण और निर्णय लेने के लिए एक शक्तिशाली उपकरण बन सकता है।
डेटा प्रकार एक बुनियादी अवधारणा है. जब हम लिखने में एक चर को स्पष्ट डेटा असाइन करते हैं, तो चर स्वयं डेटा का प्रकार भी बन जाता है.
1.2.3.1.1234.2.23456 ...
'1' .'2' .'3' ,String types must be wrapped with ''
A collection of data consisting of a series of single-valued data
प्रयोग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. `:`
```:```, represents assignment and output to the graph (subgraph).
```
Close1:Close; // Assign Close to the variable Close1 and output to the figure
```
- 2. `:=`
```:=```, represents assignment, but is not output to the graph (main graph, sub graph...), nor is it displayed in the status bar table.
```
Close2:=Close; // Assign Close to the variable Close2
```
- 3. `^^`
```^^```, Two ```^``` symbols represent assignment, assign values to variables and output to the graph (main graph).
```
lastPrice^^C;
```
- 4. `..`
```..```, two ```.``` symbols represent assignment, assign values to variables and display variable names and values in the chart, but do not draw pictures to the chart (main picture, sub-picture...).
```
openPrice..O
```
संबंधपरक संचालक द्विआधारी संचालक हैं जिनका उपयोग दो डेटा के बीच संबंध निर्धारित करने के लिए सशर्त अभिव्यक्ति में किया जाता है।
रिटर्न मानः बुल प्रकार, या तोtrue
(1) याfalse
(0).
- 1. more than```>```
```
// Assign the operation result of 2>1 to the rv1 variable, at this time rv1=1
rv1:=2>1;
```
- 2. less than```<```
```
// Returns false, which is 0, because 2 is greater than 1
rv3:=2<1;
```
- 3. more than or equal to```>=```
```
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;
```
- 4. less than or equal to```<=```
```
omitted here
```
- 5. equal to```=```
```
A:=O=C; // Determine whether the opening price is equal to the closing price.
```
- 6. Not equal to```<>```
```
1<>2 // To determine whether 1 is not equal to 2, the return value is 1 (true)
```
रिटर्न मानः बुल प्रकार, या तोtrue
(1) याfalse
(0).
1. The logical and ```&&```, can be replaced by ```and```, and the left and right sides of the and connection must be established at the same time.
// 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
2. Logical or ```||```, you can use ```or``` to replace the left and right sides of the or link, one side is true (true), the whole is true (return value 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
3. ```()``` operator, the expression in parentheses will be evaluated first.
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
अंकगणितीय संचालक अंकगणितीय संचालक हैं। यह बुनियादी अंकगणितीय संचालन (गणितीय संचालक) को पूरा करने के लिए एक प्रतीक है, जो चार अंकगणितीय संचालन को संसाधित करने के लिए उपयोग किया जाने वाला प्रतीक है।
- **plus +**
```
A:=1+1; // return 2
```
- **minus -**
```
A:=2-1; // return 1
```
- **multiply \**
```
A:=2*2; // return 4
```
- **divide /**
```
A:=4/2; // return 2
```
प्रोग्रामिंग की दुनिया में,
function एक कोड का एक टुकड़ा है जो एक निश्चित फ़ंक्शन को लागू करता है। और इसे अन्य कोड द्वारा बुलाया जा सकता है, सामान्य रूप निम्नानुसार हैः
function(param1,param2,...)
- Composition:
Function name (parameter1, parameter2, ...), may have no parameters or have multiple parameters. For example, ```MA(x,n);``` means to return to the simple moving average of ```x``` within ```n``` periods. Among them, ```MA()``` is a function, ```x``` and ```n``` are the parameters of the function.
When using a function, we need to understand the basic definition of the function, that is, what data can be obtained by calling the function. Generally speaking, functions have parameters. When we pass in parameters, we need to ensure that the incoming data type is consistent. At this stage, the code hinting function of most IDEs is very imperfect. There is a data type of the parameter given, which brings some trouble to our use, and ```MA(x,n);``` is interpreted as:
```
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
```
This is very unfriendly to beginners, but next, we will dissect the function thoroughly, trying to find a quick way to learn and use the function.
जल्दी से कार्यों को सीखने के लिए, हम पहले एक अवधारणा को समझने की जरूरत है, यह
// 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.
दूसरा, फ़ंक्शन की दूसरी महत्वपूर्ण अवधारणा पैरामीटर है, और विभिन्न पैरामीटरों में पास करके विभिन्न रिटर्न मान प्राप्त किए जा सकते हैं।
// 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);
पहला पैरामीटरX
उपरोक्त चरों में सेma5
, ma10
हैC
(समापन मूल्य), वास्तव में,C
यह भी एक फलन है (खुलने से वर्तमान तक बंद कीमतों का अनुक्रम लौटाता है), लेकिन इसमें कोई पैरामीटर नहीं है।MA()
फ़ंक्शन है कि हम कुछ दिनों के लिए समापन मूल्य के चलती औसत प्राप्त करना चाहते हैं। फ़ंक्शन मापदंडों के माध्यम से उपयोग करने के लिए अधिक लचीला हो जाता है।
MA(x,n)
, यदि आप पैरामीटर के डेटा प्रकार को नहीं जानते हैंx
, n
, यह वापसी सही मूल्य प्राप्त करने में सक्षम नहीं होगा.निम्नलिखित कार्य परिचय और उपयोग में, उपरोक्त तीन सिद्धांतों का पालन करें।
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```object
The ```scope``` object can add attributes and assign anonymous functions to attributes, and the anonymous function referenced by this attribute can be called in the code part of MyLanguage.
- ```scope.getRefs(obj)```function
In ```JavaScript``` code block, call the ```scope.getRefs(obj)``` function to return the data of the passed in ```obj``` object.
The ```JavaScript``` code wrapped with the following ```%% %%``` will get the ```C``` passed in when the ```TEST(C)``` function in MyLanguage code is called Close price.
The ```scope.getRefs``` function will return all the closing prices of this K-line data. Because of the use of ```throw "stop"``` to interrupt the program, the variable ```arr``` contains the closing price of the first bar only. You can try to delete ```throw "stop"```, it will execute the ```return``` at the end of the ```JavaScript``` code, and return all closing price data.
```
%%
scope.TEST = function(obj){
var arr = scope.getRefs(obj)
Log("arr:", arr)
throw "stop"
return
}
%%
TEST(C);
```
- scope.bars
Access all K-line bars in the ``JavaScript`` code block.
The ```TEST``` function returns a value. 1 is a negative line and 0 is a positive line.
```
%%
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
In the ```JavaScript``` code block, access the current bar.
Calculate the average of the high opening and low closing prices.
```
%%
scope.TEST = function(){
var bar = scope.bar
var ret = (bar.Open + bar.Close + bar.High + bar.Low) / 4
return ret
}
%%
avg^^TEST;
```
- scope.depth
Access to market depth data (order book).
```
%%
scope.TEST = function(){
Log(scope.depth)
throw "stop" // After printing the depth data once, throw an exception and pause
}
%%
TEST;
```
- scope.symbol
Get the name string of current trading pair.
```
%%
scope.TEST = function(){
Log(scope.symbol)
throw "stop"
}
%%
TEST;
```
- scope.barPos
Get the Bar position of the K-line.
```
%%
scope.TEST = function(){
Log(scope.barPos)
throw "stop"
}
%%
TEST;
```
- scope.get\_locals('name')
This function is used to get the variables in the code section of 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
The ```canTrade``` attribute marks whether the current bar can be traded (whether the current Bar is the last one)
For example, judging that the market data is printed when the strategy is in a state where the order can be traded
```
%%
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);
एक बार स्थिति खोलने और बंद करने के बाद रणनीति को रोकें।
प्रणाली स्वचालित रूप से एक उपयुक्त अंतर्निहित के-लाइन अवधि का चयन करेगी और डेटा की सटीकता सुनिश्चित करने के लिए सभी संदर्भित के-लाइन डेटा को संश्लेषित करने के लिए इन अंतर्निहित के-लाइन अवधि डेटा का उपयोग करेगी।
#EXPORT formula_name ... #END
एक सूत्र बनाने के लिए. अगर सूत्र केवल विभिन्न अवधि के डेटा प्राप्त करने के लिए गणना नहीं की जाती है, आप भी एक खाली सूत्र लिख सकते हैं.एक खाली सूत्र हैः
#EXPORT TEST
NOP;
#END // end
#IMPORT [MIN,period,formula name] AS variable value
एक सूत्र को संदर्भित करने के लिए निर्धारित अवधि के विभिन्न डेटा प्राप्त करें (बंद मूल्य, उद्घाटन मूल्य, आदि, चर मूल्य द्वारा प्राप्त) ।..MIN
मेंIMPORT
आदेश का अर्थमिनट का स्तर.MyLanguage FMZ क्वांट प्लेटफॉर्म, और केवलMIN
स्तर में समर्थित हैIMPORT
आदेश. गैर मानक अवधि अब समर्थित हैं. उदाहरण के लिए, आप उपयोग कर सकते हैं#IMPORT [MIN, 240, TEST] AS VAR240
240 मिनट की अवधि (4 घंटे) के-लाइन जैसे डेटा आयात करने के लिए।
कोड उदाहरणः
// 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;
अंतर की तुलना करनाMIN5.REF1C
औरREF(MIN5.C, 1)
,हम पा सकते हैंः
```REF(MIN5.C, 1)``` is the K -line period of the current model (the above code backtest period is set to 1 minute, i.e. ```period: 1m``), the closing price of the 5-minute period where the penultimate BAR is located at the current moment.
These two definitions are differentiated, and they can be used as needed.
- ## Mode Description
- ### Signal filtering model of one opening and one leveling
In the model, the ```AUTOFILTER``` function is written to control and realize the signal filtering of one opening and one closing. When there are multiple opening signals that meet the conditions, the first signal is taken as the valid signal, and the same signal on the K-line will be filtered out.
Instructions supported by filtering model: BK, BP, BPK, SK, SP, SPK, CLOSEOUT, etc. Instructions with lot numbers such as BK(5) are not supported.
For example
MA1:MA(CLOSE,5); MA2:MA(CLOSE,10); CROSSUP(C,MA1),BK; CROSSUP(MA1,MA2),BK; C>BKPRICE+10
समझना:
उपरोक्त उदाहरण की तरह, जब AUTOFILTER सेट नहीं किया जाता है, तो तीसरी पंक्ति BK, चौथी पंक्ति BK और पांचवीं पंक्ति SP क्रमशः ट्रिगर की जाती है, और प्रत्येक K-लाइन एक बार संकेत ट्रिगर करती है। स्थिति खोलने और स्थिति को बंद करने के बाद, मॉडल स्थिति को रीसेट किया जाता है।
यदि AUTOFILTER सेट है, तो BK ट्रिगर करने के बाद, केवल SP ट्रिगर किया जाता है, अन्य BK सिग्नल अनदेखा किए जाते हैं, और प्रत्येक K-लाइन एक बार सिग्नल ट्रिगर करती है।
- ### Increase and decrease position model
The ```AUTOFILTER``` function is not written in the model, allowing continuous opening signals or continuous closing signals, which can increase and decrease positions.
Supported instructions: BK(N), BP(N), SK(N), SP(N), CLOSEOUT, BPK(N), SPK(N), open and close orders without lot size are not supported.
(1)Instruction grouping is supported.
(2)When multiple instruction conditions are satisfied at the same time, the signals are executed in the order in which the conditional statements are written.
For example:
MA1:MA(CLOSE,5); MA2:MA(CLOSE,10); CROSSUP(C,MA1),BK(1); CROSSUP(MA1,MA2),BK(1); C>BKPRICE+10
Use ```TRADE\_AGAIN```
It is possible to make the same command line, multiple signals in succession.
समझना: उपरोक्त उदाहरण एक-एक करके निष्पादित किया जाता है, और निष्पादन के बाद संकेत अब ट्रिगर नहीं किया जाता है। स्थिति को बंद करने के बाद मॉडल स्थिति को रीसेट करें। एक K-लाइन एक बार संकेत को ट्रिगर करती है।
- ### Model with one K-line and one signal
Regardless of whether the K-line is finished, the signal is calculated in real-time orders, that is, the K-line is placed before the order is completed; the K-line is reviewed at the end. If the position direction does not match the signal direction at the end of the K-line, the position will be automatically synchronized.
For example:
MA1:MA(CLOSE,5); MA2:MA(CLOSE,10); CROSSUP(MA1,MA2),BPK; //5 अवधि चलती औसत ऊपर जाती है, और 10 अवधि चलती औसत लंबी जाती है। CROSSDOWN ((MA1,MA2),SPK; //5-अवधि चलती औसत नीचे जाती है, और 10-अवधि चलती औसत कम हो जाती है। ऑटोफिल्टर;
- ### A model of multiple signals on one K-line
The model uses ```multsig``` to control and implement multiple signals from one K-line.
Regardless of whether the K-line is finished, the signal is calculated in real-time.
The signal is not reviewed, there is no signal disappearance, and the direction of the signal is always consistent with the direction of the position.
If multiple signal conditions are met in one K-line, it can be executed repeatedly.
उदाहरण के लिए: MA1:MA(CLOSE,5); MA2:MA(CLOSE,10); CROSSUP(MA1,MA2),BK; C>BKPRICE+10
```MULTSIG``` can execute multiple command lines within one K-line.
A command line is only signaled once.
O,BK; // इन शर्तों के सभी एक K-लाइन बार में निष्पादित किया जा सकता है, लेकिन प्रति लाइन केवल एक संकेत 10+O,BK; // रणनीति प्लस TRADE_AGAIN(10);यह प्रति पंक्ति कई संकेत बना सकता है 20+O,BK; 40+O,BK; MULTSIG(1,1,10);
Supplement:
1.The model of adding and reducing positions, two ways of one signal and one K-line: placing an order at the closing price and placing an order at the order price, are both supported.
2.The model of adding and reducing positions also supports ordering of multiple signals from one K-line.
The model of adding and reducing positions, write the ```multsig``` function to realize multiple additions or multiple reductions on one K-line.
- ## Execution mode
![MyLanguage Doc](/upload/asset/28d0c387f293478294600.png)
- ### Bar model
The Bar model refers to the model that is executed after the current BAR is completed, and the trading is executed when the next BAR starts.
- ### Tick model
The Tick model means that the model is executed once for each price movement and trades immediately when there is a signal.
The Tick model ignores the previous day's signal (the previous day's signal is executed immediately on the same day), and the Tick model focuses only on the current market data to determine whether the signal is triggered.
- ## Chart display
- ### Additional indicators for main chart
> Use operator ```^^```, set indicators are displayed on the main chart while assigning values to variables.
MA60^^MA(C, 60); // पैरामीटर 60 के साथ औसत संकेतक की गणना करें
![MyLanguage Doc](/upload/asset/168d6ee1bbb8c7c9be63.png)
- ### Additional Indicators for sub-chart
Use operator ```:```, set indicators are displayed on the sub-chart while assigning values to variables.
एटीआरः एमए ((मैक्स)) मैक्स (उच्च-निम्न),एबीएस (उच्च-निम्न),एबीएस (उच्च-निम्न),एबीएस (उच्च-निम्न)),एबीएस (उच्च-निम्न)),एबीएस (निम्न) एटीआर चर को एक मान असाइन करें, प्रतीक के बाद एटीआर की गणना के लिए सूत्र है
![MyLanguage Doc](/upload/asset/7b032733df1539ff923b539b1dea72d0.png)
If you don't want it to be displayed on the main or subchart, use the "..." operator.
MA60..MA(C, 60); // पैरामीटर 60 के साथ औसत संकेतक की गणना करें
You can use ```DOT``` and ```COLORRED``` to set the line type and color of the line, etc., in line with the habits of users familiar with the MyLanguage.
- ## Common problems
> Introduce the **problems** commonly encountered in the process of writing indicators, usually the points that need to be paid attention to when writing (continuously added).
- Remark the semicolon ```;``` at the end.
- Remark that system keywords cannot be declared as variables.
- Remark that the string uses **single quotes**, for example: the string ```'Open position'```.
- ### Remark
Annotation
- ```// The Remark content ``` (input method can be typed in both Chinese and English) means that the code is not compiled during the execution process, that is, the content after ```//``` is not executed. Usually we use it to mark the meaning of the code, when it is convenient for code review, it can be quickly understood and recalled.
- ```{ Remark content }```Block Remark.
```
A:=MA(C,10);
{The previous line of code is to calculate the moving average.}
```
- ```(* Remark content *)```Block Remark.
```
A:=MA(C,10);
(*The previous line of code is to calculate the moving average.*)
```
- ### Input
When writing code, because the input method is often switched between Chinese and English, resulting in symbol errors. The common errors are as follows: colon ```:```, terminator ```;```, comma ```, ```, brackets ```()```, etc. These characters in different states of Chinese and English need attention.
> If you use Sogou, Baidu, or Bing input methods, you can quickly switch between Chinese and English by pressing the ```shift``` key once.
- ### Error-prone logic
1. At least, not less than, not less than: the corresponding relational operator ```>=```.
2. Up to, at most, no more than: the corresponding relational operator ```<=```.
- ### Strategy launch synchronization
In the futures strategy, if there is a manually opened position before the strategy robot starts, when the robot starts, it will detect the position information and synchronize it to the actual position status.
In the strategy, you can use the ```SP```, ```BP```, ```CLOSEOUT``` commands to close the position.
%%
यदि (!scope.init) {
var टिकर = exchange.GetTicker();
विनिमय.खरीदें.बिक्री +10, 1);
scope.init = सच;
}
%%
C>0, CLOSEOUT;
MyLanguage एक ही अनुबंध को लंबी और छोटी स्थिति दोनों के साथ समर्थन नहीं करता है।
के-लाइन चार्ट का शुरुआती मूल्य प्राप्त करें।
आरंभिक मूल्य
कार्यः 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).
के-लाइन चार्ट पर उच्चतम मूल्य प्राप्त करें।
उच्चतम मूल्य
कार्यः 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
के-लाइन चार्ट की समापन कीमत प्राप्त करें।
समापन मूल्य
कार्यः 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, संक्षिप्त रूप से 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)
वायदा (अनुबंध) बाजार में वर्तमान कुल स्थिति लें।
OpenInterest:OPI;
अग्रिम उद्धरण।
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.
व्यापारिक अनुबंध की न्यूनतम भिन्नता मूल्य।
Take the minimum variation price of a trading contract.
Usage:
MINPRICE1; Take the minimum variation price of a trading contract.
के-लाइन की स्थिति ले लो.
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 वर्तमान K-लाइन BAR दिन का K-लाइन BAR है।
अवधि मान मिनटों की संख्या है।
1, 3, 5, 15, 30, 60, 1440
तिथिफ़ंक्शन दिनांक, वर्ष, माह और 1900 के बाद से अवधि के दिन प्राप्त करें
Example 1:
AA..DATE; // The value of AA at the time of testing is 220218, which means February 18, 2022
के-लाइन लेने का समय।
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
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(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
स्थिति फलन
टिप्पणियाँ:
1.COND एक निर्णय की शर्त है; A और B शर्तें या मान हो सकते हैं।
2.यह फ़ंक्शन पिछले अवधि