Today's the day

向软件大牛炫耀我会焊单片机,向硬件大牛炫耀我会写 Rails,向软硬件大牛炫耀我生物,向软硬件生物大牛炫耀我会折腾期货 -_-bbb

C# 已经成为自动交易的标准了?
从 EasyLanguage 迁移到 MC .NET (二):发送订单

从 EasyLanguage 迁移到 MC .NET (一):基本结构

galeki posted @ 2012年9月04日 03:18 in 交易 with tags MC-NET , 7057 阅读

Multicharts .NET 虽然已经正式发布了(以下简称 MC .NET),但是官方坦言说现在只能算是 public beta 的阶段,还是有一些 bugs,所以要想实盘交易还是再等等吧,正好趁这段时间把策略移植过来。

花了很长时间把原来的策略改写为  .NET 版本,官方的文档太少,可以参考的只有 help 文件和自带的例子,还好自己用的策略并不复杂,基本上都已经搞定,这里记录一下基本的迁移方法,如果你已经有现成的 EasyLanguage/PowerLanguage (以下简称 EL)策略,那么照着这个过程基本上可以把大致框架迁移过来。

注:这里的迁移主要指的是交易策略代码的迁移,也就是 Signal,至于 Indicator 和Function,和 Signal 大同小异,参照着来就可以了。


在 EL 里,基本的策略代码结构像下面这样(once 的语法似乎只在 PowerLanguage 中才有):


once begin
	// code executed only once

// strategy code starts here ...

而在 MC .NET 中,基本的结构像是这样:

namespace PowerLanguage.Strategy {
	public class Test1 : SignalObject {
		// Inputs:
		private int m_input1 = 0;  
        public int Input1{
            get { return m_input1; }
            set { m_input1 = value; }
		// Vars:
		private int var1 = 0;
		private int var2 = 0;
		public Test1(object _ctx):base(_ctx){}  // default constructor  
		protected override void Create() {
			// create variable objects, function objects, order objects etc.
			// executed only once
		protected override void StartCalc() {
			// code executed only once
		protected override void CalcBar(){
			// strategy code start here ...


  • 参数 Inputs 对应为 getter setter 属性,并在之前声明 [Input],这样才会被 MC 识别出来。
  • 策略运行时的变量 Vars,直接声明成 private 变量。
  • 默认生成的同名构建函数(第 16 行),无需改动。
  • 基本的函数有三个:Create、StartCalc、CalcBar
    • Create:在策略初始化之前调用,只执行一次,一般在这里初始化各种变量和对象。
    • StartCalc:相当于 EL 的 once,在策略初始化之后只执行一次,一般在这里检查运行环境和设置变量的默认值。
    • CalcBar:相当于 EL 的主程序代码,再每一个 bar/tick 更新之后自动调用。



  • 无匹配
happy wheels 说:
2017年11月11日 14:44

还好自己用的策略并不复杂,基本上都已经搞定,这里记录一下基本的迁移方法,如果你已经有现成的 EasyLanguage/PowerLanguage (以下简称 EL)策略,那么照着这个过程基本上可以把大致框架迁移过来。!!!

wings io 说:
2018年3月26日 17:50

Good article and knowledge for me! I found a lot of information here! This article is really good for all newbie here. Thank you for sharing with us!

sushi cat 2 说:
2018年5月16日 17:03

I'm happy about everything you bring it very interesting and helpful, thanks

essay help 说:
2018年6月11日 18:57

The UK is pretty easy to migrate to. You have to live here for three years, speak French or English and then pass a little test about UK. Plus UK is right beside the US and so you can visit family members still in the US, and the culture and way of life is very similar too 说:
2018年6月19日 03:06

And the survey will be simple to access and it will take only a few minutes of your time. In the survey, you need to answer the few simple questions about your experience during your visit to Wendy’s restaurant.

marketing assignment 说:
2018年7月05日 18:26

Awesome article, I am a noteworthy fan in setting comments on weblogs to help the blog writers understand that they have added something of unfathomable preferred standpoint to the web!

zombs royale 说:
2018年7月25日 14:44

Thank you for posting such a great article! I found your website perfect for my needs.
It contains wonderful and helpful posts. Keep up the good work!

Imlive free credits 说:
2018年8月25日 04:51

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. giveaways

onlinecasinohex 说:
2018年9月09日 00:09

We're glad to have read this post. Please keep up the good work.

Mutilate A Doll 2 说:
2018年10月05日 12:31

Great info. I love all the posts, I really enjoyed, I would like more information about this, because it is very nice., Thanks for sharing.

hotmail login 说:
2018年12月01日 17:22

Your sharing is great. I am they are a lot of things from your article. That is a very interesting experience

duck life space 说:
2018年12月10日 17:22

I really like your website and specially this post and that's the reason I am commenting here

Bad Ice Cream 说:
2019年1月31日 17:06

Your idea is very good. It coincides with my point of view. Looking forward to reading more of your posts

bullet force 说:
2019年3月18日 16:40

Don’t ever give up on your blogs as they are a source of happiness for the people. Keep sharing. Thank you. 说:
2019年4月02日 17:36

This is amazing information. Thanks for sharing.

pixel gun 3d 说:
2019年6月14日 00:40

I save the code. It helps me much.

fnaf 说:
2019年7月06日 18:37

I have read your article, I find the content quite interesting and detailed, I hope in the near future, you will have more interesting and meticulous articles to give readers insight. More about this issue, Thank you for sharing this article.

run 3 说:
2019年7月11日 17:43

Nice Post!! Thanks for sharing! We are reputed online pharmacy where you can shop all Medicine products, Sildenafil Tablets, Tramadol 50mg,etc. We Deals in Best Generic Health product in United States.

登录 *

loading captcha image...
or Ctrl+Enter