盈利30点将止损提高到盈利15点处(平保)
盈利30点将止损提高到盈利15点处(平保)盈利30点将止损提高到盈利15点处。
这种操作,有时候也叫平保,为了避免将盈利的单子变亏损了所做的一个保护。这种操作非常有用,很多人都会用到,通过编写ea来实现这种功能,非常简单,短短几十行代码就能实现。
下面是这个程序的全部代码,感兴趣可以复制下去保存为EA就可以运行。
//+------------------------------------------------------------------+
//| 盈利30点将止损提高到盈利15点处.mq4 |
//| 云开 |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "云开"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
input int tratp=300;//盈利多少点
input int tp=150;//止损调高到盈利多少点
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
int total=OrdersTotal();
for(int i=0; i
{
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if(OrderStopLoss()tratp*Point)
{
bool res=OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+tp*Point, OrderTakeProfit(), 0);
}
}
if(OrderType()==OP_SELL)
{
if((OrderStopLoss()==0 || OrderStopLoss()>OrderOpenPrice()-tp*Point) && OrderOpenPrice()-OrderClosePrice()>tratp*Point)
{
bool res=OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()-tp*Point, OrderTakeProfit(), 0);
}
}
}
}
}
}
//+------------------------------------------------------------------+
大家在看了小编以上对"盈利30点将止损提高到盈利15点处(平保)"的介绍后应该都清楚了吧,希望对大家做单有所帮助。如果大家还想要下载更多有关"盈利30点将止损提高到盈利15点处(平保)"的相关EA源码,敬请关注汇探网下载。我们会持续更新交易系统,EA源码。
页:
[1]