MC-设置 止盈
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop; namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class ExampleTakeProfit : SignalObject
{
private IOrderMarket buyOrder, sellTimeStopOrder;
private IOrderPriced sellTPorder;
private double takeProfitPrice; [Input]
public int TakeProfitTicks { get; set; } public ExampleTakeProfit(object _ctx) : base(_ctx) { } protected override void Create()
{
buyOrder = OrderCreator.MarketNextBar(new SOrderParameters(
Contracts.Default, EOrderAction.Buy)); sellTPorder = OrderCreator.Limit(new SOrderParameters(
Contracts.Default, "TakeProfit", EOrderAction.Sell)); sellTimeStopOrder = OrderCreator.MarketNextBar(new SOrderParameters(
Contracts.Default, "TimeStop", EOrderAction.Sell)); TakeProfitTicks = ; // Default value
} protected override void StartCalc()
{
Output.Clear(); // Clear Editor Output tab
} protected override void CalcBar()
{
// When flat, enter a long position every fifth bar
if ((StrategyInfo.MarketPosition == ) && (Bars.CurrentBar % == ))
{
// Submit the order at the open of the bar
if (Bars.Status == EBarState.Open)
{
buyOrder.Send(); Output.WriteLine("{0} - Submitted buy order",
Bars.Time[].ToString("d-M HH:mm"));
}
} // Management of open long position
if (StrategyInfo.MarketPosition > )
{
// First, when the position is just opened,
// we need to calculate the take profit price
int barsInPosition = Bars.CurrentBar -
Positions[].OpenTrades[].EntryOrder.BarNumber; // When the position is just opened, calculate the take profit price
if (barsInPosition == )
{
takeProfitPrice = Positions[].OpenTrades[].EntryOrder.Price +
(TakeProfitTicks * (Bars.Info.MinMove / Bars.Info.PriceScale)); // Only output info to the Output log at the open
// of the bar (prevents cluttering the log)
if (Bars.Status == EBarState.Open)
{
Output.WriteLine("{0} - Take profit price: {1}",
Bars.Time[].ToString("d-M HH:mm"),
takeProfitPrice);
}
} // Submit take profit order as long as there is an open long position
sellTPorder.Send(takeProfitPrice); if (Bars.Status == EBarState.Close) // Prevents cluttering the output
{
Output.WriteLine("{0} - Sending limit order @ {1}",
Bars.Time[].ToString("d-M HH:mm"),
takeProfitPrice);
} // To prevent positions that are never closed, exit after more than 5 bars
if (barsInPosition > )
{
sellTimeStopOrder.Send(); if (Bars.Status == EBarState.Open) // Prevents cluttering the output
{
Output.WriteLine("{0} - Sending time stop order",
Bars.Time[].ToString("d-M HH:mm"));
}
}
}
}
}
}
MC-设置 止盈的更多相关文章
- AJPFX:什么是止盈?什么是止损?
在您进行外汇交易后,会碰到Take Profit(止盈)和 Stop Loss(止损)这两个词,均是用作控制风险的工具. 止盈(Take Profit):当单子达到预期的获利价格时锁定盈利.当订单在盈 ...
- Python之关于量化投资实现代码--根据策略提出的代码--还未完善
# 根据缺口的模式选股买股票 ''' -------------------------------------------- 1.总体回测前要做的事情 initialize(context) 1.1 ...
- 玩好百家乐需要掌握些什么技巧和打法?来自ag老玩家的实战经验心得总结
最近很多网友给我留言,说为什么学了很多技巧和打法这个游戏还是玩不好,坦白说,其实bjl想要玩得好,不是说你懂得多少技巧和掌握了多少种打法就可以的了,而是你要懂得如何把这些正确结合去运用,这些我之前都强 ...
- MC中间件WCCS
一.问题描述 在大访问量的Web服务中,MC集群作为缓解后端数据源访问压力的中间层已经成为了不可缺少的一部分,机器数量越来越大,维护成本也变得越来越高了,其中的问题有: 故障机器自动剔除.后端某台MC ...
- just555 对话
网易 新闻 2005-03-31 16:37:47 空!(19194697)555,你在大连炒单,单日最大盈利率多少? 2005-03-31 16:37:59 just555(79610908)最大1 ...
- 国外成熟的程序交易系统的思路 z
波涛(1998)在<系统交易方法>中提出,一个设计良好的交易系统,必须对投资决策的各个相关环节做出相应明确的规定,同时还必须符合使用者的心理特征.投资对象的统计特征以及投资资金的风险特征. ...
- MT5基础知识
获取账户相关信息 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 printf("ACCOUNT_BALANCE ...
- WeQuant交易策略—网格交易
网格交易策略(Grid Trading) 策略介绍 网格策略本质上是一种低吸高抛的策略.标的物价格越低,吸纳的头寸越多:标的物价格越高,卖出的头寸越多.网格策略巧妙地借鉴了日常生活中渔翁撒网扑鱼的思路 ...
- WeQuant交易策略—Dual Thrust
Dual Thrust策略 策略介绍 Dual Thrust是一个趋势跟踪系统,由Michael Chalek在20世纪80年代开发,曾被Future Thruth杂志评为最赚钱的策略之一. Dual ...
随机推荐
- 关于float和position
在div 块级元素中,一般我们的div块都是流式的,如果你设定一个div,接下来的div就会另起行,也就是块级元素的定义 但是一般排版不是这样的,最典型的应该就是这种布局了,那么中间的那三个div ...
- 用maven在eclipse用spring建javaweb工程(一)
一,步骤 只标注重点步骤: 新建工程选择Maven Project next---next---选择web工程 next---命名如下: 点击finish创建完成. 二,index.jsp和pom ...
- Linux 服务器系统监控脚本 Shell【转】
转自: Linux 服务器系统监控脚本 Shell - 今日头条(www.toutiao.com)http://www.toutiao.com/i6373134402163048961/ 本程序在Ce ...
- VMMap(查看内存工具)
来源: http://www.cnblogs.com/georgepei/archive/2012/03/07/2383445.html http://www.cnblogs.com/georgepe ...
- 301跳转:IIS服务器网站整站301永久重定向设置方法(阿里云)
欢迎来到重庆SEO俱乐部:搜索引擎优化学习交流QQ群224306761. 承接:seo优化.网站建设.论坛搭建.博客制作.全网营销 博主可接:百度百家.今日头条.一点资讯等软文发布,有需要请联系PE! ...
- XAMPP 的MYSQL无法启动
最近在学习小程序,小程序的后台cms系统需要安装XAMPP软件,这个软件是个集成软件,里面有MySql 和 Apache 等 ,首先进入小程序后台时需要启动MySql 和 Apache Apache ...
- 【转】关于spring集合对象的补充
<span style="font-size:18px;">关于spring集合对象的补充 spring2.0中对集合对象有了改进,新增了一个<util>标 ...
- NodeJS学习指南
七天学会NodeJS NodeJS基础 什么是NodeJS 有啥用处 如何安装 安装程序 编译安装 如何运行 权限问题 模块 require exports module 模块初始化 主模块 完整示例 ...
- RTL-SDR简单介绍
Sdr 软件定义的无线电(Software Defined Radio,SDR) 是一种无线电广播通信技术,它基于软件定义的无线通信协议而非通过硬连线实现. Rtl-sdr 原身是Realtek RT ...
- 大数据时代之hadoop(一):hadoop安装
1.hadoop版本介绍 0.20.2版本以前(不含该版本)的配置文件都在default.xml中. 0.20.x以后的版本不含有eclipse插件的jar包,由于eclipse的版本不一,所以就需要 ...