我当前持仓6手空仓,执行BuyToCover平空返回true,但是没有任何反应。
最后我用 Commentary打印出MarketPosition 为正1,这能是什么原因导致的
说明图表持仓为多
你展示的是账户持仓
空单入场之前MarketPosition这个值也是0,空单入场成功了,这个值还是0,导致后面空单出场平仓执行没有反应。这个 MarketPosition 需要我自己维护吗,还是每次执行完下单接口都要刷新一下什么的。
你信号闪烁了吧
你好,信号闪烁是什么意思
感谢提供课程,这个课程我看了,里面说的信号闪烁主要影响的是回测,我现在遇到的问题是,只能开仓不能平仓,我做了一个测试策略,点里面的按钮只能开多开空,不能平,请帮我看下代码有什么问题吗
//------------------------------------------------------------------------
// 简称: test
// 名称: test
// 类别: 策略应用
// 类型: 内建应用
// 输出:
//------------------------------------------------------------------------
Params
Vars
Plot pltTool;
Global Bool bTestBuy(False);
Global Bool bTestSell(False);
Global Bool bTestSellShort(False);
Global Bool bTestBuyToCover(False);
Global String eventBtnTestBuy("eventBtnTestBuy");
Global String eventBtnTestSell("eventBtnTestSell");
Global String eventBtnTestSellShort("eventBtnTestSellShort");
Global String eventBtnTestBuyToCover("eventBtnTestBuyToCover");
Events
OnInit()
{
SubscribeEvent(eventBtnTestBuy);
SubscribeEvent(eventBtnTestSell);
SubscribeEvent(eventBtnTestSellShort);
SubscribeEvent(eventBtnTestBuyToCover);
pltTool.figure(0);
pltTool.toolBar(eventBtnTestBuy,"开多","开多");
pltTool.toolBar(eventBtnTestSell,"平多","平多");
pltTool.toolBar(eventBtnTestSellShort,"开空","开空");
pltTool.toolBar(eventBtnTestBuyToCover,"平空","平空");
}
OnBar(ArrayRef<Integer> indexs)
{
if(bTestBuy)
{
bTestBuy = False;
Print("开多:" + IIFString(Buy(1),"成功","失败"));
}
if(bTestSell)
{
bTestSell = False;
Print("平多:" + IIFString(Sell(1),"成功","失败"));
}
if(bTestSellShort)
{
bTestSellShort = False;
Print("开空:" + IIFString(SellShort(1),"成功","失败"));
}
if(bTestBuyToCover)
{
bTestBuyToCover = False;
Print("平空:" + IIFString(BuyToCover(1),"成功","失败"));
}
}
//成交更新事件函数,参数ordFill表示更新的成交结构体
OnFill(FillRef ordFill)
{
Print("-----> 成交:" + Text(ordFill));
PlotString("tip", "成交", Close, Green);
}
//通用事件触发函数,参数evtName为事件名称,参数evtValue为事件内容
OnEvent(StringRef evtName,MapRef<String,String> evtValue)
{
if(evtName == eventBtnTestBuy)
{
bTestBuy = True;
Print("发出 开多");
}
else if(evtName == eventBtnTestSell)
{
bTestSell = True;
Print("发出 平多");
}
else if(evtName == eventBtnTestSellShort)
{
bTestSellShort = True;
Print("发出 开空");
}
else if(evtName == eventBtnTestBuyToCover)
{
bTestBuyToCover = True;
Print("发出 平空");
}
}
问题大了去了,是谁教你这么写的。
你这样写,信号必闪烁
开仓信号闪烁没了,怎么可能出平仓信号
用一种语言平台写模型,起码先把语言的语法数据结构和机制都了解清楚再写吧
能给简单举个例子,我这个应该怎么做才不闪烁,能平仓呢?多谢
全部定义成序列类型
哪个教程里教过用global类型控制buy sell图表命令的?
我觉得你如果想创新,没问题,前提是把基础学扎实了。
感觉你在骂我🤔