Hoang Quang Minh
Active Member
- 209
- 90
Qua TraderViet mình có biết trang Web https://www.forexeadvisor.com/expert_generator.aspx
Mình có làm thử 1 số EA kết hợp với xem video dạy viết EA trên Yutube nên tạo ra con EA này.
Mình xin nhờ các anh, chị, các bạn biết code EA có thể xem, sửa vài dòng để nó có thể tự động tính lost theo 1% tài khoản. Và góp ý, sửa những đoạn mã chưa tốt được không ạ? Xin mọi người đừng cười vì mình mới bắt đầu học, tập viết EA. Cảm ơn tất cả mọi người.
//+------------------------------------------------------------------+
extern int MagicNumber = 10000;
extern double Lots = 0.01;
extern double StopLoss = 12;
extern double TakeProfit1 = 0;
extern double TakeProfit2 = 15;
extern double TakeProfit3 = 18;
extern double TakeProfit4 = 21;
extern double TakeProfit5 = 24;
extern double TakeProfit6 = 27;
extern double TakeProfit7 = 30;
extern double TakeProfit8 = 33;
extern double TakeProfit9 = 36;
extern int TrailingStop = 12;
extern int Slippage = 3;
//+------------------------------------------------------------------+
// expert start function
//+------------------------------------------------------------------+
int start()
{double MyPoint=Point;
if(Digits==1 || Digits==2|| Digits==3|| Digits==4|| Digits==5|| Digits==6|| Digits==7|| Digits==8|| Digits==9) {MyPoint=Point*10;}
double TheStopLoss=0;
double TheTakeProfit1=0;double TheTakeProfit2=0;double TheTakeProfit3=0;double TheTakeProfit4=0;double TheTakeProfit5=0;
double TheTakeProfit6=0;double TheTakeProfit7=0;double TheTakeProfit8=0;double TheTakeProfit9=0;
if(TotalOrdersCount()==0)
{int result1=0; int result2=0;int result3=0;int result4=0;int result5=0; int result6=0;int result7=0;int result8=0;int result9=0;
if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Ask+TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);
result2= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Ask+TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);
result3= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Ask+TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);
result4= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Ask+TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);
result5= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Ask+TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);
result6= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Ask+TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);
result7= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Ask+TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);
result8= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Ask+TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);
result9= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Ask+TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}
//======================================================================
if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Bid-TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);
result2= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Bid-TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);
result3= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Bid-TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);
result4= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Bid-TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);
result5= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Bid-TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);
result6= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Bid-TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);
result7= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Bid-TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);
result8= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Bid-TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);
result9= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Bid-TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}}
//========================================================================
for(int cnt=0;cnt<OrdersTotal();cnt++)
{OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{if(OrderType()==OP_BUY)
{if(TrailingStop>0)
{if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
{if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
{OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
return(0);}}}}
else
{if(TrailingStop>0)
{if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
{if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
{OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
return(0);}}}}}} return(0);}
int TotalOrdersCount()
{int result=0;
for(int i=0;i<OrdersTotal();i++)
{OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) result++;}
return (result);}
//========================================================================
Mình có làm thử 1 số EA kết hợp với xem video dạy viết EA trên Yutube nên tạo ra con EA này.
Mình xin nhờ các anh, chị, các bạn biết code EA có thể xem, sửa vài dòng để nó có thể tự động tính lost theo 1% tài khoản. Và góp ý, sửa những đoạn mã chưa tốt được không ạ? Xin mọi người đừng cười vì mình mới bắt đầu học, tập viết EA. Cảm ơn tất cả mọi người.
//+------------------------------------------------------------------+
extern int MagicNumber = 10000;
extern double Lots = 0.01;
extern double StopLoss = 12;
extern double TakeProfit1 = 0;
extern double TakeProfit2 = 15;
extern double TakeProfit3 = 18;
extern double TakeProfit4 = 21;
extern double TakeProfit5 = 24;
extern double TakeProfit6 = 27;
extern double TakeProfit7 = 30;
extern double TakeProfit8 = 33;
extern double TakeProfit9 = 36;
extern int TrailingStop = 12;
extern int Slippage = 3;
//+------------------------------------------------------------------+
// expert start function
//+------------------------------------------------------------------+
int start()
{double MyPoint=Point;
if(Digits==1 || Digits==2|| Digits==3|| Digits==4|| Digits==5|| Digits==6|| Digits==7|| Digits==8|| Digits==9) {MyPoint=Point*10;}
double TheStopLoss=0;
double TheTakeProfit1=0;double TheTakeProfit2=0;double TheTakeProfit3=0;double TheTakeProfit4=0;double TheTakeProfit5=0;
double TheTakeProfit6=0;double TheTakeProfit7=0;double TheTakeProfit8=0;double TheTakeProfit9=0;
if(TotalOrdersCount()==0)
{int result1=0; int result2=0;int result3=0;int result4=0;int result5=0; int result6=0;int result7=0;int result8=0;int result9=0;
if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)>iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Ask+TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);
result2= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Ask+TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);
result3= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Ask+TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);
result4= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Ask+TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);
result5= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Ask+TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);
result6= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Ask+TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);
result7= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Ask+TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);
result8= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Ask+TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);
result9= OrderSend(Symbol(),0,Lots,Ask,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Ask+TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}
//======================================================================
if((iRSI(NULL,PERIOD_M1,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M1,18, PRICE_WEIGHTED,0))
&&(iRSI(NULL,PERIOD_M5,14,PRICE_WEIGHTED,0)<iRSI(NULL,PERIOD_M5,18, PRICE_WEIGHTED,0)))
{{result1= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA1",MagicNumber,0,Blue);
if(TakeProfit1>0) TheTakeProfit1=Bid-TakeProfit1*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result1,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit1,Digits),0,Green);
result2= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA2",MagicNumber,0,Blue);
if(TakeProfit2>0) TheTakeProfit2=Bid-TakeProfit2*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result2,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit2,Digits),0,Green);
result3= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA3",MagicNumber,0,Blue);
if(TakeProfit3>0) TheTakeProfit3=Bid-TakeProfit3*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result3,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit3,Digits),0,Green);
result4= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA4",MagicNumber,0,Blue);
if(TakeProfit4>0) TheTakeProfit4=Bid-TakeProfit4*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result4,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit4,Digits),0,Green);
result5= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA5",MagicNumber,0,Blue);
if(TakeProfit5>0) TheTakeProfit5=Bid-TakeProfit5*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result5,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit5,Digits),0,Green);
result6= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA6",MagicNumber,0,Blue);
if(TakeProfit6>0) TheTakeProfit6=Bid-TakeProfit6*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result6,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit6,Digits),0,Green);
result7= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA7",MagicNumber,0,Blue);
if(TakeProfit7>0) TheTakeProfit7=Bid-TakeProfit7*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result7,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit7,Digits),0,Green);
result8= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA8",MagicNumber,0,Blue);
if(TakeProfit8>0) TheTakeProfit8=Bid-TakeProfit8*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result8,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit8,Digits),0,Green);
result9= OrderSend(Symbol(),1,Lots,Bid,Slippage,0,0,"EA9",MagicNumber,0,Blue);
if(TakeProfit9>0) TheTakeProfit9=Bid-TakeProfit9*MyPoint;
if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;
OrderSelect(result9,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit9,Digits),0,Green);}
return(0);}}
//========================================================================
for(int cnt=0;cnt<OrdersTotal();cnt++)
{OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{if(OrderType()==OP_BUY)
{if(TrailingStop>0)
{if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)
{if(OrderStopLoss()<Bid-MyPoint*TrailingStop)
{OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
return(0);}}}}
else
{if(TrailingStop>0)
{if((OrderOpenPrice()-Ask)>(MyPoint*TrailingStop))
{if((OrderStopLoss()>(Ask+MyPoint*TrailingStop)) || (OrderStopLoss()==0))
{OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MyPoint*TrailingStop,OrderTakeProfit(),0,Red);
return(0);}}}}}} return(0);}
int TotalOrdersCount()
{int result=0;
for(int i=0;i<OrdersTotal();i++)
{OrderSelect(i,SELECT_BY_POS ,MODE_TRADES);
if (OrderMagicNumber()==MagicNumber) result++;}
return (result);}
//========================================================================
Giới thiệu sách Trading hay
Phương Pháp Wyckoff Hiện Đại - Kỹ thuật Nhận diện Xu hướng Thị trường Tiềm năng
Phương pháp Wyckoff là một phương pháp price action kinh điển và đem lại thành công cho nhiều trader. Phương pháp này là nền tảng của nhiều phương pháp trading nổi tiếng khác
Bài viết liên quan