Today's the day

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

从 EasyLanguage 迁移到 MC .NET (一):基本结构
从 EasyLanguage 迁移到 MC .NET (三):常用 EasyLanguage 函数写法

从 EasyLanguage 迁移到 MC .NET (二):发送订单

galeki posted @ 2012年9月04日 22:34 in 交易 with tags MC-NET , 6680 阅读

发送订单

在 MC .NET 中,发送买卖的订单要比 EL 中麻烦很多,最主要的区别在于,要事先为策略中所有可能会用到的订单建立订单对象,不同类型的订单(例如 Limit、Stop、Market)在创建订单对象的时候要指定不同的参数。

开仓

发送开仓订单在 EL 中的写法是这样的:

Buy next bar at 1200.5 limit;  // Limit Order
Buy next bar at 1234.5 stop;   // Stop Order
Buy next bar at market;        // Market Order

在 MC .NET 中就要麻烦一些,步骤如下:

  1. 首先为这个订单声明一个 IOrderPriced(如果是 market 单就是 IOrderMarket) 变量。
  2. 在 Create 函数中,为这个订单创建实例。
  3. 在 CalcBar 函数中发送订单。
namespace PowerLanguage.Strategy {
    public class test2 : SignalObject {
        public test2(object _ctx):base(_ctx){}
        
        private IOrderPriced buy_limit_order;  // Limit Order
        private IOrderPriced buy_stop_order;   // Stop Order
        private IOrderMarket buy_market_order; // Market Order
        

        protected override void StartCalc() {
            
        }
        protected override void CalcBar(){
            // ...
            buy_limit_order.Send(1200.5);
            buy_stop_order.Send(1234.5);
            buy_market_order.Send();
            // ...
        }
    }
}

平仓

平仓单在 EL 中的写法是这样的:

sell next bar at market;
buytocover next bar at market;

在 MC .NET 中,平仓单和上面的开仓单的写法完全一样,区别只在于在 Create 函数中,把参数设置为 EOrderAction.Sell 或 EOrderAction.BuyToCover:

...
        protected override void Create() {
            // ...
            sell_order =         OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.Sell));
            buytocover_order =   OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.BuyToCover));
        }
...

Limit 和 Stop 的平仓单同理。

指定手数

上面的例子并没有设置买卖的手数,所以默认买卖的手数为策略设置中的默认值,如果想要指定手数要怎么写呢?

在 EL 中,指定手数(比如买 5 手)的写法如下:

Buy 5 shares next bar at 1234.5 stop;

在 MC .NET 中要:

  1. 在 Create 函数中创建订单对象时,第一个参数要设置为 Contracts.UserSpecified,这样才可以指定手数。
  2. 在发送订单的 Send 函数中指定具体的手数。
...
	protected override void Create() {
		// ...
		buy_stop_order =   OrderCreator.Stop(new SOrderParameters(Contracts.UserSpecified, EOrderAction.Buy))

	}
...

	protected override void CalcBar(){
		// ...

		buy_stop_order.Send(1234.5, 5);

		// ...
	}

 

  • 无匹配
geometry dash 说:
2017年11月11日 14:43

在 Create 函数中,为这个订单创建实例。!

color switch 说:
2017年11月11日 14:52

If any page has quality posts like yours then I will search for information very quickly. Please donate again

usps tracking 说:
2018年3月30日 18:11

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!

return man 3 game 说:
2018年5月17日 14:52

Your article is very interesting. I think this article has a lot of information needed, looking forward to your new posts. Get permission to share:

Potty Racers 说:
2018年5月17日 18:00

The article you have shared here very awesome. I really like and appreciated your work. I read deeply your article, the points you have mentioned in this article are useful

Jenry 说:
2018年6月01日 10:05

Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up.

ludo king 说:
2018年6月01日 10:06

Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up.

homedepot opinion 说:
2018年6月19日 03:04

This survey clearly measures the customer satisfaction. Also, the customers can openly share their views, ideas, and opinions. And, in case if feedback is negative or if customers are not satisfied then the company will make the necessary changes in their products and service offerings.

Hotmail Entrar 说:
2018年6月22日 15:26

