在页面的右下角,你可以看到你账户的盈利或亏损百分比。

接下来,我们来看看如何使用这个每日回撤指标。
初始化函数 OnInit
CreateEdit("每日回撤",200,68,98,30,"每日回撤",clrWhite,clrBlack,12); CreateEdit("每日回撤 V",100,68,98,30,"",clrWhite,clrBlack,12);
去初始化函数 OnDeinit
ObjectDelete(0,"每日回撤"); ObjectDelete(0,"每日回撤 V");
计算函数 OnCalculate
MqlDateTime w; TimeToStruct(TimeCurrent(),w); string md=IntegerToString(w.year)+"."+IntegerToString(w.mon)+".01"; double historyProfit=0,deposit=0; HistorySelect(0,TimeCurrent()); ulong ticket_history_deal=0; for(int i=0; i<HistoryDealsTotal(); i++) if((ticket_history_deal=HistoryDealGetTicket(i))>0) { datetime timeeee=(datetime)HistoryDealGetInteger(ticket_history_deal,DEAL_TIME); if(timeeee>StringToTime(TimeToString(TimeCurrent(),TIME_DATE))) if(HistoryDealGetInteger(ticket_history_deal,DEAL_TYPE)==DEAL_TYPE_BUY || HistoryDealGetInteger(ticket_history_deal,DEAL_TYPE)==DEAL_TYPE_SELL) historyProfit+=HistoryDealGetDouble(ticket_history_deal,DEAL_PROFIT)+HistoryDealGetDouble(ticket_history_deal,DEAL_COMMISSION)+HistoryDealGetDouble(ticket_history_deal,DEAL_SWAP); else deposit+=HistoryDealGetDouble(ticket_history_deal,DEAL_PROFIT); } double startBalance=AccountInfoDouble(ACCOUNT_BALANCE)-historyProfit; string text=""; double dd=(historyProfit+AccountInfoDouble(ACCOUNT_PROFIT))*100/startBalance; text=DoubleToString(dd,2)+" %"; ObjectSetString(0,"每日回撤 V",OBJPROP_TEXT,text); ChartRedraw();
通过这个指标,你可以更好地掌控每日的回撤情况,帮助你做出更明智的交易决策。希望大家能在交易中取得更好的成绩!
评论 0