HIDDEN TP, TS&SL_EA_FinalVersion

HIDDEN TP, TS&SL_EA_FinalVersion

官方版 无广告 79

更新日期:2022-10-26 分类标签: 语言:中文 平台:没限制

12 人已下载 手机查看

HIDDEN TP, TS&SL_EA_FinalVersion

#property copyright "Copyright ?2008, FOREXflash"
#property link "http://www.metaquotes.net"

//+-------------------------------------------------------------------------------------------+

extern bool use_hidden_stop_loss = true;
extern int hidden_sl = 35;
extern bool use_hidden_take_profit = true;
extern int hidden_tp = 100;

extern bool ProfitTrailing = True;
extern int TrailingStop = 30;
extern int TrailingStep = 15;
extern bool UseSound = False;
//+-------------------------------------------------------------------------------------------+

void hidden_take_profit()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderSymbol()==Symbol() )
{
if (OrderType() == OP_BUY && OrderOpenPrice()+hidden_tp*Point<=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()-hidden_tp*Point>=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

}
}
return;
}
//+-------------------------------------------------------------------------------------------+
void hidden_stop_loss()
{
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderSymbol()==Symbol() )
{
if (OrderType() == OP_BUY && OrderOpenPrice()-hidden_sl*Point>=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()+hidden_sl*Point<=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );

}
}
return;
}
//+-------------------------------------------------------------------------------------------+
//| expert initialization function |
//+-------------------------------------------------------------------------------------------+

//+-------------------------------------------------------------------------------------------+
//| expert deinitialization function |
//+-------------------------------------------------------------------------------------------+

int deinit()
{
//----

//----
return(0);
}

//+-------------------------------------------------------------------------------------------+
//| expert start function |
//+-------------------------------------------------------------------------------------------+
void start() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
TrailingPositions();

//----
if (use_hidden_stop_loss) hidden_stop_loss();
if (use_hidden_take_profit) hidden_take_profit();
//----

}
}
}

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+

 

//+------------------------------------------------------------------+
//| 杨镳钼铈溴龛?镱玷鲨?镳铖螓?蝠嚯铎 |
//+------------------------------------------------------------------+
void TrailingPositions() {
double pBid, pAsk, pp;

pp = MarketInfo(OrderSymbol(), MODE_POINT);
if (OrderType()==OP_BUY) {
pBid = MarketInfo(OrderSymbol(), MODE_BID);
if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
ModifyStopLoss(pBid-TrailingStop*pp);
return;
}
}
}
if (OrderType()==OP_SELL) {
pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
ModifyStopLoss(pAsk+TrailingStop*pp);
return;
}
}
}
}

//+------------------------------------------------------------------+
//| 襄疱眍?箴钼? StopLoss |
//| 相疣戾蝠? |
//| ldStopLoss - 箴钼屙?StopLoss |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss) {
bool fm;

fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);

}
//+------------------------------------------------------------------+

 

//+-------------------------------------------------------------------------------------------+

 

相关资源

暂无评论

暂无评论...