- 精华
- 0
- 在线时间
- 42 小时
- UID
- 246133
- 积分
- 38
- 帖子
- 29
- 阅读权限
- 10
- 注册时间
- 2017-1-15
- 最后登录
- 2023-6-6
- 精华
- 0
- UID
- 246133
- 积分
- 38
- 帖子
- 29
- 主题
- 9
- 阅读权限
- 10
- 注册时间
- 2017-1-15
- 最后登录
- 2023-6-6
|
//------------------------------------------------------------------------
// 简称: CheShi_Duo
// 名称: 均价昨结价做多
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
Numeric lots(1);
Numeric StopLossSet(15); //固定 止损设置
Vars
Numeric JustPrice;
Numeric YesterdayPrice;
Numeric MinPoint; // 一个最小变动单位,也就是一跳
NumericSeries HighestAfterEntry; // 开仓后出现的最高价
NumericSeries LowestAfterEntry; // 开仓后出现的最低价
Numeric BuyStopLine;
Numeric BuyPoint;//1为持多单,0为不持单
Numeric OpenBar;//记录开仓的Bar数值
Numeric OpenBar_Du;
Numeric BarCha;
Begin
If(!CallAuctionFilter()) Return;
If(BarStatus==0)
{
OpenBar=0;
BuyPoint=0;
SetGlobalVar(1,BuyPoint);
SetGlobalVar(0,OpenBar);
} Else
{
OpenBar=GetGlobalVar(0);
BuyPoint=GetGlobalVar(1);
}
JustPrice=Q_AvgPrice;
YesterdayPrice=Q_PreSettlePrice;
//PlotNumeric("实时均价",JustPrice,0,Yellow);
//PlotNumeric("昨日结算价",YesterdayPrice,0,white);
If(JustPrice>YesterdayPrice&&A_BuyPosition==0/*&&BuyPoint==0*/)
{
A_SendOrder(Enum_Buy,Enum_Entry,lots,Q_AskPrice);
//Buy(lots,Q_AskPrice);
BuyPoint=1;
SetGlobalVar(1,BuyPoint);
BuyPoint=GetGlobalVar(1);
SetGlobalVar(0,Currentbar);
OpenBar=GetGlobalVar(0);
SetTBProfileString2File("C:\\ "+Upper(Symbol())+"_OpenBar_Duo1.txt","OpenBar","OpenBar",Text(OpenBar));
}
if(A_BuyPosition!=0)
{
OpenBar_Du=Value(GetTBProfileString2File("C:\\ "+Upper(Symbol())+"_OpenBar_Duo1.txt","OpenBar","OpenBar"));
BarCha=CurrentBar-OpenBar_Du;
Commentary("OpenBar_Du="+Text(OpenBar_Du));
HighestAfterEntry=Highest(High,BarCha);
Commentary("HighestAfterEntry="+Text(HighestAfterEntry));
MinPoint = MinMove*PriceScale;
BuyStopLine=HighestAfterEntry-StopLossSet*MinPoint;
//Commentary("多单止损线="+Text(BuyStopLine));
PlotNumeric("多单止损线Green",BuyStopLine,0,Green);
}
if(Q_Last<=BuyStopLine&&A_BuyPosition!=0&&A_GetOpenOrderCount==0)
{
A_SendOrder(Enum_Sell,Enum_Exit,lots,Q_BidPrice);
//Sell(lots,Q_BidPrice);
BuyPoint=0;
SetGlobalVar(1,BuyPoint);
BuyPoint=GetGlobalVar(1);
}
End
-----------------------------------------------------------------------
在旗舰版上自己搞了一个A数控制的!但是实际运行时,有时候会开出两手单!平仓有时也会提示平仓不足
如果启用BuyPoint则很多时候都不开仓,重新刷新图表又正常开仓! |
|