MC- 挂单STOP交易
using System;using System.Drawing;using System.Linq;using PowerLanguage.Function;using ATCenterProxy.interop;namespace PowerLanguage.Strategy{ public class Example_StopLimit : SignalObject { private IOrderMarket buyMarketOrder, sellMarketOrder; private IOrderStopLimit sellStopLimitOrder; private double sellStopPrice, sellLimitPrice; public Example_StopLimit(object _ctx) : base(_ctx) { } protected override void Create() { buyMarketOrder = OrderCreator.MarketNextBar(new SOrderParameters( Contracts.Default, "EnterLong", EOrderAction.Buy)); sellMarketOrder = OrderCreator.MarketNextBar(new SOrderParameters( Contracts.Default, "ExitLong", EOrderAction.Sell)); sellStopLimitOrder = OrderCreator.StopLimit(new SOrderParameters( Contracts.Default, "StopLMT", EOrderAction.Sell)); } protected override void StartCalc() { Output.Clear(); // Clear PowerLanguage Editor output tab } protected override void CalcBar() { // When flat, enter long on first bar of day if ((StrategyInfo.MarketPosition == 0) && (Bars.Time[0].Date != Bars.Time[1].Date)) { buyMarketOrder.Send(); sellStopPrice = Bars.Low[0] - Bars.Range(); sellLimitPrice = Bars.Low[0] - (Bars.Range() * 1.5); Output.WriteLine("{0} - Buy order submitted. Sell stop calculated @ {1} with limit {2}", Bars.Time[0].ToString("d-M HH:mm:ss"), sellStopPrice, sellLimitPrice); } // Long order management if (StrategyInfo.MarketPosition > 0) { // Submit the stop-limit order as long as there is an open position sellStopLimitOrder.Send(sellStopPrice, sellLimitPrice); Output.WriteLine("{0} - Submitting sell stop @ {1} with limit {2}", Bars.Time[0].ToString("d-M HH:mm:ss"), sellStopPrice, sellLimitPrice); // Time stop; exit the position after 15 bars double barsInPosition = Bars.CurrentBar - CurrentPosition.OpenTrades[0].EntryOrder.BarNumber; if (barsInPosition >= 15) { sellMarketOrder.Send(); Output.WriteLine("{0} - Position open for {1} bars, submitting exit long market order", Bars.Time[0].ToString("d-M HH:mm:ss"), barsInPosition); } } } }}
|
MC- 挂单STOP交易的更多相关文章
- 转载自 BotVS 「 珍藏版 」如何搭建一个完整的交易框架
[img]http://dn-filebox.qbox.me/8c218c119046b2a25df2d9c7b00c1e0fa6899bdd.png[/img]NO:01 交易策略 ≠ 交易系统. ...
- 量化交易中VWAP/TWAP算法的基本原理和简单源码实现(C++和python)(转)
量化交易中VWAP/TWAP算法的基本原理和简单源码实现(C++和python) 原文地址:http://blog.csdn.net/u012234115/article/details/728300 ...
- 券商VIP交易通道
打新不成就炒新.随着新股发行上市的再次重启,巨大的获利机会引来投资者的争相竞逐,可并非所有投资者都能抢到新股筹码.“每天都在涨停板追这些新股,但从来没有买到过.”证券时报记者在采访中听到不少中小散户如 ...
- vnpy交易学习接口(2)
#来源于github下载vnpy版本 20180413 11.多投资标的情况下,该如何修改? 10.stop和limit报单有什么区别呢? 在交易时用得最多的是二类定单,第一类是市价单(Market ...
- 高频交易算法研发心得--MACD指标算法及应用
凤鸾宝帐景非常,尽是泥金巧样妆. 曲曲远山飞翠色:翩翩舞袖映霞裳. 梨花带雨争娇艳:芍药笼烟骋媚妆. 但得妖娆能举动,取回长乐侍君王. [摘自<封神演义>纣王在女娲宫上香时题的诗] 一首定 ...
- Oracle交易流水号问题
需求:生成交易流水号,每次新增一条记录时都自动加1,且流水号形式为000000001形式的10位数字. 思路:利用序列可以生成自增的流水号,只需要在前面添加N个0即可,同时,由于数字的长度一定,因此可 ...
- android/java 根据当前时间判断股票交易状态(未开盘 交易中 休市中 已收盘)
/** * @param data yyyy-MM-dd HH:mm:ss 时间 * @return 未开盘 交易中 休市中 已收盘 */ public static String getSotckS ...
- 微信JSApi支付~订单号和微信交易号
返回目录 谈谈transactionId和out_trade_no 前一篇微信JSApi支付~坑和如何填坑文章反映不错,所以又写了个后篇,呵呵. 每个第三方在线支付系统中都会有至少两类订单号,其一为支 ...
- python 优矿自动化交易
一.进入官网,打开notebook 自己新建 notebook 二.在代码中编写自己的交易策略 https://uqer.io/help/faqApi/#account相关属性 在帮助文档中可以找到 ...
- [python]初试页面抓取——抓取沪深股市交易龙虎榜数据
[python]抓取沪深股市交易龙虎榜数据 python 3.5.0下运行 没做自动建立files文件夹,需要手动在py文件目录下建立files文件夹后运行 #coding=utf-8 import ...
随机推荐
- IIS 批处理 bat
c:\windows\system32\inetsrv\AppCmd.exe stop apppool /apppool.name:"ASP.NET 4.0"c:\windows\ ...
- AForge.net 使用之录像拍照功能实现
连接摄像头设备,这里需要引入 AForge.Video; AForge.Video.DirectShow; AForge.Video.FFMPEG; 还需要添加引用,aforge.dll,aforge ...
- CodeForces 645D Robot Rapping Results Report
二分,拓扑排序. 二分答案,然后进行拓扑排序检查,若某次发现存在两个或者两个以上入度为$0$的节点,那么不可行. #pragma comment(linker, "/STACK:102400 ...
- Symfony没有安装依赖_PHP Fatal error: require(): Failed opening required
$ php bin/console server:run PHP Warning: require(D:\home\workspace\pd\app/../vendor/autoload.php): ...
- PHP控制连接打印机
一.需求 使用PHP控制连接打印机 现场实时连续打印动态数据 二.配置 php运行环境正确安装(Apache|Nginx + PHP) 下载与php版本对应的php_printer.dll扩展 扩展文 ...
- sulime text3
sublime text 3 详细说明--包括快捷键 sublime 插件安装 快捷键 sunlime (需要先安装package control,ctrl+shift+p,输入insall之后安装插 ...
- CentOS 7 systemd service开机启动设定
#vi /etc/systemd/system/xxx.service [Unit] Description=startup script test [Service] Type=simple Exe ...
- 关于MongoDB数据库中文件唯一性的问题
※重要※——介绍一下我的环境:MongoDB的“win32-x86_64-2008plus-ssl-3.0.5”,MongoVUE版本是1.6.9,VS2010,dll是1.10版本. MongoDB ...
- Qt事件和事件循环
在处理QT循环事件的时候遇到了问题,查了半天资料都没弄明白问题出在哪,后来找大牛同事问了一下,同事就给我写了QCoreApplication::processEvent()这个函数,好啦,终于搞定了, ...
- python返回null和空的不同
mysql数据库中有的字段是NULL, 有的字段是空白 写Python脚本,fetchall()得到结果,也是不同. NULL对应的是None, 空白对应的是'' (None, '') 所以根据结果进 ...