在策略交易开自动交易和在行情页面自动交易完全不一样

策略交易里面开户自动交易只发买委托,打开策略的k线图也是只有买信号,但是我停掉自动交易再开再打开k线图又买卖信号都有了但是策略显示的多仓数还是不对

TBQ自动开启自动交易
自动交易
自动交易
自动交易
量化自动交易 请求策略代写
多周期,策略自动交易
策略自动交易,开仓信号闪烁,先出现,最后再消失
量化策略在自动交易中看到的收益为啥与策略研究中的收益不一样
请问有没有自动交易的观察信号页面,跟文华8的模组页面类似
打开自动交易流程下

//------------------------------------------------------------------------

// 简称: kdj1234barwy

// 名称: 上穿没有买仓买,下破没有卖仓卖

// 类型: 公式应用

// 类型: 用户应用

// 输出: Void

//------------------------------------------------------------------------


Params

Bool isRollover(False);//是否后复权

Bool isRolloverRealPrice(False);//是否映射真实价格

Bool isAutoSwapPosition(False);//是否自动换仓

Bool ignoreSwapSiganlCalc(False); //是否忽略换仓信号计算

Integer countcs(1);//统计N个TICK

Vars

Bool bVarCondition_buy_1;

Numeric nVarPlotValue_buy_1_left;

Numeric nVarPlotValue_buy_1_right;

Series<Integer> sVarCondition_buy_upOrDown1(0,2);

Bool bVarCondition_buy_2;

Integer iVarSignal_Flag_Buy_1(0);

Numeric dVarPrice_buy_1;

Numeric dVarPrice_buy_1_volume;

Bool bVarCondition_sellShort_1;

Numeric nVarPlotValue_sellShort_1_left;

Numeric nVarPlotValue_sellShort_1_right;

Series<Integer> sVarCondition_sellShort_upOrDown1(0,2);

Bool bVarCondition_sellShort_2;

Integer iVarSignal_Flag_SellShort_2(0);

Numeric dVarPrice_sellShort_2;

Numeric dVarPrice_sellShort_2_volume;

Plot plt;

String tableName("BarTime");

Global Integer duochang(0);//多仓变量

Global Integer kenchang(0);//空仓变量

Global Integer jscs(0);//计数次数

Global Integer ksjs;//开始计数

Global Integer buysellshs;//统计N次tick内的买信号数

Global Integer sellshs;//统计N次tick内的卖信号数

Integer b(0);

Bool buybool;

Bool sellbool;

Array<String> symbols;

Global Integer Tickint(0);

   Global Integer barint(0);

Defs

Numeric Cond_Open(Integer barback = 0)

{

if(Frequency == "tick")

{

return Close[barback];

}

return Open[barback];

}

Integer Cond_round_volume(Numeric volume, Numeric price = 0)

{

Return IntPart(Round(volume / BaseShares(), 0))*BaseShares();

}

Bool Cond_LocalTimeLimit(Numeric bTime, Numeric eTime)

{

If(MakeDateTime(Date(),Time()) >= bTime And MakeDateTime(Date(),Time()) <= eTime)

{

Return True;

}

Return False;

}

Bool buy_condition_1()

{

nVarPlotValue_buy_1_left=GetPlotNumericValue("KDJ","J");

If(InvalidNumeric() == nVarPlotValue_buy_1_left)

{

Return False;

}

nVarPlotValue_buy_1_right=GetPlotNumericValue("KDJ","K");

If(InvalidNumeric() == nVarPlotValue_buy_1_right)

{

Return False;

}

If(nVarPlotValue_buy_1_left>nVarPlotValue_buy_1_right)

{

sVarCondition_buy_upOrDown1 = 1;

}

Else If(nVarPlotValue_buy_1_left<nVarPlotValue_buy_1_right)

{

sVarCondition_buy_upOrDown1 = -1;

}

Else

{

sVarCondition_buy_upOrDown1 = sVarCondition_buy_upOrDown1[1];

}

Return sVarCondition_buy_upOrDown1[1] == -1 && sVarCondition_buy_upOrDown1[0] == 1;

//Return True;

}

Bool buy_condition_2()

{

Return A_BuyPosition(0) == 0.000000;

}

Bool time_condition_Buy_1()

{

Return true;

}

Bool sellShort_condition_1()

{

nVarPlotValue_sellShort_1_left=GetPlotNumericValue("KDJ","J");

If(InvalidNumeric() == nVarPlotValue_sellShort_1_left)

{

Return False;

}

nVarPlotValue_sellShort_1_right=GetPlotNumericValue("KDJ","K");

If(InvalidNumeric() == nVarPlotValue_sellShort_1_right)

{

Return False;

}

If(nVarPlotValue_sellShort_1_left>nVarPlotValue_sellShort_1_right)

{

sVarCondition_sellShort_upOrDown1 = 1;

}

Else If(nVarPlotValue_sellShort_1_left<nVarPlotValue_sellShort_1_right)

{

sVarCondition_sellShort_upOrDown1 = -1;

}

Else

{

sVarCondition_sellShort_upOrDown1 = sVarCondition_sellShort_upOrDown1[1];

}

Return sVarCondition_sellShort_upOrDown1[1] == 1 && sVarCondition_sellShort_upOrDown1[0] == -1;

//Return True;

}

Bool sellShort_condition_2()

{

Return A_SellPosition(0) == 0.000000;

}

Bool time_condition_SellShort_2()

{

Return true;

}

Events

OnInit()

{

Range[0:DataCount()-1]

{

If(isRollover)

{

AddDataFlag(Enum_Data_RolloverBackWard());

}

If(isRolloverRealPrice)

{

AddDataFlag(Enum_Data_RolloverRealPrice());

}

If(isAutoSwapPosition)

{

AddDataFlag(Enum_Data_AutoSwapPosition());

}

If(ignoreSwapSiganlCalc)

{

AddDataFlag(Enum_Data_IgnoreSwapSignalCalc());

}


}}

