等级: 免费版
- 注册:
- 2024-6-4
- 曾用名:
|
// 定义全局变量
Vars
NumericSeries MA10;
Bool IsLong = False;
Bool IsShort = False;
Numeric LotSize = 1;
Begin
// 计算10日均线
MA10 = AverageFC(CLOSE, 10);
// 限制交易时间在09:10 - 22:50
If (Time >= 091000 And Time <= 225000)
{
// 做多条件
If (MA10 > CLOSE And Not IsLong)
{
TBUY(LotSize, O, 0);
IsLong = True;
IsShort = False;
}
// 做空条件
Else If (MA10 < CLOSE And Not IsShort)
{
TSELLSHORT(LotSize, O, 0);
IsShort = True;
IsLong = False;
}
// 检查持仓盈利止损情况
If (BarsSinceEntry > 0)
{
// 做多持仓盈利止损
If (IsLong)
{
If ((CLOSE - EntryPrice) / EntryPrice >= 0.06)
{
TSELL(0, MKT);
LotSize = 1;
IsLong = False;
}
Else If ((EntryPrice - CLOSE) / EntryPrice >= 0.06)
{
TSELL(0, MKT);
LotSize = 2;
IsLong = False;
}
}
// 做空持仓盈利止损
Else If (IsShort)
{
If ((EntryPrice - CLOSE) / EntryPrice >= 0.06)
{
TBUYTOCOVER(0, MKT);
LotSize = 1;
IsShort = False;
}
Else If ((CLOSE - EntryPrice) / EntryPrice >= 0.06)
{
TBUYTOCOVER(0, MKT);
LotSize = 2;
IsShort = False;
}
}
}
}; // 补上缺失的分号
End
|
|