Some problems are difficult to solve, but I will try. I have a part time job to cover life. Learning by doing is very tired, but it's my life.

color switch 说:
2018年7月11日 15:06

Although very difficult, but I think to accept the truth. My children it affected a lot, we have moved to a new place and is gradually adapting to it.

baby names 说:
2018年7月30日 13:46

The article you have shared here very awesome. I really like and appreciated your work. I read deeply your article, the points you have mentioned in this article are useful

192.168.l.l 说:
2018年8月10日 15:38

I like to get up early to go out and breathe fresh air. I feel that it is good for health and a good habit

Download Mr. Square 说:
2018年10月20日 16:27

great post. i like it. feeling great when reading your post .

Slope Game 说:
2018年10月31日 11:21

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

super mario crossove 说:
2018年11月30日 11:41

Thank you for sharing valuable information. Nice post. I enjoyed reading this post.

outlook entrar 说:
2018年11月30日 11:41

great post. i like it. feeling great when reading your post

basketball legends 说:
2018年11月30日 11:42

I would like to thank you for your nicely written post

temple run 3 说:
2018年12月01日 12:40

Your writing impresses me deeply, and I hope you will have more good articles in the future to give readers a new perspective on life.

youtube to mp3 说:
2018年12月01日 15:53

You’ve written nice post, I am gonna bookmark this page, thanks for info. I actually appreciate your own position and I will be sure to come back here.

MangaFox 说:
2018年12月01日 17:21

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

red ball 说:
2018年12月06日 15:22

I really impressed after read this because of some quality work and informative thoughts .

bouncing balls 说:
2018年12月06日 15:22

I just wanna say thanks for the writer and wish you all the best for coming

super smash flash 2 说:
2018年12月07日 10:59

I understand what you bring it very meaningful and useful, thanks.

fireboy and watergir 说:
2018年12月10日 12:30

I found a lot of information here to create this actually best for all newbie here. Thank you for this information.

MangaFox 说:
2018年12月10日 17:19

I used to visit this website because of this web page content genuine information

FNAF Games 说:
2018年12月11日 12:39

Thanks for sharing. I hope it will be helpful for too many people that are searching for this topic.

Geometry Dash 说:
2018年12月12日 15:03

This article is really fantastic and thanks for sharing the valuable post

Moto X3M 说:
2018年12月20日 10:06

Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.

happy wheels 说:
2018年12月27日 17:03

This blog has all the information for programmer. Thanks for sharing it. 

happy wheels space 说:
2018年12月27日 17:05

Great read. Thanks for this post. Worth reading and sharing. 

happy wheels space 说:
2018年12月27日 17:06

 

Great read. Thanks for this post. Worth reading and sharing. 

 

 

happy wheels space 说:
2018年12月27日 17:07

Its so great to read and findout about this programming blog. Thanks for sharing. 

red ball 说:
2019年1月05日 14:43

Thank you for sharing this exciting resource with me and the world. Wish you always luck.

Return Man 3 说:
2019年1月05日 16:51

I like to get up early to go out and breathe fresh air. I feel that it is good for health and a good habit

punter 说:
2019年1月16日 12:17

Hiii
There are times when you need more than one monitor to complete the task quickly and rapidly.you can enhance your workflow in window 10.
you can learn here how to create dual monitor in window 10 by a simple click.

Happy Wheels 说:
2019年1月26日 12:45

When I'm sad I usually play games. It will make me more comfortable. I like to spend time like that

happy wheels 说:
2019年1月26日 12:45

I often get emotionally involved. Like when I read your post, I can cry, laugh, sad, funny, depending on your written words. I think you are a sensitive person.

run 3 说:
2019年1月31日 17:05

Please treat each other well. Everybody has difficulties that we have to overcome, do not know later but how to live each day happily.

atari breakout 说:
2019年1月31日 17:05

I think you are right to say so. Your share is great, I found a lot of things in your post

Sushi Cat 2 说:
2019年1月31日 17:06

It is easy to understand, detailed and meticulous! I have had a lot of harvest after watching this article from you! I feel it interesting, your post gave me a new perspective!