OnBarClose(ArrayRef<Integer> indexs)

{

//用户业务逻辑

buysellshs=0;

jscs=0;

ksjs=0;

sellshs=0;

Tickint=0;

barint=barint+1;

}


OnBar(ArrayRef<Integer> indexs)

{Bool ret = GetLayerOrderMapSymbols(symbols);

Array<Integer> orders;

Range[0:DataCount()-1]

{  

Tickint=Tickint+1;

Bool boolls;

print("日期:"+text(Date()));

print ("tick计数:"+Text(Tickint));

print ("bar计数:"+Text(barint));

//print("多仓数:"+TEXT(duochang));

//print("空仓数:"+TEXT(kenchang));

Print("MarketPosition多空仓状态:" + Text(MarketPosition()));

bVarCondition_buy_1 = buy_condition_1();

bVarCondition_buy_2 = buy_condition_2();

dVarPrice_buy_1 = Cond_Open();

//dVarPrice_buy_1 = Open();

dVarPrice_buy_1_volume = Cond_round_volume(1.000000,dVarPrice_buy_1);

print ("buysellSHS:"+Text(buysellshs));

boolls= time_condition_Buy_1() and (bVarCondition_buy_1 and bVarCondition_buy_2) and buysellshs==0;

buybool=boolls or buysellshs==1;

//Print("BUYBOOL:" + buybool);

//PlotBool("BUYBOOL:",buybool);

if(buybool)

//if(time_condition_Buy_1() and buysellshs==0)

{

if(tickint>=1){

buysellshs=1;

print("onbar买卖信号数:"+TEXT(buysellshs));

if(kenchang>0 or (tickint>=2 and A_SellPosition()>0))

              { //Bool ret = A_BuyToCover(Symbol,dVarPrice_sellShort_2_volume,Open,orders,"","");

              if(Tickint>1)

              {A_BuyToCover(Symbol,dVarPrice_sellShort_2_volume,Close,orders,"","");}

             

              BuyToCover(dVarPrice_sellShort_2_volume,Close);

                print ("平空仓");

                kenchang=kenchang-1;

                //print("空仓="+TEXT(kenchang));

                }

//IF((buysellshs>0 and duochang==0) or (buysellshs>0 and MarketPosition()==0))  

//{

print("买卖信号:"+TEXT(buysellshs));

          //Bool ret = A_Buy(Symbol,dVarPrice_buy_1_volume,dVarPrice_buy_1,orders,"","");

       

          Buy(dVarPrice_buy_1_volume,dVarPrice_buy_1,iVarSignal_Flag_Buy_1);

         

            duochang =duochang+1;

            print ("开多仓");

//print("多仓="+TEXT(duochang));

//print("开仓价格"+TEXT(dVarPrice_buy_1));

//print("收盘价格"+TEXT(Close));

//}

               

  While(b<130)

   {

       b=b+1;

   }              

             

}

}

bVarCondition_sellShort_1 = sellShort_condition_1();

bVarCondition_sellShort_2 = sellShort_condition_2();

dVarPrice_sellShort_2 = Cond_Open();

//dVarPrice_sellShort_2 = Open();

dVarPrice_sellShort_2_volume = Cond_round_volume(1.000000,dVarPrice_sellShort_2);

boolls=time_condition_SellShort_2() and (bVarCondition_sellShort_1 and bVarCondition_sellShort_2) and buysellshs==0;

sellbool=boolls or buysellshs==-1;

if(sellbool)

{

if(tickint>=1){

buysellshs=-1;

//print("onbar买卖信号数:"+TEXT(buysellshs));

if(duochang>0 or (tickint>=2 and A_BuyPosition()>0))

              {  //Bool ret = A_Sell(Symbol,dVarPrice_sellShort_2_volume,Open,orders,"","");

              if(Tickint>1)

              {A_Sell(Symbol,dVarPrice_sellShort_2_volume,Close,orders,"","");}

              sell(dVarPrice_sellShort_2_volume,Close);

                print ("平多仓");                

                duochang=duochang-1;

               //print("多仓="+TEXT(duochang));

             

              }

//IF((buysellshs<0 and kenchang==0) or (buysellshs<0 and MarketPosition()==0))  

//{

//Bool ret = A_SellShort(Symbol,dVarPrice_sellShort_2_volume,dVarPrice_sellShort_2,orders,"","");

SellShort(dVarPrice_sellShort_2_volume,dVarPrice_sellShort_2,iVarSignal_Flag_Buy_1);

//print("卖出信号:"+TEXT(buysellshs));

kenchang=kenchang+1;

print("开空仓");

//print("空仓="+TEXT(kenchang));

//}

             

             

                           

  While(b<130)

   {

       b=b+1;

   }              

     

}

}

}

}

//------------------------------------------------------------------------

// 编译版本: 2024/12/12 212326

// 版权所有 yvhccss

// 更改声明 TradeBlazer Software保留对TradeBlazer平台

// 每一版本的TradeBlazer公式修改和重写的权利

//------------------------------------------------------------------------


策略编写的问题,可以发代码具体看

策略编写的问题不是应该一直有问题吗,为什么停止策略再开一次又可以了呢?

而且这外控制台输出的都是一个信号,但是实盘的会出现两个信号,不知道你们的信号处理到底是处么处理的,之前我以为是实盘发一次买卖就不会闪烁,后面你说让我去看基础,发现是要一直发买或者一直发卖才不会闪烁,但是现在是这么做的他还是会闪烁不知道你们的处理机制到底是怎么样的?