- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前有一个几乎每 5 分钟就开始一次交易的系统。
我目前正在全神贯注地创建一个执行以下操作的追踪止损:
每个订单号扫描所有未结订单并修改它们,如果它们还没有被修改,像这样:
以 25 点的静态止损开始
在获利 5 点时将止损移至入场价
8 点利润移动止损 8 点利润(当前价格)后 4 点
这是我目前的情况
//---- input parameters
extern double InitialStop = 25;
extern double BreakEven = 20; // Profit Lock in pips
extern double StepSize = 5;
extern double MinDistance = 10;
int k, digit=0;
bool BE = false;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
return(0);
}
// ---- Stepped Stops
void StepStops()
{
double BuyStop, SellStop;
int total=OrdersTotal();
for (int cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
int mode=OrderType();
if ( OrderSymbol()==Symbol() )
{
if ( mode==OP_BUY )
{
BuyStop = OrderStopLoss();
if ( Bid-OrderOpenPrice()>0 || OrderStopLoss()==0)
{
if ( Bid-OrderOpenPrice()>=Point*BreakEven && !BE) {BuyStop = OrderOpenPrice();BE = true;}
if (OrderStopLoss()==0) {BuyStop = OrderOpenPrice() - InitialStop * Point; k=1; BE = false;}
if ( Bid-OrderOpenPrice()>= k*StepSize*Point)
{
BuyStop = OrderStopLoss()+ StepSize*Point;
if (Bid - BuyStop >= MinDistance*Point)
{ BuyStop = BuyStop; k=k+1;}
else
BuyStop = OrderStopLoss();
}
//Print( " k=",k ," del=", k*StepSize*Point, " BuyStop=", BuyStop," digit=", digit);
OrderModify(OrderTicket(),OrderOpenPrice(),
NormalizeDouble(BuyStop, digit),
OrderTakeProfit(),0,LightGreen);
return(0);
}
}
if ( mode==OP_SELL )
{
SellStop = OrderStopLoss();
if ( OrderOpenPrice()-Ask>0 || OrderStopLoss()==0)
{
if ( OrderOpenPrice()-Ask>=Point*BreakEven && !BE) {SellStop = OrderOpenPrice(); BE = true;}
if ( OrderStopLoss()==0 ) { SellStop = OrderOpenPrice() + InitialStop * Point; k=1; BE = false;}
if ( OrderOpenPrice()-Ask>=k*StepSize*Point)
{
SellStop = OrderStopLoss() - StepSize*Point;
if (SellStop - Ask >= MinDistance*Point)
{ SellStop = SellStop; k=k+1;}
else
SellStop = OrderStopLoss();
}
//Print( " k=",k," del=", k*StepSize*Point, " SellStop=",SellStop," digit=", digit);
OrderModify(OrderTicket(),OrderOpenPrice(),
NormalizeDouble(SellStop, digit),
OrderTakeProfit(),0,Yellow);
return(0);
}
}
}
}
}
// ---- Scan Trades
int ScanTrades()
{
int total = OrdersTotal();
int numords = 0;
for(int cnt=0; cnt<total; cnt++)
{
OrderSelect(cnt, SELECT_BY_POS);
if(OrderSymbol() == Symbol() && OrderType()<=OP_SELL)
numords++;
}
return(numords);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
digit = MarketInfo(Symbol(),MODE_DIGITS);
if (ScanTrades()<1) return(0);
else
if (BreakEven>0 || InitialStop>0 || StepSize>0) StepStops();
return(0);
}//int start
//+------------------------------------------------------------------+
如您所见,此 EA 确实以 25 点的静态止损开始,但我无法让它执行最后两个步骤,它们是:
如果您可以分享我可以合并到我的 EA 中或作为独立脚本/EA 运行的代码/想法,那将真的很有帮助。
谢谢
最佳答案
建议不要在服务器端申请止损,只要满足条件就直接用自己的代码平仓。
关于mql4 - 算法交易 : How to incorporate this type of trailing stop?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50965143/
我想知道是否可以从 Freebase 获取有关特定日期的所有信息。 我可以轻松检索有关特定主题的日期信息,例如,获取所有在特定日期出生的感兴趣的人: [{ "type":"/people/pers
我正在尝试返回维基百科中列出出生日期的人员列表。下面的代码适用于英文维基百科,但不会返回非英文维基百科中的人员。如何返回任何维基百科中的人员列表? [{ "id": null, "name":
因为没有办法使用 MQL 获取随机记录,所以我尝试先使用计数来获取它: [{ "return": "count", "id": null, "name": null, "type": "/people
我正在尝试写一个 MQL query使用 Freebase 执行蜜蜂。我想检索主题摘要和主题图像。 我已经能够计算出以下查询,它将为我提供与 Bill Gates 相关的图像话题。 MQL: [
在 Freebase 网站主题页面上,他们有一个名为“相关主题”的部分。例如,在 Toy Story 的情况下它有:玩具总动员 2、汽车、海底总动员和怪物公司 我已经通读了查询编辑器、手册、Stack
我正在尝试几个非常简单的查询,以从 Freebase 检索政党成员,特别是英国工党。我无法让他们返回任何结果,欢迎任何关于为什么会这样的想法: 查询 1: [{ "id": "/m/01c9x
我很难尝试通过 MQL 查询使用社交链接从 Freebase 获取某人的数据。 这怎么可能? 类似于: https://www.googleapis.com/freebase/v1/mqlread?q
我一直在研究一个简单的 calorie counter使用免费基地。当我querying for a recipe我没有得到所有返回的条目。 我的查询是: [{ "id": "/m/0e cvb9
所以我有两个表: order_product -------------------------------------------------- | ProductID | Quantity
为什么会返回 400 错误(唯一查询最多只能有一个结果。得到 100): [{ name:null, type:'music/artist' }] 我希望它返回音乐/艺术家的前 100
我想编写一个查询来获取关于某个主题的所有已知信息(只需要一层深度。 在 Freebase MQL Editor 工作时他们为“我们所知道的关于 Jimi Hendrix 的一切”给出了以下示例: {
Freebase 的 metaweb query language如果你传入 ISO8601,可以用来检索 future 的事件格式化日期。 [{ "id": null,
freebase 网站上的例子 http://wiki.freebase.com/wiki/MQL_Manual_Javascript_Example 使用http://api.freebase.co
遵循 freebase MQL 为每个艺术家查找 5 位艺术家和 50 张专辑。 [{ "type" : "/music/artist", "name":null, "album" : [
可以在特定字段中获取所有值为 null 的三元组吗? 所有 date_of_birth 的人都等于 null? [ "type": "/people/person", "date_of_bi
我正在尝试弄清楚如何编写 MQL 查询以获取与给定单词关联的所有类型的列表。 例如我试过: { "id":null, "name":null, "name~=": "SOME_WORD",
我尝试使用 google API freebase。 我使用以下查询搜索电影描述: [{ "id": "/m/027pfg", "name": null, "/common/topic/d
我正在尝试编写一个过滤掉空值的 MQL 查询。 我现在的查询(可以使用 MQL Query Editor 执行): [ { "/common/topic/image" : [
我试图在一个地理边界框(大约覆盖法国)中获取所有事件,但我想排除所有重复发生的事件,所以我不会得到大量的法国网球公开赛等。为此,我在查询中使用了以下内容。 "/time/event/instance_
Freebase 包含大量文档,但缺少一些适用于许多场景的工作代码的具体示例。 其中之一是如何使用他们的 eMQL 服务实现(在 Python 中,使用 Python Freebase 库)查询。这是
我是一名优秀的程序员,十分优秀!