helix jump 说:
2019年2月13日 17:21

Absolutley amazing camerawork and editing. Truly stunning

friv4school 说:
2019年3月07日 10:42

I like your post, there are lots of new things I learned. Thanks for sharing the post.

Outlook Entrar 说:
2019年3月09日 14:48

This post is very wonderful, very its depth and add

Five Nights At Fredd 说:
2019年3月09日 14:51

Not all are true. Everyone has their own way of thinking but I think they have to reconsider. I like to argue for the most accurate results.

complete kodi setup 说:
2019年3月19日 18:39

We can assist you with Kodi Setup wizard, so if you are looking to setup your Kodi for the first time, then you can take our help.

belkin n300 setup 说:
2019年3月20日 15:42

We even have a live chat support system which available 24X7 for providing assistance in the process of Belkin extender setup.

alex1999 说:
2019年6月01日 15:54

Different students have different requirements. If someone needs essay writing help, https://printersupportnumber.com/hewlett-packard-support/
another might require case study help. But every assignment help provider has a specific area of specialty. The reviews on this website help students to select the service as per their requirement
It is very good, but look at the information at this address.
This is very appealing, however , it is very important that will mouse click on the connection
A simple show of appreciation goes a long way for those people that work behind the to day to keep our community clean" Respect appreciation for them,,,,,
This is a very great post and the way you are doing so is so good.

alex1999 说:
2019年6月01日 15:55

Different students have different requirements. If someone needs essay writing help, https://printersupportnumber.com/hewlett-packard-support/
another might require case study help. But every assignment help provider has a specific area of specialty. The reviews on this website help students to select the service as per their requirement
It is very good, but look at the information at this address.
This is very appealing, however , it is very important that will mouse click on the connection
A simple show of appreciation goes a long way for those people that work behind the to day to keep our community clean" Respect appreciation for them,,,,,
This is a very great post and the way you are doing so is so good.

phone number 说:
2019年6月01日 15:58

This is a very great post and the way you are doing so is so good.

phone number 说:
2019年6月01日 15:58

This is a very great post and the way you are doing so is so good.

Dell printer support 说:
2019年6月01日 15:59

This is a very great post and the way you are doing so is so good.

hp printer service 说:
2019年6月01日 16:00

This is a very great post and the way you are doing so is so good.

canon professional s 说:
2019年6月01日 16:01

This is a very great post and the way you are doing so is so good.

www.contacthelpsuppo 说:
2019年6月01日 16:01

This is a very great post and the way you are doing so is so good.

aol desktop 9 7 down 说:
2019年6月01日 16:02

This is a very great post and the way you are doing so is so good.

how to print from ip 说:
2019年6月01日 16:43

This is a very great post and the way you are doing so is so good.

hp laptop customer s 说:
2019年6月01日 16:44

This is a very great post and the way you are doing so is so good.

amazon video custome 说:
2019年6月01日 16:44

This is a very great post and the way you are doing so is so good.

could not contact th 说:
2019年6月01日 16:45

This is a very great post and the way you are doing so is so good.

hewlett packard comp 说:
2019年6月01日 16:46

This is a very great post and the way you are doing so is so good.

lexmark printer driv 说:
2019年6月01日 16:46

This is a very great post and the way you are doing so is so good.

webroot antivirus 说:
2019年6月01日 16:47

This is a very great post and the way you are doing so is so good.

david05 说:
2019年6月18日 19:27

