一个回调挂单开仓的一个程序
//------------------------------------------------------------------------ // 简称: stream_20250523 // 名称: // 类别: 策略应用 // 类型: 用户应用 // 输出: Void //------------------------------------------------------------------------ Params Integer lots(1); Vars Series<Numeric> HH; Series<Numeric> LL; Series<Numeric> b_count; Series<Numeric> s_count; Series<Numeric> trigger_price; Bool B; bool S; Events //Bar更新事件函数,参数indexs表示变化的数据源图层ID数组 OnBar(ArrayRef<Integer> indexs) { If(BarStatus==0) { b_count = 10000; s_count = 10000; } HH = Highest(High, 3); LL = Lowest(Low, 3); plotnumeric("HH", HH, 0, red); plotnumeric("LL", LL, 0, green); B = Close[1] > Open[1] AND Close[1] > HH[2]; S = Close[1] < Open[1] AND Close[1] < LL[2] ; If(B and MarketPosition<>1) { b_count = 0; trigger_price = low[1]+(high[1]-low[1])/2; } If(s and MarketPosition<>-1) { s_count = 0; trigger_price = low[1]+(high[1]-low[1])/2; } b_count = b_count + 1; s_count = s_count + 1; Commentary("b_count:"+text(b_count)); Commentary("s_count:"+text(s_count)); Commentary("trigger_price:"+text(trigger_price)); //计数器在3以内,包含3,没有多单,最低价触碰到触发价格,在触发价格发信号 If(b_count<=3 and MarketPosition<>1 and low<=trigger_price) { buy(lots, min(open, trigger_price)); } If(s_count<=3 and MarketPosition<>-1 and high>=trigger_price) { sellshort(lots, max(open, trigger_price)); } } //------------------------------------------------------------------------ // 编译版本 2025/7/3 153857 // 版权所有 kyover // 更改声明 TradeBlazer Software保留对TradeBlazer平台 // 每一版本的TradeBlazer策略修改和重写的权利 //------------------------------------------------------------------------