- 精华
- 0
- 在线时间
- 113 小时
- UID
- 95458
- 积分
- 129
- 帖子
- 43
- 阅读权限
- 40
- 注册时间
- 2012-2-4
- 最后登录
- 2014-4-21
- 精华
- 0
- UID
- 95458
- 积分
- 129
- 帖子
- 43
- 主题
- 9
- 阅读权限
- 40
- 注册时间
- 2012-2-4
- 最后登录
- 2014-4-21
|
Params
Numeric EntryStop(0.5);
Numeric stop(0.5);
Numeric malen(60);
Vars
Numeric ma;
Numeric EntryPrice1;
Numeric MyExitPrice;
NumericSeries HighestAfterEntry;
NumericSeries LowestAfterEntry;
Begin
ma = Average(Close,malen);
PlotNumeric("ma",ma);
If(BarsSinceentry == 0)
{
HighestAfterEntry = Close;
LowestAfterEntry = Close;
If(MarketPosition <> 0)
{
HighestAfterEntry = Max(HighestAfterEntry,AvgEntryPrice);
LowestAfterEntry = Min(LowestAfterEntry,AvgEntryPrice);
}
}
else
{
HighestAfterEntry = Max(HighestAfterEntry,High);
LowestAfterEntry = Min(LowestAfterEntry,Low);
}
Commentary("HighestAfterEntry="+Text(HighestAfterEntry));
Commentary("LowestAfterEntry="+Text(LowestAfterEntry));
if(CurrentBar > malen)
{
if(MarketPosition == 0)
{
if(Open >= ma)
{
if(high/open >= 1+EntryStop/100)
{
EntryPrice1=open*(1+EntryStop/100);
Buy(1,EntryPrice1);
Return;
}
}
Else
{
if(low/open <= 1-EntryStop/100)
{
EntryPrice1=open*(1-EntryStop/100);
SellShort(1,EntryPrice1);
Return;
}
}
}
if(MarketPosition == 1)
{
if(low/open <= 1-stop/100 )
{
sell(1,open*(1-stop/100));
Return;
}
if(LowestAfterEntry<=EntryPrice1/(1+EntryStop/100))
{
MyExitPrice=EntryPrice1/(1+EntryStop/100);
MyExitPrice=IntPart(MyExitPrice/MinMove*PriceScale)*MinMove*PriceScale;
if(Open<MyExitPrice) MyExitPrice=Open;
Sell(0,MyExitPrice);
Return;
}
}
if(MarketPosition == -1)
{
if(High/open >= 1+stop/100 )
{
BuyToCover(1,open*(1+stop/100));
Return;
}
if(High>=EntryPrice1/(1-EntryStop/100))
{
MyExitPrice=EntryPrice1/(1-EntryStop/100);
MyExitPrice=IntPart(MyExitPrice/MinMove*PriceScale)*MinMove*PriceScale;
if(Open>MyExitPrice) MyExitPrice=Open;
BuyToCover(0,MyExitPrice);
Return;
}
}
}
End |
|