https://www.technical-help-support.com/device-support/alexa-support/
https://www.technical-help-support.com/email-support/att-email-support/
https://www.technical-help-support.com/device-support/arlo-support/
https://www.technical-help-support.com/email-support/roadrunner-email-support/
https://www.technical-help-support.com/email-support/sbcglobal-email-support/
https://www.technical-help-support.com/email-support/bellsouth-email-support/
https://www.technical-help-support.com/device-support/roku-support/
https://www.technical-help-support.com/device-support/garmin-support/
https://www.technical-help-support.com/device-support/kindle-support/
https://www.technical-help-support.com/device-support/tomtom-support/
https://www.technical-help-support.com/hp-support/hp-tech-support/
https://www.technical-help-support.com/device-support/netflix-support/
https://www.technical-help-support.com/router-support/cisco-support/
https://www.technical-help-support.com/device-support/
https://www.technical-help-support.com/router-support/linksys-support/
https://www.technical-help-support.com/email-support/gmail-support/
https://www.technical-help-support.com/email-support/yahoo-mail-support/
https://www.technical-help-support.com/router-support/netgear-support/
https://www.technical-help-support.com/quickbooks-support/quickbooks-upgrade/
https://www.technical-help-support.com/quickbooks-support/quickbooks-cost/
https://www.technical-help-support.com/quickbooks-support/quickbooks-license/
https://www.technical-help-support.com/quickbooks-support/buy-quickbooks/
https://www.technical-help-support.com/quicken-support/buy-quicken/
https://www.technical-help-support.com/quickbooks-support/quickbooks-pricing/
https://www.technical-help-support.com/quickbooks-support/quickbooks-discount/
https://www.technical-help-support.com/quickbooks-support/quickbooks-technical-support/
https://www.technical-help-support.com/quickbooks-support/quickbooks-help/
https://www.technical-help-support.com/router-support/
https://www.technical-help-support.com/microsoft-support/microsoft-activation-support/
https://www.technical-help-support.com/quickbooks-support/quickbooks-payroll-support/
https://www.technical-help-support.com/quickbooks-support/quickbooks-customer-service/
https://www.technical-help-support.com/quicken-support/quicken-customer-service/
https://www.technical-help-support.com/quickbooks-support/quickbooks-phone-number/
https://www.technical-help-support.com/quicken-support/quicken-technical-support/
https://www.technical-help-support.com/quicken-support/quicken-bill-pay-support/
https://www.technical-help-support.com/quicken-support/quicken-online-support/
https://www.technical-help-support.com/quickbooks-support/quickbooks-online-support/
https://www.technical-help-support.com/quicken-support/quicken-help/
https://www.technical-help-support.com/email-support/
https://www.technical-help-support.com/apple-support/icloud-support/
https://www.technical-help-support.com/quickbooks-support/quickbooks-enterprise-support/
https://www.technical-help-support.com/quicken-support/quicken-phone-number/
https://www.technical-help-support.com/quickbooks-support/intuit-quickbooks-support/
https://www.technical-help-support.com/pogo-support/pogo-screen-size-problem/
https://www.technical-help-support.com/microsoft-support/microsoft-help/
https://www.technical-help-support.com/microsoft-support/microsoft-phone-support/
https://www.technical-help-support.com/microsoft-support/microsoft-contact/
https://www.technical-help-support.com/hp-support/hp-contact-number/
https://www.technical-help-support.com/hp-support/hp-computer-support/
https://www.technical-help-support.com/microsoft-support/microsoft-number/
https://www.technical-help-support.com/hp-support/hp-phone-number/
https://www.technical-help-support.com/pogo-support/pogo-games-flash-error/
https://www.technical-help-support.com/microsoft-support/microsoft-technical-support/
https://www.technical-help-support.com/hp-support/hp-printer-support/
https://www.technical-help-support.com/microsoft-support/microsoft-telephone-support/
https://www.technical-help-support.com/hp-support/hp-laptop-support/
https://www.technical-help-support.com/microsoft-support/microsoft-customer-service/
https://www.technical-help-support.com/hp-support/hp-help/
https://www.technical-help-support.com/apple-support/apple-help-number/
https://www.technical-help-support.com/pogo-support/pogo-games-java-problem/
https://www.technical-help-support.com/hp-support/hp-customer-service/
https://www.technical-help-support.com/quickbooks-support/
https://www.technical-help-support.com/quicken-support/
https://www.technical-help-support.com/pogo-support/
https://www.technical-help-support.com/apple-support/apple-id-support/
https://www.technical-help-support.com/apple-support/macintosh-support/
https://www.technical-help-support.com/apple-support/macbook-support/
https://www.technical-help-support.com/
https://www.technical-help-support.com/hp-support/
https://www.technical-help-support.com/apple-support/apple-ipad-support/
https://www.technical-help-support.com/pogo-support/pogo-technical-support/
https://www.technical-help-support.com/apple-support/itunes-support/
https://www.technical-help-support.com/apple-support/mac-support/
https://www.technical-help-support.com/pogo-support/pogo-customer-service/
https://www.technical-help-support.com/apple-support/apple-customer-service/
https://www.technical-help-support.com/apple-support/iphone-support/
https://www.technical-help-support.com/apple-support/apple-tech-support/
https://www.technical-help-support.com/microsoft-support/microsoft-outlook-support/
https://www.technical-help-support.com/microsoft-support/microsoft-office-support/
https://www.technical-help-support.com/microsoft-support/microsoft-windows-support/
https://www.technical-help-support.com/apple-support/
https://www.technical-help-support.com/microsoft-support/

