Loại dữ liệuNó là phổ biến kiến thức rằng chỉ có giá trị equitype có thể được thêm hoặc trừ. Ví dụ, táo có thể được thêm vào táo, nhưng táo không thể được thêm vào để mét vuông hoặc để nhiệt độ. Hạn chế tương tự có thể được tìm thấy trong hầu hết các ngôn ngữ algorithmic hiện đại.Giống như các đối tượng bình thường của cuộc sống có một số loại characterizing của màu sắc (màu đỏ, màu xanh, màu vàng, màu xanh lá cây), của hương vị (cay đắng, chua, ngọt), số lượng (một và một nửa, hai, bảy), MQL4 sử dụng dữ liệu loại khác nhau. Phát biểu về kiểu dữ liệu, chúng tôi sẽ có nghĩa là các loại của giá trị của một liên tục, trong một biến và giá trị trả về bởi một chức năng (khái niệm về chức năng được coi là trong phần của chức năng).Ở MQL4, các loại sau đây được phân biệt (cho các giá trị của hằng số, biến, và các giá trị trả về bởi chức năng):int - số nguyên; đôi - số thực; bool - giá trị Boolean (hợp lý); Chuỗi - giá trị của chuỗi loại; màu - giá trị loại màu sắc; DateTime - giá trị ngày và thời gian. Kiểu intCác giá trị của kiểu int là các số nguyên. Loại này bao gồm giá trị là số nguyên bởi bản chất của họ. Các giá trị sau đây là các số nguyên, ví dụ: số tiền của các quán bar trong cửa sổ biểu tượng (16000 thanh), số lượng mở và đang chờ xử lý đơn đặt hàng (đơn đặt hàng 3), khoảng cách ở điểm giữa giá biểu tượng hiện tại và bộ giá mở rộng (15 điểm). Số lượng đại diện cho các đối tượng như sự kiện cũng có thể là số nguyên chỉ. Ví dụ, số lượng các nỗ lực để mở một đơn đặt hàng không thể tương đương với một và một nửa, nhưng chỉ để một, hai, ba, vv.Hiện có 2 loại giá trị số nguyên:Giá trị thập phân có thể bao gồm các chữ số từ 0 đến 9 và được tích cực hoặc tiêu cực: 10, 11, 12, 1, 5,-379, 25,-12345, -1, 2. Hệ thập lục phân giá trị có thể bao gồm các chữ cái Latin từ A đến F hoặc từ một đến f, chữ số từ 0 đến 9. Họ phải bắt đầu với 0 x hoặc 0 X và có giá trị tích cực hay tiêu cực: 0x1a7b, 0xff340, 0xAC3 0X2DF23, 0X13AAB, 0X1. Giá trị của kiểu int phải trong khoảng từ - 2 147 483 648 để 2 147 483 647. Nếu giá trị của một liên tục hoặc một biến là vượt ra ngoài phạm vi trên, kết quả của hoạt động chương trình sẽ bị vô hiệu. Các giá trị của hằng số và biến kiểu int có 4 byte bộ nhớ của máy tính.Một ví dụ của việc sử dụng một biến kiểu int trong một chương trình: int nghệ thuật = 10; Ví dụ số nguyên biến int B_27 = -1; Ví dụ số nguyên biến int Num = 21; Ví dụ số nguyên biến int Max = 2147483647; Ví dụ số nguyên biến int phút =-2147483648; Ví dụ số nguyên biếnLoại đôiGiá trị của hai loại là số thực có chứa một phần phân đoạn.Ví dụ giá trị của loại hình này có thể là bất kỳ giá trị nào có một phần phân đoạn: độ nghiêng của dòng hỗ trợ, biểu tượng giá, có nghĩa là số tiền của các đơn đặt hàng mở trong vòng một ngày.Đôi khi bạn có thể phải đối mặt vấn đề chỉ định biến khi viết mã của bạn, tức là, nó không phải là luôn luôn rõ ràng để một lập trình viên loại (int hoặc đôi) biến thuộc về. Chúng ta hãy xem xét một ví dụ nhỏ:Một chương trình đã mở 12 đơn đặt hàng trong vòng một tuần. Loại của biến một mà sẽ xem xét có nghĩa là số lượng các đơn đặt hàng hàng ngày mở bằng chương trình này là gì? Câu trả lời là hiển nhiên: A = 12 đơn đặt hàng / 5 ngày. Nó có nghĩa là rằng biến A = 2.4 nên được xem xét trong chương trình như tăng gấp đôi, kể từ khi giá trị này có một phần chút ít. Loại nên là cùng một biến A nếu tổng số tiền đơn đặt hàng mở cửa trong vòng một tuần là 10? Bạn có thể nghĩ rằng nếu 2 (đơn đặt hàng 10 / 5 ngày = 2) đã không có một phần phân đoạn, biến A có thể được coi là int. Tuy nhiên, lý do này là sai. Giá trị hiện tại của một biến có thể có một phần phần bao gồm chỉ Zero. Nó là quan trọng rằng giá trị của biến này là có thật bởi bản chất của nó. Trong trường hợp này, biến A có cũng của hai loại. Khi tách cũng phải được hiển thị trong bản ghi liên tục trong chương trình: А = 2.0Các giá trị của hằng số thực và biến bao gồm một phần số nguyên, nhiệt độ thập phân, và một phần phân đoạn. Các giá trị có thể được tích cực hay tiêu cực. Một phần số nguyên và phần phân đoạn được làm bằng chữ số từ 0 đến 9. Số lượng nhân vật quan trọng sau khi dấu thập phân có thể đạt được giá trị của 15. Ví dụ: 27,12-1.0 2.5001-765456.0 198732.07 0.123456789012345 Các giá trị của đôi loại có thể dao động từ-1.7 * e-308 để 1,7 * e308. Trong bộ nhớ máy tính, các giá trị của hằng số và biến đôi loại mất 8 byte.Một ví dụ của việc sử dụng một biến đôi loại trong một chương trình: nghệ thuật đôi = 10.123; Ví dụ thực sự biến đôi B_27 =-1.0; Ví dụ thực sự biến đôi Num = 0,5; Ví dụ thực sự biến đôi MMM =-12.07; Ví dụ thực sự biến đôi Price_1 = 1.2756; Ví dụ thực sự biếnLoại boolGiá trị bool loại là giá trị Boolean (hợp lý) loại chứa falsehood hay thử thách.Để tìm hiểu các khái niệm của kiểu Boolean, chúng ta hãy xem xét một ví dụ nhỏ từ cuộc sống hàng ngày của chúng tôi. Nói rằng, một giáo viên cần để giải thích sự hiện diện của sách giáo khoa của các em học sinh. Trong trường hợp này, các giáo viên sẽ liệt kê tất cả các em học sinh trên một tờ giấy và sau đó sẽ đánh dấu trong một dòng đúng cho dù một học sinh có một cuốn sách hay không. Ví dụ, các giáo viên có thể sử dụng nhãn hiệu đánh dấu và dấu gạch ngang trong bảng:Danh sách các sách giáo khoa của học sinh về vật lý sách giáo khoa về sinh học sách giáo khoa về hóa học 1 Smith V-- 2 Jones V - V Brown 3 - V V ... ... ... ... ... 25 Thompson V V V Các giá trị trong cột bên phải có thể chỉ có 2 loại: đúng hay sai. Những giá trị này không thể được quy cho một trong các loại được coi là ở trên vì chúng không phải con số ở tất cả. Chúng không phải giá trị màu, hương vị, số lượng, vv, hoặc là. Tuy nhiên, họ mang một ý nghĩa quan trọng. Trong MQL4, các giá trị được đặt tên giá trị Boolean, hay hợp lý. Hằng số và biến loại bool được đặc trưng qua rằng chúng chỉ có giá trị có thể 2: đúng (thật sự, thật sự, 1) hoặc sai (False, FALSE, 0). Các giá trị của hằng số và biến loại bool mất 4 byte trong bộ nhớ máy tính.Một ví dụ của việc sử dụng một biến bool loại trong một chương trình: bool aa = True; Boolean biến аа có giá trị thật sự bool B17 = TRUE; Boolean biến B17 có giá trị thật sự bool Hamma = 1; Boolean biến Hamma có giá trị thật sự bool Asd = False; Boolean biến Asd có giá trị của sai bool Nol = FALSE; Boolean biến Nol có giá trị của sai bool Prim = 0; Boolean biến Prim có giá trị của sai Loại ChuỗiGiá trị của chuỗi loại là một giá trị đại diện như là một tập các ký tự ASCII.Trong cuộc sống hàng ngày của chúng tôi, một nội dung tương tự thuộc về, ví dụ: cửa hàng tên, làm cho xe hơi, vv. Một giá trị chuỗi-loại được ghi lại như là một tập các ký tự đặt trong daáu ngoaëc (không phải được trộn lẫn với dấu ngoặc kép gấp đơn!). Dấu ngoặc kép được sử dụng chỉ để đánh dấu sự khởi đầu và cuối của một chuỗi liên tục. Giá trị chính nó là tổng thể của nhân vật đóng khung bởi các dấu ngoặc kép.If there is a necessity to introduce a double quote ("), you should put a reverse slash () before it. Any special character constants following the reverse slash () can be introduced in a string. The length of a string constant ranges from 0 to 255 characters. If the length of a string constant exceeds its maximum, the excessive characters on the right-hand side will be truncated and compiler will give the corresponding warning. A combination of two characters, the first of which is the reverse slash (), is commonly accepted and perceived by most programs as an instruction to execute a certain text formatting. This combination is not displayed in the text. For example, the combination of
indicates the necessity of a line feed; demands tabulation, etc.The value of string type is recorded as a set of characters framed by double quotes: "MetaTrader 4", " Stop Loss", "Ssssstop_Loss", "stoploss", "10 pips". The string value as such is the set of characters. The quotes are used only to mark the value borders. The internal representation is a structure of 8 bytes.An example of using a variable of string type in a program: string Prefix = "MetaTrader 4"; // Example string variable string Postfix = "_of_my_progr. OK"; // Example string variable string Name_Mass = "History"; // Example string variable string text ="Upper Line
Lower Line"; // the text contains line feed charactersLoại màuGiá trị màu loại là một giá trị màu.Ý nghĩa của 'màu sắc' (màu xanh, đỏ, trắng, vàng, xanh lá cây, vv) là phổ biến kiến thức. Nó là dễ dàng để hình dung những gì một biến hoặc một hằng số loại màu sắc có nghĩa là. Nó là một hằng số hoặc một biến, giá trị trong đó là một màu sắc. Nó có vẻ là một chút không bình thường, nhưng nó là rất đơn giản, nói chung. Giống như giá trị của một liên tục số nguyên là một số, giá trị của một liên tục màu là một màu sắc.Các giá trị của hằng số màu sắc và các biến có thể được thể hiện là một trong ba loại:LiteralsGiá trị của loại màu sắc đại diện như một chữ bao gồm ba phần đại diện cho các giá trị số của cường độ của ba màu cơ bản: màu đỏ, màu xanh lá cây và màu xanh (RGB). Giá trị của loại này bắt đầu với 'C' và được trích dẫn bởi duy nhất báo giá.Các giá trị số của cường độ RGB nằm trong khoảng từ 0 đến 255 và có thể được ghi lại cả hai decimally và hexadecimally.Ví dụ: C'128, 128, 128' (màu xám), C'0x00, 0x00, 0xFF' (màu xanh), C'0xFF, 0x33, 0x00' (màu đỏ).Số nguyên đại diệnSố nguyên đại diện được ghi lại như là một hệ thập lục phân hoặc một số thập phân. Một số hệ thập lục phân được hiển thị như 0xRRGGBB nơi RR là giá trị của màu đỏ cường độ, GG - màu xanh lá cây, và BB - màu xanh. Hằng số thập phân không được phản ánh trực tiếp trong RGB. Họ đại diện cho giá trị thập phân của một đại diện thập lục phân số nguyên.Đại diện của các giá trị màu kiểu số nguyên và hexadecima
đang được dịch, vui lòng đợi..