COCO研究院

 找回密碼
 註冊
搜索
查看: 2330|回復: 3

[範例程式碼] 請教前輩程式print問題

[複製鏈接]
發表於 13-1-17 17:33 | 顯示全部樓層 |閱讀模式
站上前輩,請教一下, 在HTS上寫策略時, 程式中有一個 print的的指令; 因剛接觸AB 不知AB程式語法中,是不是也有相同指令可以使用; 下面的樣本,若用AB應該怎麼寫, 煩請站上前輩可否指導指導; 感謝感謝~

1. value1 = H+L+C/2
2. value2 = MA5
3. value3 = MA10
4. 當價格穿越 MA10買進(箭號)
5. 當價格跌破 MA5賣出(箭號)

6. print value1
7. print value2
8. print value3

 樓主| 發表於 13-1-21 21:53 | 顯示全部樓層
不知沒有會的人可以教一下... 感激不盡!!
發表於 13-1-22 00:48 | 顯示全部樓層
QooQ 發表於 13-1-21 21:53
不知沒有會的人可以教一下... 感激不盡!!

* 小弟來幫一下大大好了


barcomplete = BarIndex() < LastValue(BarIndex());

_SECTION_BEGIN("Background_Setting");
SetChartBkColor(1);
SetChartOptions(2,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartBkGradientFill(1, 1, 1);
GraphXSpace = Param("Zoom/In Out",100,-50,150,1);
dist = 2*ATR(15);
_SECTION_END();

SetPositionSize(1, spsShares);
SetOption("InitialEquity", 1000000);
SetOption("FuturesMode", 1);
SetOption("CommissionMode", 3);
SetOption("CommissionAmount", 1000);
RoundLotSize = 1;
PointValue = 200;


Buy = Cross( (H+L+C)/3, MA(C,10) ) AND barcomplete;
Short = Cross( MA(C,5), (H+L+C)/3 ) AND barcomplete;

Buy = Cover = ExRem(Buy, Short);
Short = Sell = ExRem(Short, Buy);

BuyPrice = CoverPrice = C;
ShortPrice = SellPrice = C;

Position = IIf(Buy, 1, IIf(Short, -1, 0));
CurrentPosition = ValueWhen(Position!=0, Position, 1);
IsCPNull = IsNull(CurrentPosition);

MarketPosition = IIf(Cum(Buy+Short)==0, 0, IIf(IsCPNull!=1, IIf(CurrentPosition==1, 1, -1), 0));

_SECTION_BEGIN("Charts");
PlotOHLC( O, H, L, C, "", IIf(MarketPosition == 0, 0, IIf(MarketPosition>0, colorRed, colorGreen)), styleBar|styleNoLabel);
PlotShapes(IIf(Buy, 59, shapeNone), 7, 0, WMA(O,10)-dist, 6);  
PlotShapes(IIf(Short, 60, shapeNone), 7, 0, WMA(O,10)+dist, 0);
_SECTION_END();



---
HTS 裡的 print

在 AB 裡是 printf

參考看看吧

 樓主| 發表於 13-1-22 20:41 | 顯示全部樓層
kilroy前輩 謝謝~

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-11-22 17:08

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 |