asasaas 说:
2019年6月18日 21:44

csadaihhf iefiw ehf
e wf
e wipf
wirghr
eih

asasaawefewdwewer re 说:
2019年6月18日 21:45

93rv829e7vgr98t71bey7t8b
7ytr7
8yb7rtb
y7rtb2y68r7

meliodas 说:
2019年6月25日 10:10

The day passed quickly and I realized I couldn't forget -> geometry dash -> basketball legends

funeral-car 说:
2019年6月26日 18:12

I am glad to see this brilliant post. all the details are very helpful and useful for us, keep up to good work.

funeral-homes 说:
2019年6月26日 18:12

I am pleased to find this website, you have shared very informative article which i like reading.I will come back to the website to read more similar content.

avg-support 说:
2019年6月26日 18:14

This is a very great post and the way you express your all post details that is too good.thanks for sharing with us this useful post..

mcafee-support 说:
2019年6月26日 18:15

Thanks for publishing this details. I simply wish to let you know that I just look into your site and also I locate it really fascinating and useful.

cisco-support-number 说:
2019年6月26日 18:16

I am pleased to find this website, you have shared very informative article which i like reading.I will come back to the website to read more similar content.

vex 说:
2019年7月06日 18:36

I appreciate it !. I really like it when people are together and sharing ideas. Great site, keep up the good work !. Either way, the web is great and I look forward to seeing it grow over time. Thanks very much.

meilleur chirurgie o 说:
2019年7月08日 17:34

chirurgie obésité Tunisie<br>
<a href="https://clinique-obesite-tunisie.fr/">chirurgie bariatrique tunisie</a><br>
<a href="https://clinique-obesite-tunisie.fr/sleeve-gastrectomie-tunisie/">sleeve tunisie</a><br>
<a href="https://clinique-obesite-tunisie.fr/bypass-tunisie/">bypass tunisie tarif</a><br>
<a href="https://clinique-obesite-tunisie.fr/ballon-gastrique-tunisie/">ballon gastrique tunisie</a><br>
<a href="https://clinique-obesite-tunisie.fr/anneau-gastrique-tunisie/">anneau gastrique tunisie prix pas cher</a><br>

meilleur chirurgie o 说:
2019年7月08日 17:35

chirurgie obésité Tunisie
<a href="https://clinique-obesite-tunisie.fr/">chirurgie bariatrique tunisie</a>
<a href="https://clinique-obesite-tunisie.fr/sleeve-gastrectomie-tunisie/">sleeve tunisie</a>
<a href="https://clinique-obesite-tunisie.fr/bypass-tunisie/">bypass tunisie tarif</a>
<a href="https://clinique-obesite-tunisie.fr/ballon-gastrique-tunisie/">ballon gastrique tunisie</a>
<a href="https://clinique-obesite-tunisie.fr/anneau-gastrique-tunisie/">anneau gastrique tunisie prix pas cher</a>

meilleur chirurgie o 说:
2019年7月08日 17:36

chirurgie obésité Tunisie <a href="https://clinique-obesite-tunisie.fr/">chirurgie bariatrique tunisie</a>

meilleur chirurgie o 说:
2019年7月08日 17:37

[url=https://clinique-lipofilling-tunisie.com]lipofilling tunisie[/url]


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter