DgR RaitisTrading EA 源代码可用。此 EA 具有到期代码。因此,您可以使用此具有到期日期的 EA。亲爱的,我已经把 2200 作为到期日。根据您的要求进行编辑。
#property copyright "TradingSB.com The Original Source Code"
#property copyright " X2 Price Zone 2 "
#property link "imql5.com"
#property version "V22"
#property description "<-- DgR_RaitisTrading_EA Source code by tradingsb.com --><-- Telegram Link, https://www.mql5.vip--><-- Email: 14117225@qq.com"
//---- includes
//#include <debug.mqh>
//#include <WinUser32.mqh>
//#include <LibOrderReliable.mqh>
extern string Set1_________ = "====== main_setting =======";
extern int TakeProfit = 50;
extern int StopLoss = 50;
extern int TrailingStop = 0;
extern int TrailingStep = 0;
extern int BreakEven = 0;
extern bool ClsOnReverse = TRUE;
extern int magic = 2512;
extern int maxspread = 5;
extern double slippage = 3.0;
extern string Set2_________ = "====== lot_management =====";
extern double Lots = 0.1; // basic lot
extern bool Dynamic_Lots = TRUE; //TRUE
extern double LotPercent = 10.0; //
extern bool Martingale = FALSE; // false to deactivated this feature
extern double Multiplier = 1.1; // previous lotsize will multiplied
extern int MartiLevel = 10; // how many continue losses
extern string Set3_________ = "======= Time Filter =======";
extern bool TimeFilter = true; //time filter
extern int StartDay = 1; //time filter
extern int EndDay = 5; //end hour
extern int StartHour = 0; //start hour
extern int EndHour = 23; //end hour
extern bool close_all = true; //close all order
extern int CloseMinute = 1; //end hour
//<< Global Variables >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
string gs_148;
string gs_156;
double gd_176;
string gs_comment_120 = "!DgR_RaitisTradingSB.com_EA";
double pips2points, // slippage 3 pips 3=points 30=points
pips2dbl; // Stoploss 15 pips 0.0015 0.00150
int Digitspips; // DoubleToStr(dbl/pips2dbl, Digits.pips)
double dPriceChannel_Up,
dPriceChannel_Dn,
dRaitisHA_0,
dRaitisHA_1,
dJMARibbon_0,
dJMARibbon_1,
dRaitisStoch_0,
dRaitisStoch_1,
dRaitisCyF_Up,
dRaitisCyF_Dn,
Signal_L,
Signal_S,
dBuyLevel,
dSellLevel,
stoplevel,
spread,
dAsk,
dBid;
bool buy = true,
sell = true;
//<< End >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//+==================================================================+
//| expert initialization function |
//+==================================================================+
int init() {
if (Digits == 3 || Digits == 5){ // Adjust for five (5) digit brokers.
pips2dbl = Point*10; pips2points = 10; Digitspips = 1;
} else { pips2dbl = Point; pips2points = 1; Digitspips = 0; }
// OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
////////////////////////////////////////////////////////////////////////////
ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);
ObjectSetText("ObjName","tradingSB.com",14, "Verdana", Blue);
ObjectSet("ObjName", OBJPROP_CORNER, 0);
ObjectSet("ObjName", OBJPROP_XDISTANCE, 40);
ObjectSet("ObjName", OBJPROP_YDISTANCE, 80);
return (0);
}
//+==================================================================+
//| expert deinitialization function |
//+==================================================================+
int deinit() {
Comment("");
return (0);
}
//+==================================================================+
//| expert start function |
//+==================================================================+
int start() {
//////////////////////////////////////////////////////////////
// User dengan Expired Date
string expire_date = "2200.04.30"; //<-- hard coded datetime
datetime e_d = StrToTime(expire_date);
if (CurTime() >= e_d)
{
Alert ("Versi Trial expired !");
return(0);
}
//////////////////////////////////////////////////////////////
if (IsTradeAllowed() == FALSE) return (0);
if (!IsTradeTime())
{
if (close_all && Minute() >= CloseMinute)
CloseAll();
CloseAll();
CloseAll();
return(0);
}
//<<< risk management >>>>>>>>>>>>
if (Dynamic_Lots)LotCalculate();
//<<< trailing stop >>>>>>>>>>>>>>
if(TrailingStop > 0)MoveTrailingStop();
//<<< break even >>>>>>>>>>>>>>>>>
if(BreakEven > 0 && TrailingStop == 0)MoveBreakEven();
//<<< Indicators & MarketInfo >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
dPriceChannel_Up = iCustom(Symbol(), 0, "RaitisPriceChannel", 60,2,3,9,9,0.3,0.3,1,1,0,0,1,1,1,1,0, 0, 1);
dPriceChannel_Dn = iCustom(Symbol(), 0, "RaitisPriceChannel", 60,2,3,9,9,0.3,0.3,1,1,0,0,1,1,1,1,0, 1, 1);
dRaitisHA_0 = iCustom(Symbol(), 0, "RaitisHeikenAshi", 14, 0, 1);
dRaitisHA_1 = iCustom(Symbol(), 0, "RaitisHeikenAshi", 14, 1, 1);
dJMARibbon_0 = iCustom(Symbol(), 0, "RaitisJMARibbon", 0, 12,0,0,26,0,0, 0, 1);
dJMARibbon_1 = iCustom(Symbol(), 0, "RaitisJMARibbon", 0, 12,0,0,26,0,0, 1, 1);
dRaitisStoch_0 = iCustom(Symbol(), 0, "RaitisStoch", 13,25,2,5,0, 0, 1);
dRaitisStoch_1 = iCustom(Symbol(), 0, "RaitisStoch", 13,25,2,5,0, 1, 1);
dRaitisCyF_Up = iCustom(Symbol(), 0, "RaitisCyFilter","current time frame", 5,0, 0, 1);
dRaitisCyF_Dn = iCustom(Symbol(), 0, "RaitisCyFilter","current time frame", 5,0, 1, 1);
stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL)*Point;
spread = MarketInfo(Symbol(), MODE_SPREAD)*Point;
dAsk = NormalizeDouble(MarketInfo(Symbol(), MODE_ASK), Digits);
dBid = NormalizeDouble(MarketInfo(Symbol(), MODE_BID), Digits);
Signal_L = (dPriceChannel_Up > 0) && (dRaitisHA_0 > dRaitisHA_1) && (dJMARibbon_0 > dJMARibbon_1) &&
(dRaitisStoch_0 > dRaitisStoch_1) && (dRaitisCyF_Up > 0);
Signal_S = (dPriceChannel_Dn > 0) && (dRaitisHA_0 < dRaitisHA_1) && (dJMARibbon_0 < dJMARibbon_1) &&
(dRaitisStoch_0 < dRaitisStoch_1) && (dRaitisCyF_Dn > 0);
//<<< Counting Order >>>>>>>>>>>>>
int _ord_total = OrdersTotal();
int _countM = 0;
int _countB = 0;
int _countS = 0;
for (int _pos = 0; _pos < _ord_total; _pos++)
{
OrderSelect(_pos, SELECT_BY_POS, MODE_TRADES);
RefreshRates();
if (OrderSymbol() == Symbol() && OrderCloseTime() == 0)
{
if (OrderMagicNumber() == magic)
{
_countM++;
if (OrderType() == OP_BUY) _countB++;
if (OrderType() == OP_SELL) _countS++;
}
}
}
//<<< Open & Close Order >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (Signal_L && spread <= maxspread*pips2points)
{
if (ClsOnReverse == true && _countS > 0) // Order Sell
{
gs_148 = "Bullish";
OrderClose( OrderTicket(), OrderLots(), dAsk, slippage * pips2points, Red );
gs_156 = "Closing Order Sell";
RefreshRates();
}
if (buy == true && _countB == 0) // Order Sell
{
gs_148 = "Bullish";
OrderSend(Symbol(), OP_BUY, mylot(), dAsk, slippage * pips2points, // Open Order Buy
dBid - StopLoss * pips2dbl, dAsk + TakeProfit * pips2dbl, gs_comment_120, magic, 0, Blue);
buy=false;sell=true;
gs_156 = "Opening Order Buy";
RefreshRates();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (Signal_S && spread <= maxspread*pips2points)
{
if (ClsOnReverse == true && _countB > 0)
{
gs_148 = "Bearish";
OrderClose( OrderTicket(), OrderLots(), dBid, slippage * pips2points, Red );
gs_156 = "Closing Order Buy";
RefreshRates();
}
if (sell == true && _countS == 0)
{
gs_148 = "Bearish";
OrderSend(Symbol(), OP_SELL, mylot(), dBid, slippage * pips2points, // Open Sell Order
dAsk + StopLoss * pips2dbl, dAsk - TakeProfit * pips2dbl, gs_comment_120, magic, 0, Red);
buy=true;sell=false;
gs_156 = "Opening Order Sell";
RefreshRates();
}
}
///////////////////////////////////////////////////////////////////////////
Comment("");
komentar (1, ":::::::::::::::::::::::::::::::::::::::","");
komentar (2, "T I M E", TimeToStr(CurTime(),TIME_DATE|TIME_MINUTES));
komentar (3, "NAMA", AccountName());
komentar (4, "No. ACC", AccountNumber());
komentar (5, "BROKER", AccountCompany());
komentar (6, "LEVERAGE", "1:"+DoubleToStr(AccountLeverage(),0));
komentar (7, "BALANCE", DoubleToStr (AccountBalance(),2));
komentar (8, "EQUITY", DoubleToStr (AccountEquity(),2));
komentar (9, "MAGIC", DoubleToStr (magic,0));
komentar (10, ":::::::::::::::::::::::::::::::::::::::","");
komentar (11, "Spread", DoubleToStr(spread/pips2points,1));
komentar (12, "StopLevel", DoubleToStr(stoplevel/pips2points,1));
komentar (13, "Trend", gs_148);
komentar (14, "Action", gs_156);
komentar (15, ":::::::::::::::::::::::::::::::::::::::","");
///////////////////////////////////////////////////////////////////////////
return (0);
}
//<<< Trailing Stop >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void MoveTrailingStop()
{
int cnt,total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic)
{
if(OrderType() == OP_BUY)
{
if(TrailingStop > 0)
{
if((NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(Bid-(pips2dbl*(TrailingStop+TrailingStep)),Digits))||(OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-(pips2dbl*TrailingStop),Digits),OrderTakeProfit(),0,Blue);
return(0);
}
}
}
else
{
if(TrailingStop>0)
{
if((NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+(pips2dbl*(TrailingStop+TrailingStep)),Digits)))||(OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+(pips2dbl*TrailingStop),Digits),OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
//<<< BreakEven >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void MoveBreakEven()
{
int cnt,total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic)
{
if(OrderType() == OP_BUY)
{
if(BreakEven > 0)
{
if(NormalizeDouble((Bid-OrderOpenPrice()),Digits) > BreakEven*pips2dbl)
{
if(NormalizeDouble((OrderStopLoss()-OrderOpenPrice()),Digits)<0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+0*pips2dbl,Digits),OrderTakeProfit(),0,Blue);
return(0);
}
}
}
}
else
{
if(BreakEven>0)
{
if(NormalizeDouble((OrderOpenPrice()-Ask),Digits)>BreakEven*pips2dbl)
{
if(NormalizeDouble((OrderOpenPrice()-OrderStopLoss()),Digits)<0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-0*pips2dbl,Digits),OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
}
//<<< Lot Management >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool checkforlosses() // we check our last closed order
{ // from losses here
int losses=0; // total of losses
int i; // pos of our order
for(i=0; i<OrdersHistoryTotal(); i++) // looping to check all of our
{ // order history from pos 0 until
// last pos
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); // is it right our order?
if(OrderSymbol()!=Symbol() || // if symbol of order didn't match
OrderMagicNumber()!=magic) // with current chart symbol
continue; // or the magic numb of order
// didn't match with our magic
// number, it is not our's, just don't check it
if(OrderProfit()<0) losses++; // so we count it as a losses 'cause negative profit
else losses=0; // otherwise we leave it as is
}
if(losses>0) return(true); // if last of our order is in losses
// true "value" will returned from this function
return(false); // when there is no losses false will returned
}
//<<< Last Lot >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
double lastlot() // we will find last lot size
{ // order with this function
double lot=0; // lot size
int i; // pos of our order
for(i=0; i<OrdersHistoryTotal(); i++) // looping to check all of our
{ // order history from pos 0 until
// last pos
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); // is it right our order?
if(OrderSymbol()!=Symbol() || // if symbol of order didn't match
OrderMagicNumber()!=magic) // with current chart symbol
continue; // or the magic numb of order
// didn't match with our magic
// number, it is not our's
lot=OrderLots(); // last lot
}
return(lot); // last lot size returned
}
//<<< Lot Management >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
double mylot() // we calculate for next lot here
{ // when a loss occured or not
int prec=0; // precision value
double lot, // lot size
minlot, // minimal size of lot
maxlot, // maximal size of lot
maxlotX; // maximal size of martingale lot
minlot=MarketInfo(Symbol(),MODE_MINLOT); // get brokers minimal lot size
maxlot=MarketInfo(Symbol(),MODE_MAXLOT); // get brokers maximal lot size
if(minlot==0.01) prec=2; // get precision value
if(minlot==0.1) prec=1; // get precision value
maxlotX=NormalizeDouble(Lots*MathPow(Multiplier,MartiLevel), prec); //get max.
// martingale lotsize
/////////////////////////////////////////////////////////////////////////////
if(Martingale) // if martingale activated
{
if(checkforlosses()) // if last order is in losses
{
lot=NormalizeDouble(lastlot()*Multiplier,prec); // martingale lot
}
else
{
lot=Lots; // normal lot
}
}
else
{
lot=Lots; // normal lot
}
////////////////////////////////////////////////////////////////////
if(lot>maxlot) return(Lots); // if lot size is bigger than broker rules,
// we change it into StartLot value
if(lot>maxlotX) return(Lots); // if lot size is bigger than martingale level,
// we change it into StartLot value
if(lot<minlot) return(minlot); // if lot size smaller than minlot, we change
// into monlot value
return(lot); // lot size returned
}
////////////////////////////////////////////////////////////////////
void LotCalculate()
{
double MinLots=MarketInfo(Symbol(),MODE_MINLOT);
double MaxLots=MarketInfo(Symbol(),MODE_MAXLOT);
Lots=AccountBalance()/100000*LotPercent;
Lots=MathMin(MaxLots,MathMax(MinLots,Lots));
if(MinLots<0.1)Lots=NormalizeDouble(Lots,2);
else
{
if(MinLots<1)Lots=NormalizeDouble(Lots,1);
else Lots=NormalizeDouble(Lots,0);
}
if(Lots<MinLots)Lots=MinLots;
if(Lots>MaxLots)Lots=MaxLots;
return(0);
}
//<<< Time Filter >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool IsTradeTime()
{
if (!TimeFilter)
return (true);
if(
(DayOfWeek() == StartDay && !(Hour() >= StartHour && Hour() < 24))||
(DayOfWeek() > !StartDay && DayOfWeek() < !EndDay)||
(DayOfWeek() == EndDay && !(Hour() >= 0 && Hour() < EndHour))
)
return(FALSE);
else
return(TRUE);
}
//<<< Close All Trades >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void CloseAll()
{
int total = OrdersTotal();
bool do_again = false;
for(int i=total-1; !do_again && i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
bool result = false;
switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), dBid, slippage * pips2points, Red );
do_again = true;
break;
//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), dAsk, slippage * pips2points, Red );
do_again = true;
break;
}
if(result == false)
{
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
}
}
return(0);
}
//<<< Comment >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void komentar (int baris, string label1, string label2)
{
if (!IsTradeAllowed() || !IsExpertEnabled()) {ObjectDelete("baris0"); return (0);}
int x,y;
switch(baris)
{
case 1: x=15; y= 60; break;
case 2: x=15; y= 75; break;
case 3: x=15; y= 90; break;
case 4: x=15; y=105; break;
case 5: x=15; y=120; break;
case 6: x=15; y=135; break;
case 7: x=15; y=150; break;
case 8: x=15; y=165; break;
case 9: x=15; y=180; break;
case 10: x=15; y=195; break;
case 11: x=15; y=210; break;
case 12: x=15; y=225; break;
case 13: x=15; y=240; break;
case 14: x=15; y=255; break;
case 15: x=15; y=270; break;
case 16: x=15; y=285; break;
case 17: x=15; y=300; break;
case 18: x=15; y=315; break;
}
Monitor("baris0", WindowExpertName()+ " IS RUNNING", 10, 15, 35, Yellow,1);
Monitor("baris00", "tradingSB.com", 12, 20, 10, Yellow,2);
Monitor("baris"+baris, label1, 8, x, y, Yellow,1);
Monitor("baris_"+baris, ":", 8, x+70, y, Yellow,1);
Monitor("baris-"+baris, label2, 8, x+80, y, Yellow,1);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Monitor(string nama, string isi, int ukuran, int x, int y, color warna, int pojok)
{
if (ObjectFind(nama)<0) {ObjectCreate (nama,OBJ_LABEL,0,0,0,0,0);}
ObjectSet (nama,OBJPROP_CORNER,pojok);
ObjectSet (nama,OBJPROP_XDISTANCE,x);
ObjectSet (nama,OBJPROP_YDISTANCE,y);
ObjectSetText (nama,isi,ukuran,"Tahoma",warna);
}
////////////////////////////////////////////////////*****|||*****\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END