- extern double Lot=0.1; // ประกาศให้ Lot เป็นตัวแปรภายนอกที่ผู้ใช้งานสามารถป้อนค่าที่ต้องการได้
- คำสั่งต่าง ๆ อยู่ภายใน int start( ) { ... }
- การเรียกใช้ MA ในตัวอย่างคือ
double MA5 = iMA(NULL,0,5,0,MODE_SMMA,PRICE_CLOSE,0);
double MA10 = iMA(NULL,0,10,0,MODE_SMMA,PRICE_CLOSE,0);
double MA15 = iMA(NULL,0,15,0,MODE_SMMA,PRICE_CLOSE,0);
double MA20 = iMA(NULL,0,20,0,MODE_SMMA,PRICE_CLOSE,0);
มีรูปแบบดังนี้
double iMA(
string symbol, // symbol
int timeframe, // timeframe
int ma_period, // MA averaging period
int ma_shift, // MA shift
int ma_method, // averaging method
int applied_price, // applied price
int shift // shift
);
string symbol, // symbol
int timeframe, // timeframe
int ma_period, // MA averaging period
int ma_shift, // MA shift
int ma_method, // averaging method
int applied_price, // applied price
int shift // shift
);
- symbol := สัญษณ์ของกราฟ หากใส่ NULL หรือ 0 จะหมายถึง คู่เงินที่กราฟนั้นเปิดอยู่
- timeframe := เวลาของกราฟที่จะเรียกใช้งาน หากใส่ 0 จะหมายถึง Timeframe used on the chart
ID
|
Value
|
Description
|
PERIOD_CURRENT
|
0
|
Current timeframe
|
PERIOD_M1
|
1
|
1 minute
|
PERIOD_M5
|
5
|
5 minutes
|
PERIOD_M15
|
15
|
15 minutes
|
PERIOD_M30
|
30
|
30 minutes
|
PERIOD_H1
|
60
|
1 hour
|
PERIOD_H4
|
240
|
4 hours
|
PERIOD_D1
|
1440
|
1 day
|
PERIOD_W1
|
10080
|
1 week
|
PERIOD_MN1
|
43200
|
1 month
|
- period := จำนวนแท่งเทียนที่นำมาใช้คำนวณ
- ma_shift := MA shift, Indicators line offset relate to the chart by timeframe
- ma_method := ชนิดของเส้น MA ที่นำมาใช้
ID
|
Value
|
Description
|
MODE_SMA
|
0
|
Simple averaging
|
MODE_EMA
|
1
|
Exponential averaging
|
MODE_SMMA
|
2
|
Smoothed averaging
|
MODE_LWMA
|
3
|
Linear-weighted averaging
|
- applied_price := ชนิดของราคาที่นำมาใช้คำนวณ
ID
|
Value
|
Description
|
PRICE_CLOSE
|
0
|
Close price
|
PRICE_OPEN
|
1
|
Open price
|
PRICE_HIGH
|
2
|
The maximum price for the period
|
PRICE_LOW
|
3
|
The minimum price for the period
|
PRICE_MEDIAN
|
4
|
Median price, (high + low)/2
|
PRICE_TYPICAL
|
5
|
Typical price, (high + low + close)/3
|
PRICE_WEIGHTED
|
6
|
Weighted close price, (high + low + close + close)/4
|
- shift := แท่งเทียนของกราฟที่ต้องการเรียกค่าขึ้นมาใช้โดเริ่มจาก 0 คือแท่งเทียนปัจจุบันแล้วนับเพิ่มขึ้นตามแท่งเทียนของกราฟไปทางด้านซ้ายมือ
ไม่มีความคิดเห็น:
แสดงความคิดเห็น