- 精华
- 0
- 在线时间
- 98 小时
- UID
- 2415
- 积分
- 21
- 帖子
- 7
- 阅读权限
- 10
- 注册时间
- 2008-9-21
- 最后登录
- 2021-4-8
- 精华
- 0
- UID
- 2415
- 积分
- 21
- 帖子
- 7
- 主题
- 4
- 阅读权限
- 10
- 注册时间
- 2008-9-21
- 最后登录
- 2021-4-8
|
AvgValue1 = AverageFC(Close,FastLength);
AvgValue2 = AverageFC(Close,SlowLength);
Hitoday = High;
Lotoday =Low;
MinPoint = MinMove*PriceScale;
AvgTR = XAverage(TrueRange,ATRLength);
N = AvgTR[1];
TotalEquity = Portfolio_CurrentCapital() + Portfolio_UsedMargin();
TurtleUnits = (TotalEquity*RiskRatio/100) /(N * ContractUnit()*BigPointValue());
TurtleUnits = IntPart(TurtleUnits); // 对小数取整
Buy_signal = AvgValue1[1] > AvgValue2[1] && Lotoday>AvgValue1[1] ;
Sell_signal = AvgValue1[1] < AvgValue2[1] && Hitoday<AvgValue1[1];
If(MarketPosition ==0 && TurtleUnits>=1 && (TotalTrades()==0||(TotalTrades()>0 && BarsSinceExit>0)) )
{ If (Buy_signal )
{
Buy(TurtleUnits,Open);
}Else
If(Sell_signal)
{
SellShort(TurtleUnits,OPEN);;
}
}Else
If(MarketPosition == 1) // 有多仓的情况
{
If(Sell_signal && TurtleUnits>=1) //如果有空信号,平掉多单并开空
{
SellShort(TurtleUnits,OPEN);
}Else
{
If( ((CurrentEntries()>=2 && Hitoday < LastEntryPrice()-N ) ||(CurrentEntries()>=3 && Lotoday-LastEntryPrice()>TP*N) ) && MarketPosition == 1)
{
Sell(0,OPEN);
}Else
{
If ( Hitoday <= LastEntryPrice() - 2* N && SendOrderThisBar == false && MarketPosition == 1) Sell(0,OPEN);// 止损指令
If( CurrentEntries()<=4 && TurtleUnits >= 1 && Buy_signal && MarketPosition == 1)
{
If(Lotoday >= LastEntryPrice() + 0.5*N) // 如果开盘就超过设定的1/2N,则直接用开盘价增仓。
{
Buy(TurtleUnits,OPEN);
}
}
}
}
} |
|