龙听期货论坛's Archiver

C
+
+


 微信: QQ:

龙听 发表于 2019-3-22 21:26

[常见问题] 全局变量GV运用方法 [MC]

[b]询内容:[/b][color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px] 附件中有两段指标代码[/size][/font][/color]
[color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]GVset :[/size][/font][/color][list=1][*]vars:GVset("test");//定义字符串类型[*][*]if time = 1000 then[*]value1=average(open,10);[*][*]value2= average(close,10);[*][*]condition1= value2 cross over value1;[*]condition2=value2 cross under value1;[*]GVSetNamedDouble(Gvset,0);[*]if condition1 then GVSetNamedDouble(Gvset,1);//把1存到 “test”里面[*]if condition2 then GVSetNamedDouble(gvset,-1);//把-1存到“test”里面[*][*]plot1(value1);[*]plot2(value2);[*][*]//set可以把值 1 或者-1 或者其他变量赋值给一个字符标识的空间“test”[/list][color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]复制代码[/size][/font][/color][color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]------------------------------[/size][/font][/color]
[color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]GVget:[/size][/font][/color][list=1][*]var:GVget("test");[*]value1=GVGetNamedDouble("test",-9999);[*]plot1(value1,"test");[*][*]//通过get 获取 “test”里面存的值,并且放在value1中供程序使用,如果test里没有存任何东西的话,value1就等于-9999[/list][color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]复制代码[/size][/font][/color][color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]GV这种函数只能用在实时行情中,用MC回放也有效果。[/size][/font][/color]

[color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]基本架构就是这样。[/size][/font][/color]
[color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]再放大一些,如果交易多种商品,只允许一种商品进场的话,就可以用全局变量来控制是否要交易其他商品。[/size][/font][/color]

[color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]可能有其他的用法,不才没有想到。[/size][/font][/color]
[color=#212121][font=宋体, Arial, Helvetica, sans-serif][size=14px]大家也可以构思一下。[/size][/font][/color]

页: [1]