후행 정지 및 후행 이익 - 페이지 6 1234567 새 코멘트 Arav007 2014.03.08 19:13 #51 deVries : 중개인이 OrderComment를 덮어쓸 수 있습니다. 당신은 원하고 있습니다 ... 이제 내 요구 사항에 따라 가격이 이익으로 7 pip [103.603] 일 때 손절매 첫 번째와 두 번째 거래는 1핍 이익[103.543]이 되고 세 번째 거래의 손절매는 103.386으로 유지됩니다. extern int BreakEven = 7을 만듭니다. (* 10 ) pipvalue를 얻기 위해 5자리 브로커에서 수정 오, 예, 이것은 확실히 단점입니다. 저녁부터 내 모든 노력은 이제 헛된 것입니다! ' 주문댓글 ' 기능에 따라 거래를 구분하는 방법을 시도해보고 코드를 작성했습니다. 어쨌든, 주어진 코드는 손절매 부분을 BE 또는 원하는 지점으로 이동하지만 여전히 '세 번째' 거래에 대한 내 문제는 해결되지 않습니다. 나는 또한 코드의 이 BE 움직이는 부분을 가지고 있지만 세 번째 거래를 위해 움직이지 않는 SL에 갇혔습니다. 다른 아이디어가 떠올랐습니다. 지금 시도해 보세요. 그리고 이것이 유효했습니까? string comment_sell="판매 주문"; SellOrder=OrderSend(Symbol(), iOrderType_Sell, LotSize, OpenPrice, Slippage, dStopLossPrice, dTakeProfitPrice, comment_sell , MagicNumber, 0, Red); if (OrderComment()=="comment_sell") // ? Trailing Stops and Trailing 10포인트 3.mq4 기본적인 질문 ... Arav007 2014.03.08 19:21 #52 유효한가요? EA를 EURUSD 차트 에 첨부했다고 가정해 보겠습니다. if (Order_Symbol()==EURUSD) 현재 차트가 EURUSD인지 여부를 비교합니까? Arav007 2014.03.09 07:54 #53 여기까지는 '매직넘버'를 통해 주문을 구별하는 방법입니다. 중괄호는 균형이 맞지 않습니다. 이게 가능해? if (Order_Symbol==EURUSD) { int Magic_Number_3= 1303 int Magic_Number_2= 1302 int Magic_Number_1= 1301 } if (Order_Symbol==GBPUSD) { int Magic_Number_3= 1603 int Magic_Number_2= 1602 int Magic_Number_1= 1601 } if (Order_Symbol==GBPUSD) { int Magic_Number_3= 8703 int Magic_Number_2= 8702 int Magic_Number_1= 8701 } if (count== 3 ) { BuyOrder_1= OrderSend ( "EURUSD" , iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1, NULL ,Magic_Number_3, 0 ,Blue); if (BuyOrder_1> 0 ) //Checking if the order was opened or not { sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + " Buy order 1 sent successfully. Ticket=" + BuyOrder_1; count = count - 1 ; } else { iLastError = GetLastError(); sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + " Error sending buy order 1. Error code=" + ErrorDescription(iLastError); } } if (count== 2 ) { BuyOrder_2= OrderSend ( "EURUSD" , iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_2, NULL ,Magic_Number_2, 0 ,Blue); if (BuyOrder_2> 0 ) { sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + " Buy order 2 sent successfully. Ticket=" + BuyOrder_2; count = count - 1 ; } else { iLastError = GetLastError(); sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + " Error sending buy order 2. Error code=" + ErrorDescription(iLastError); } } if (count== 1 ) { BuyOrder_3= OrderSend (EURUSD, iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_3, NULL ,Magic_Number_1, 0 ,Blue); if (BuyOrder_3> 0 ) { sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + " Buy order 2 sent successfully. Ticket=" + BuyOrder_3; count = count - 1 ; } else { iLastError = GetLastError(); sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + " Error sending buy order 2. Error code=" + ErrorDescription(iLastError); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// for (cnt= OrdersTotal ()- 1 ;cnt>= 0 ;cnt--) { if (! OrderSelect (cnt, SELECT_BY_POS , MODE_TRADES )) continue ; if ( OrderSymbol () == Symbol () && OrderMagicNumber () == Magic_Number_3) { sl = OrderStopLoss (); // Stop Loss. tStopLoss = NormalizeDouble ( OrderStopLoss (), Digits ); // Stop Loss. if ( OrderType ()== OP_BUY ) { if ( Ask > NormalizeDouble ( OrderOpenPrice ()+TrailingStart* vPoint, Digits ) && tStopLoss < NormalizeDouble ( Bid -(TrailingStop+TrailingStep)*vPoint, Digits )) { tStopLoss = NormalizeDouble ( Bid -TrailingStop*vPoint, Digits ); ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),tStopLoss, OrderTakeProfit (), 0 ,Blue); if (ticket > 0 ) { Print ( "TrailingStop #2 Activated: " , OrderSymbol (), ": SL" , tStopLoss, ": Bid" , Bid ); } else { iLastError = GetLastError(); } } //end if(Ask> NormalizeDouble(OrderOpenPrice()+TrailingStart* vPoint,Digits) && tStopLoss < NormalizeDouble(Bid-(TrailingStop+TrailingStep)*vPoint,Digits)){ } //end if(OrderType()==OP_BUY){ if ( OrderSymbol () == Symbol () && OrderMagicNumber () == Magic_Number_2) { sl = OrderStopLoss (); // Stop Loss. tStopLoss = NormalizeDouble ( OrderStopLoss (), Digits ); // Stop Loss. if ( OrderType ()== OP_BUY ) { if ( Ask > NormalizeDouble ( OrderOpenPrice ()+TrailingStart* vPoint, Digits ) && tStopLoss < NormalizeDouble ( Bid -(TrailingStop+TrailingStep)*vPoint, Digits )) { tStopLoss = NormalizeDouble ( Bid -TrailingStop*vPoint, Digits ); ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),tStopLoss, OrderTakeProfit (), 0 ,Blue); if (ticket > 0 ) { Print ( "TrailingStop #2 Activated: " , OrderSymbol (), ": SL" , tStopLoss, ": Bid" , Bid ); } else { iLastError = GetLastError(); } } //end if(Ask> NormalizeDouble(OrderOpenPrice()+TrailingStart* vPoint,Digits) && tStopLoss < NormalizeDouble(Bid-(TrailingStop+TrailingStep)*vPoint,Digits)){ } //end if(OrderType()==OP_BUY){ if ( OrderSymbol () == Symbol () && OrderMagicNumber () == Magic_Number_1) { sl = OrderStopLoss (); // Stop Loss. tStopLoss = NormalizeDouble ( OrderStopLoss (), Digits ); // Stop Loss. if ( OrderType ()== OP_BUY ) { ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),tStopLoss, OrderTakeProfit (), 0 ,Blue); if (ticket > 0 ) { Print ( "Stop Loss Unchanged" ); } else { iLastError = GetLastError(); } } //end if(Ask> NormalizeDouble(OrderOpenPrice()+TrailingStart* vPoint,Digits) && tStopLoss < NormalizeDouble(Bid-(TrailingStop+TrailingStep)*vPoint,Digits)){ } //end if(OrderType()==OP_BUY){ Tjipke de Vries 2014.03.09 09:59 #54 if (Order_Symbol== "EURUSD" ) //it has to be a string if you do it this way { //==EURUSD) fails int Magic_Number_3= 1303 int Magic_Number_2= 1302 int Magic_Number_1= 1301 } 이 방법으로 3개의 다른 매직넘버를 찾아야 합니다. 내가 할 수있는 것처럼 보입니다. Arav007 2014.03.09 18:24 #55 좋아, 지속적으로 열심히 일한 후(적어도 나에게는) EA를 '오류 무료'로 만들었습니다! 변경 사항 게시: extern string Order_Symbol= "EURUSD" ; int init() { } int start() { int Magic_Number_1,Magic_Number_2,Magic_Number_3; bool bOrderClosed; //////////////////////////////////////SETTING MAGIC NUMBER/////////////////////////////////////////////////// Set_Magic_Number(); //////////////////////////////////////SETTING MAGIC NUMBER COMPLETED///////////////////////////////////////// //////////////////////////////////////LOCKING MINIMUM PROFIT///////////////////////////////////////////////// if ( OrdersTotal ()> 0 ) { for ( int cnt= OrdersTotal ()- 1 ;cnt>= 0 ;cnt--) { if (! OrderSelect (cnt, SELECT_BY_POS , MODE_TRADES )) continue ; //----------------------------------------------------------------------------------------------------------------------- if ( OrderSymbol () == Symbol () && OrderMagicNumber () ==Magic_Number_1) { if ( OrderProfit ()< 0.03 ) { if ( OrderType ()== OP_BUY ) { bOrderClosed = closeBuyOrder(iOrderType_Buy); //Closing Buy order if (bOrderClosed) { Print ( "Buy Order 1 Closed" ); } else { iLastError = GetLastError(); } //end else if(bOrderClosed) } //end if(OrderType()==OP_BUY) //========================================================================================================================== if ( OrderType ()== OP_SELL ) { bOrderClosed = closeSellOrder(iOrderType_Sell); //Closing Sell order if (bOrderClosed) { Print ( "Sell Order 1 Closed" ); } else { iLastError = GetLastError(); } //end else if(bOrderClosed) } //end if(OrderType()==OP_SELL) } // if (OrderProfit()<0.03) } // if(OrderSymbol() == Symbol() && OrderMagicNumber() ==Magic_Number_1) //------------------------------------------------------------------------------------------------------------------------- if ( OrderSymbol () == Symbol () && OrderMagicNumber () ==Magic_Number_2) { if ( OrderProfit ()< 0.02 ) { if ( OrderType ()== OP_BUY ) { bOrderClosed = closeBuyOrder(iOrderType_Buy); //Closing Buy order if (bOrderClosed) { Print ( "Buy Order 2 Closed" ); } else { iLastError = GetLastError(); } //end else if(bOrderClosed) } //end if(OrderType()==OP_BUY) //========================================================================================================================== if ( OrderType ()== OP_SELL ) { bOrderClosed = closeSellOrder(iOrderType_Sell); //Closing Sell order if (bOrderClosed) { Print ( "Sell Order 1 Closed" ); } else { iLastError = GetLastError(); } //end else if(bOrderClosed) } //end if(OrderType()==OP_SELL) } // if (OrderProfit()<0.02) } // if(OrderSymbol() == Symbol() && OrderMagicNumber() ==Magic_Number_2) //------------------------------------------------------------------------------------------------------------------------------ if ( OrderSymbol () == Symbol () && OrderMagicNumber () ==Magic_Number_3) { Print ( "Don't Close this Third Order" ); } // if(OrderSymbol() == Symbol() && OrderMagicNumber() ==Magic_Number_3) //------------------------------------------------------------------------------------------------------------------------------- } //end for(cnt=OrdersTotal()-1;cnt>=0;cnt--) } // if(OrdersTotal()>0) //////////////////////////////////////MINIMUM PROFIT LOCKED////////////////////////////////////////////////// if (TrailingStop> 0 && TrailingStart > 0 ) TrailOrder (TrailingStart, TrailingStop); //count open buy orders. iOpenOrders_Buy = CntOrd(iOrderType_Buy, Symbol ()); //count open sell orders. iOpenOrders_Sell = CntOrd(iOrderType_Sell, Symbol ()); //Conditional Part for Trade if (Buy condition Met) { //Close Open Sell Positions double OpenPrice= Ask ; int count= 3 ; double dTakeProfitPrice_1,dTakeProfitPrice_2,dTakeProfitPrice_3; dStopLossPrice = NormalizeDouble (OpenPrice - StopLoss * dPip, Digits ); dTakeProfitPrice_1 = NormalizeDouble (OpenPrice + TakeProfit_1 * dPip, Digits ); dTakeProfitPrice_2 = NormalizeDouble (OpenPrice + TakeProfit_2 * dPip, Digits ); dTakeProfitPrice_3 = NormalizeDouble (OpenPrice + TakeProfit_3 * dPip, Digits ); iLastError = 0 ; if (count== 3 ) { BuyOrder_1= OrderSend (Order_Symbol, iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1, "Buy Order" ,Magic_Number_1, 0 ,Blue); if (BuyOrder_1> 0 ) //Checking if the order was opened or not { count = count - 1 ; } else { iLastError = GetLastError(); } } if (count== 2 ) { BuyOrder_2= OrderSend (Order_Symbol, iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_2, "Buy Order" ,Magic_Number_2, 0 ,Blue); if (BuyOrder_2> 0 ) { count = count - 1 ; } else { iLastError = GetLastError(); } } if (count== 1 ) { BuyOrder_3= OrderSend (Order_Symbol, iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_3, "Buy Order" ,Magic_Number_3, 0 ,Blue); if (BuyOrder_3> 0 ) { count = count - 1 ; } else { iLastError = GetLastError(); } } } if (Sell condition met) { //Close Open Buy Orders OpenPrice= Bid ; count= 3 ; double SellOrder_1,SellOrder_2,SellOrder_3; dStopLossPrice = NormalizeDouble (OpenPrice + StopLoss * dPip, Digits ); dTakeProfitPrice_1 = NormalizeDouble (OpenPrice - TakeProfit_1 * dPip, Digits ); dTakeProfitPrice_2 = NormalizeDouble (OpenPrice - TakeProfit_2 * dPip, Digits ); dTakeProfitPrice_3 = NormalizeDouble (OpenPrice - TakeProfit_3 * dPip, Digits ); iLastError = 0 ; if (count== 3 ) { SellOrder_1= OrderSend (Order_Symbol, iOrderType_Sell , LotSize,OpenPrice,Slippage ,dStopLossPrice ,dTakeProfitPrice_1 , "Sell Order" ,Magic_Number_1, 0 ,Red); if (SellOrder_1> 0 ) //Checking if the order was opened or not { count = count - 1 ; } else { iLastError = GetLastError(); } } if (count== 2 ) { SellOrder_2= OrderSend (Order_Symbol, iOrderType_Sell , LotSize,OpenPrice,Slippage ,dStopLossPrice ,dTakeProfitPrice_2 , "Sell Order" ,Magic_Number_2, 0 ,Red); if (SellOrder_1> 0 ) //Checking if the order was opened or not { count = count - 1 ; } else { iLastError = GetLastError(); } } if (count== 1 ) { SellOrder_3= OrderSend (Order_Symbol, iOrderType_Sell , LotSize,OpenPrice,Slippage ,dStopLossPrice,dTakeProfitPrice_3 , "Sell Order" ,Magic_Number_3, 0 ,Red); if (SellOrder_3> 0 ) //Checking if the order was opened or not { count = count - 1 ; } else { iLastError = GetLastError(); } } } } void TrailOrder( double Trailingstart, double Trailingstop) { int ticket = 0 ; double tStopLoss; int cnt; double vPoint,vSlippage; double sl; int Magic_Number_1,Magic_Number_2,Magic_Number_3; Set_Magic_Number(); if ( Digits == 3 || Digits == 5 ) {vPoint = Point * 10 ; vSlippage = Slippage * 10 ;} else {vPoint = Point ; vSlippage = Slippage;} RefreshRates (); if ( OrdersTotal ()> 0 ) { for (cnt= OrdersTotal ()- 1 ;cnt>= 0 ;cnt--) { if (! OrderSelect (cnt, SELECT_BY_POS , MODE_TRADES )) continue ; ////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ( OrderSymbol () == Symbol () && OrderMagicNumber () ==Magic_Number_1) { sl = OrderStopLoss (); // Stop Loss. tStopLoss = NormalizeDouble ( OrderStopLoss (), Digits ); // Stop Loss. if ( OrderType ()== OP_BUY ) { if ( Ask > NormalizeDouble ( OrderOpenPrice ()+TrailingStart* vPoint, Digits ) && tStopLoss < NormalizeDouble ( Bid -(TrailingStop+TrailingStep)*vPoint, Digits )) { tStopLoss = NormalizeDouble ( Bid -TrailingStop*vPoint, Digits ); ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),tStopLoss, OrderTakeProfit (), 0 ,Blue); if (ticket > 0 ) { Print ( "TrailingStop #2 Activated: " , OrderSymbol (), ": SL" , tStopLoss, ": Bid" , Bid ); } else { iLastError = GetLastError(); } } //end if(Ask> NormalizeDouble(OrderOpenPrice()+TrailingStart* vPoint,Digits) && tStopLoss < NormalizeDouble(Bid-(TrailingStop+TrailingStep)*vPoint,Digits)){ } //end if(OrderType()==OP_BUY){ //------------------------------------------------------------------------------------------------------------------------------------- Arav007 2014.03.09 18:31 #56 if ( OrderType ()== OP_SELL ) { if ( Bid < NormalizeDouble ( OrderOpenPrice ()-TrailingStart*vPoint, Digits ) && (sl >( NormalizeDouble ( Ask +(TrailingStop+TrailingStep)*vPoint, Digits ))) || ( OrderStopLoss ()== 0 )) { sl = NormalizeDouble ( Ask +TrailingStop*vPoint, Digits ); ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),sl, OrderTakeProfit (), 0 ,Red); if (ticket > 0 ) { Print ( "Trailing #2 Activated: " , OrderSymbol (), ": SL " ,sl, ": Ask " , Ask ); } else { iLastError = GetLastError(); } } //end if (Bid < NormalizeDouble(OrderOpenPrice()-TrailingStart*vPoint,Digits) } //end if (OrderType()==OP_SELL) } // end if(OrderSymbol() == Symbol() && OrderMagicNumber() ==Magic_Number_1) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ( OrderSymbol () == Symbol () && OrderMagicNumber () ==Magic_Number_2) { sl = OrderStopLoss (); // Stop Loss. tStopLoss = NormalizeDouble ( OrderStopLoss (), Digits ); // Stop Loss. if ( OrderType ()== OP_BUY ) { if ( Ask > NormalizeDouble ( OrderOpenPrice ()+TrailingStart* vPoint, Digits ) && tStopLoss < NormalizeDouble ( Bid -(TrailingStop+TrailingStep)*vPoint, Digits )) { tStopLoss = NormalizeDouble ( Bid -TrailingStop*vPoint, Digits ); ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),tStopLoss, OrderTakeProfit (), 0 ,Blue); if (ticket > 0 ) { Print ( "TrailingStop #2 Activated: " , OrderSymbol (), ": SL" , tStopLoss, ": Bid" , Bid ); } else { iLastError = GetLastError(); } } //end if(Ask> NormalizeDouble(OrderOpenPrice()+TrailingStart* vPoint,Digits) && tStopLoss < NormalizeDouble(Bid-(TrailingStop+TrailingStep)*vPoint,Digits)){ } //end if(OrderType()==OP_BUY){ //------------------------------------------------------------------------------------------------------------------------------------- if ( OrderType ()== OP_SELL ) { if ( Bid < NormalizeDouble ( OrderOpenPrice ()-TrailingStart*vPoint, Digits ) && (sl >( NormalizeDouble ( Ask +(TrailingStop+TrailingStep)*vPoint, Digits ))) || ( OrderStopLoss ()== 0 )) { sl = NormalizeDouble ( Ask +TrailingStop*vPoint, Digits ); ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),sl, OrderTakeProfit (), 0 ,Red); if (ticket > 0 ) { Print ( "Trailing #2 Activated: " , OrderSymbol (), ": SL " ,sl, ": Ask " , Ask ); } else { iLastError = GetLastError(); } } //end if (Bid < NormalizeDouble(OrderOpenPrice()-TrailingStart*vPoint,Digits) } //end if (OrderType()==OP_SELL) } // end if(OrderSymbol() == Symbol() && OrderMagicNumber() ==Magic_Number_2) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ( OrderSymbol () == Symbol () && OrderMagicNumber () ==Magic_Number_3) { sl = OrderStopLoss (); // Stop Loss. tStopLoss = NormalizeDouble ( OrderStopLoss (), Digits ); // Stop Loss. if ( OrderType ()== OP_BUY ) { ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),tStopLoss, OrderTakeProfit (), 0 ,Blue); if (ticket > 0 ) { Print ( "Stop Loss Unchanged" ); } else { iLastError = GetLastError(); } } //end if(OrderType()==OP_BUY) //------------------------------------------------------------------------------------------------------------------------------ if ( OrderType ()== OP_SELL ) { sl= OrderStopLoss (); // Stop Loss. ticket = OrderModify ( OrderTicket (), OrderOpenPrice (),sl, OrderTakeProfit (), 0 ,Red); if (ticket > 0 ) { Print ( "Trailing #2 Activated: " , OrderSymbol (), ": SL " ,sl, ": Ask " , Ask ); } else { iLastError = GetLastError(); } } //end if (OrderType()==OP_SELL) } // end if(OrderSymbol() == Symbol() && OrderMagicNumber() ==Magic_Number_3) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } //end for(cnt=OrdersTotal()-1;cnt>=0;cnt--) } // end if(OrdersTotal()>0) return ( 0 ); } // end void TrailOrder(double Trailingstart,double Trailingstop) bool closeBuyOrder( int iBuytype) { bool bClosed_; int Magic_Number_1,Magic_Number_2,Magic_Number_3; Set_Magic_Number(); if ( OrdersTotal ()> 0 ) { for ( int Counter= OrdersTotal ()- 1 ;Counter>= 0 ;Counter--) { OrderSelect (Counter, SELECT_BY_POS , MODE_TRADES ); if (iBuytype== OP_BUY && OrderType ()== OP_BUY ) { //------------------------------------------------------------------------------------------------------------------------------------ if ( OrderSymbol ()== Symbol () && OrderMagicNumber ()==Magic_Number_1) { RefreshRates (); OrderClose ( OrderTicket (), OrderLots (), NormalizeDouble ( Bid , Digits ), Slippage); } //------------------------------------------------------------------------------------------------------------------------------------- if ( OrderSymbol ()== Symbol () && OrderMagicNumber ()==Magic_Number_2) { RefreshRates (); OrderClose ( OrderTicket (), OrderLots (), NormalizeDouble ( Bid , Digits ), Slippage); } //------------------------------------------------------------------------------------------------------------------------------------- if ( OrderSymbol ()== Symbol () && OrderMagicNumber ()==Magic_Number_3) { RefreshRates (); Print ( "Don't Close this Thrid Order" ); } //------------------------------------------------------------------------------------------------------------------------------------- } //if(iBuytype==OP_BUY && OrderType()==OP_BUY) } //for(int Counter=OrdersTotal()-1;Counter>=0;Counter--) } //if(OrdersTotal()>0) return (bClosed_); } //end bool closeBuyOrder(int iBuytype) //========================================================================================== bool closeSellOrder( int iSelltype) { bool bClosed_; int Magic_Number_1,Magic_Number_2,Magic_Number_3; Set_Magic_Number(); if ( OrdersTotal ()> 0 ) { for ( int Counter= OrdersTotal ()- 1 ;Counter>= 0 ;Counter--) { if (! OrderSelect (Counter, SELECT_BY_POS , MODE_TRADES )) continue ; if (iSelltype== OP_SELL && OrderType ()== OP_SELL ) { //------------------------------------------------------------------------------------------------------------------------------------ if ( OrderSymbol ()== Symbol () && OrderMagicNumber ()==Magic_Number_1) { RefreshRates (); bClosed_ = OrderClose ( OrderTicket (), OrderLots (), NormalizeDouble ( Ask , Digits ),Slippage); } //------------------------------------------------------------------------------------------------------------------------------------- if ( OrderSymbol ()== Symbol () && OrderMagicNumber ()==Magic_Number_2) { RefreshRates (); bClosed_ = OrderClose ( OrderTicket (), OrderLots (), NormalizeDouble ( Ask , Digits ),Slippage); } //------------------------------------------------------------------------------------------------------------------------------------- if ( OrderSymbol ()== Symbol () && OrderMagicNumber ()==Magic_Number_3) { RefreshRates (); Print ( "Don't Close this Thrid Order" ); } //------------------------------------------------------------------------------------------------------------------------------------- } //end if(iSelltype==OP_SELL && OrderType()==OP_SELL) } //for(int Counter=OrdersTotal()-1;Counter>=0;Counter--) } //end if(OrdersTotal()>0) return (bClosed_); } //end bool closeSellOrder(int iSelltype) //========================================================================================== void Set_Magic_Number() { int Magic_Number_1,Magic_Number_2,Magic_Number_3; if (Order_Symbol== "EURUSD" ) { Magic_Number_1= 1301 ; Magic_Number_2= 1302 ; Magic_Number_3= 1303 ; } if (Order_Symbol== "GBPUSD" ) { Magic_Number_1= 1601 ; Magic_Number_2= 1602 ; Magic_Number_3= 1603 ; } if (Order_Symbol== "AUDUSD" ) { Magic_Number_1= 8701 ; Magic_Number_2= 8702 ; Magic_Number_3= 8703 ; } return ( 0 ); } Set_Magic_Number() 함수 와 혼동이 있습니다. 내가 올바르게 정의했는가? 또한 다른 함수에서 호출하는 동안 올바르게 작동합니까? 문안 인사 Tjipke de Vries 2014.03.09 23:09 #57 Arav007 : Set_Magic_Number() 함수와 혼동이 있습니다. 내가 올바르게 정의했는가? 또한 다른 함수에서 호출하는 동안 올바르게 작동합니까? 문안 인사 여기에서 귀하의 기호가 "EURUSD"가 아님을 읽었습니다. 올바른 기호를 사용해야 합니다 Arav007 2014.03.10 05:57 #58 deVries : 나는 여기에서 귀하의 기호가 "EURUSD"가 아니라는 것을 읽었습니다. 올바른 기호를 사용해야 합니다 문제가 되지 않습니다. 제가 EA를 테스트하고 있는 브로커의 심볼은 EURUSD,GBPUSD입니다.... 기호가 EURUSDpro인 브로커에 EA를 첨부하면 'pro'만 추가하겠습니다. 내 코드를 검토했습니까? 최소 수익 특성은 '실패'입니다. 거래의 손실/이익에 관계없이 실행될 때마다 열려 있는 모든 거래를 닫는 것입니다! 하지만 내 목표는 이렇지 않다. 거래가 이익 영역에 들어갔다가 시장이 다시 돌아오기 시작하면 이 '최소 이익' 기능이 그 거래는 내가 원하는 최소 이익으로 마감되었습니다. 그리고 여기에서도 '세 번째' 거래가 이 기능의 영향을 받는 것을 원하지 않습니다. 나는 그런 것을 쓰려고 노력했지만 지금은 작동하지 않습니다. '모두 닫기'/'열기' 도구 10포인트 3.mq4 더 타이트한 후행 정지 Tjipke de Vries 2014.03.10 07:16 #59 Arav007 : 문제가 되지 않습니다. 제가 EA를 테스트하고 있는 브로커의 심볼은 EURUSD,GBPUSD입니다.... 기호가 EURUSDpro인 브로커에 EA를 첨부하면 'pro'만 추가하겠습니다. 내 코드를 검토했습니까? 최소 수익 특성은 '실패'입니다. 거래의 손실/이익에 관계없이 실행될 때마다 열려 있는 모든 거래를 닫는 것입니다! 하지만 내 목표는 이렇지 않다. 거래가 이익 영역에 들어갔다가 시장이 다시 돌아오기 시작하면 이 '최소 이익' 기능이 그 거래는 내가 원하는 최소 이익으로 마감되었습니다. 그리고 여기에서도 '세 번째' 거래가 이 기능의 영향을 받는 것을 원하지 않습니다. 나는 그런 것을 쓰려고 노력했지만 지금은 작동하지 않습니다. 이것을 처리하는 방법을 모르기 때문에 너무 복잡하게 만듭니다. 더 많이 읽고 스스로 프로그래밍하려고 하면 할수록 더 복잡한 것을 만드는 것이 더 쉬워집니다. 그러나 하나의 거래에 대해 프로그램이 작동하도록 시작한 다음 나중에 더 많은 거래를 시도하는 경우 간단한 것부터 시작합니다. 많이 배워야 합니다. 간단하게 작성된 프로그램을 선택하고 테스트를 위해 약간 변경하면 당신은 그 프로그램이 어떻게 작동하는지 배울 수 있습니다 당신이 시작한 문제 내가 어떻게 할지 봐 //+------------------------------------------------------------------+ //| MACD Sample.mq4 | //| Copyright 2005-2014, MetaQuotes Software Corp. | //| https://www.mql4.com | //+------------------------------------------------------------------+ #property copyright "2005-2014, MetaQuotes Software Corp." #property link "https://www.mql4.com" input double TakeProfit = 50 ; input double Lots = 0.1 ; input int MagicNumber = 16384 ; input int TakeProfit1 = 15 ; input int TakeProfit2 = 25 ; input int TakeProfit3 = 0 ; input int StopLoss = 100 ; input double BreakEven = 10 ; input double BreakEvenSL = 5 ; input double TrailingStop = 30 ; input double TrailingStep = 30 ; input int SlippagePips = 3 ; input double MACDOpenLevel = 3.0 ; input double MACDCloseLevel= 2 ; input int MATrendPeriod = 26 ; int count,countbuy,countsell; //++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digitspips; // DoubleToStr(dbl/pips2dbl, Digitspips) int Slip; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit () { //--- if ( Digits % 2 == 1 ) // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 {pips2dbl = Point * 10 ; pips2points = 10 ; Digitspips = 1 ;} else {pips2dbl = Point ; pips2points = 1 ; Digitspips = 0 ;} // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl Slip = pips2points * SlippagePips; //Slippage //--- return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick ( void ) { double MacdCurrent,MacdPrevious; double SignalCurrent,SignalPrevious; double MaCurrent,MaPrevious; int cnt,ticket,total; //--- // initial data checks // it is important to make sure that the expert works with a normal // chart and the user did not make any mistakes setting external // variables (Lots, StopLoss, TakeProfit, // TrailingStop) in our case, we check TakeProfit // on a chart of less than 100 bars //--- if ( Bars < 100 ) { Print ( "bars less than 100" ); return ; } //--- if ((countbuy> 0 )||(countsell> 0 )) { int CMD; double SL,TP,price; int LastError = 0 ; RefreshRates (); if (countbuy> 0 ) { count=countbuy; CMD = OP_BUY ; price = Ask ; if (StopLoss> 0 )SL= price-StopLoss*pips2dbl; if (count== 3 && TakeProfit1> 0 )TP= price+TakeProfit1*pips2dbl; if (count== 2 && TakeProfit2> 0 )TP= price+TakeProfit2*pips2dbl; if (count== 1 && TakeProfit3> 0 )TP= price+TakeProfit3*pips2dbl; } else { count=countsell; CMD = OP_SELL ; price = Bid ; if (StopLoss> 0 )SL= price+StopLoss*pips2dbl; if (count== 3 && TakeProfit1> 0 )TP= price-TakeProfit1*pips2dbl; if (count== 2 && TakeProfit2> 0 )TP= price-TakeProfit2*pips2dbl; if (count== 1 && TakeProfit3> 0 )TP= price-TakeProfit3*pips2dbl; } ticket= OrderSend ( Symbol (), CMD, Lots, price , Slip, SL, TP, "macd sample" ,MagicNumber, 0 ,Green); if (ticket> 0 ) //Checking if the order was opened or not { OrderPrint (); countbuy--; countsell--; } else { LastError = GetLastError(); if (CMD== OP_BUY ) Print ( "Error sending buy order " +count+ ". Error code= " + LastError); if (CMD== OP_SELL ) Print ( "Error sending sell order " +count+ ". Error code= " + LastError); } if ((countbuy> 0 )||(countsell> 0 )) return ; } //--- to simplify the coding and speed up access data are put into internal variables MacdCurrent= iMACD ( NULL , 0 , 12 , 26 , 9 , PRICE_CLOSE , MODE_MAIN , 0 ); MacdPrevious= iMACD ( NULL , 0 , 12 , 26 , 9 , PRICE_CLOSE , MODE_MAIN , 1 ); SignalCurrent= iMACD ( NULL , 0 , 12 , 26 , 9 , PRICE_CLOSE , MODE_SIGNAL , 0 ); SignalPrevious= iMACD ( NULL , 0 , 12 , 26 , 9 , PRICE_CLOSE , MODE_SIGNAL , 1 ); MaCurrent= iMA ( NULL , 0 ,MATrendPeriod, 0 , MODE_EMA , PRICE_CLOSE , 0 ); MaPrevious= iMA ( NULL , 0 ,MATrendPeriod, 0 , MODE_EMA , PRICE_CLOSE , 1 ); //--- it is important to enter the market correctly, but it is more important to exit it correctly... total= 0 ; for (cnt = OrdersTotal ()- 1 ; cnt>= 0 ; cnt--) { if ( OrderSelect (cnt, SELECT_BY_POS , MODE_TRADES )== false ) break ; if ( OrderSymbol ()!= Symbol ()|| OrderMagicNumber ()!=MagicNumber) continue ; if ( OrderType ()<= OP_SELL) // check for opened position { total++; //--- long position is opened if ( OrderType ()== OP_BUY ) { //--- should it be closed? if (MacdCurrent> 0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDCloseLevel*pips2dbl)) { //--- close order OrderClose ( OrderTicket (), OrderLots (), Bid ,Slip,Violet); } //--- check for breakeven if (BreakEven> 0 ) { if ( Bid - OrderOpenPrice ()>=pips2dbl*BreakEven) { if ( OrderStopLoss ()< OrderOpenPrice ()) { //--- modify order if ( OrderTakeProfit ()> Point ) OrderModify ( OrderTicket (), OrderOpenPrice (), OrderOpenPrice ()+(BreakEvenSL*pips2dbl), OrderTakeProfit (), 0 ,Green); } } } //--- check for trailing stop if (TrailingStop> 0 ) { if ( OrderOpenPrice ()< OrderStopLoss ()) { if ( OrderStopLoss ()< Bid -pips2dbl*(TrailingStop+TrailingStep)) { //--- modify order OrderModify ( OrderTicket (), OrderOpenPrice (), Bid -pips2dbl*TrailingStop, OrderTakeProfit (), 0 ,Green); } } } } else // go to short position { //--- should it be closed? if (MacdCurrent< 0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs (MacdCurrent)>(MACDCloseLevel*pips2dbl)) { //--- close order and exit OrderClose ( OrderTicket (), OrderLots (), Ask ,Slip,Violet); } //--- check for breakeven if (BreakEven> 0 ) { if ( OrderOpenPrice ()- Ask >pips2dbl*BreakEven) { if ( OrderStopLoss ()> OrderOpenPrice ()) { //--- modify order if ( OrderTakeProfit ()> Point ) OrderModify ( OrderTicket (), OrderOpenPrice (), OrderOpenPrice ()-(BreakEvenSL*pips2dbl), OrderTakeProfit (), 0 ,Green); } } } //--- check for trailing stop if (TrailingStop> 0 ) { if (( OrderOpenPrice ()> OrderStopLoss ())&&( OrderStopLoss ()> Point )) { if ( OrderStopLoss ()>( Ask +pips2dbl*(TrailingStop+TrailingStep))) { //--- modify order OrderModify ( OrderTicket (), OrderOpenPrice (), Ask +pips2dbl*TrailingStop, OrderTakeProfit (), 0 ,Red); } } } } } } if (total< 1 ) { countbuy = 0 ; countsell = 0 ; //--- no opened orders identified if ( AccountFreeMargin ()<( 3000 *Lots))//3trades*1000 { Print ( "We have no money. Free Margin = " , AccountFreeMargin ()); return ; } //--- check for long position (BUY) possibility if (MacdCurrent< 0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs (MacdCurrent)>(MACDOpenLevel*pips2dbl) && MaCurrent>MaPrevious) { countbuy = 3 ; //we can open } //--- check for short position (SELL) possibility if (MacdCurrent> 0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && MacdCurrent>(MACDOpenLevel*pips2dbl) && MaCurrent<MaPrevious) { countsell = 3 ; //we can open } } //--- } //+------------------------------------------------------------------+ Symbol()에 대해 다른 입력이 필요하지 않음 3가지 매직넘버.. Tjipke de Vries 2014.03.10 11:26 #60 Arav007 : 문제가 되지 않습니다. 제가 EA를 테스트하고 있는 브로커의 심볼은 EURUSD,GBPUSD입니다.... 기호가 EURUSDpro인 브로커에 EA를 첨부하면 'pro'만 추가하겠습니다. 내 코드를 검토했습니까? 최소 수익 기능은 '실패'입니다. 거래의 손실/이익에 관계없이 실행될 때마다 열려 있는 모든 거래를 닫는 것입니다! 하지만 내 목표는 이렇지 않다. 거래가 이익 영역에 들어갔다가 시장이 다시 돌아오기 시작하면 이 '최소 이익' 기능이 그 거래는 내가 원하는 최소 이익으로 마감되었습니다. 그리고 여기에서도 '세 번째' 거래가 이 기능의 영향을 받는 것을 원하지 않습니다. 나는 그런 것을 쓰려고 노력했지만 지금은 작동하지 않습니다. 나는 당신의 코드를 컴파일했습니다 80 오류 6 경고 대부분 선언되지 않은 식별자 모든 식별자가 선언된 코드가 필요합니다. 파일이 너무 크면 첨부 파일을 컴파일하고 오류를 확인하십시오 . 1234567 새 코멘트 트레이딩 기회를 놓치고 있어요: 무료 트레이딩 앱 복사용 8,000 이상의 시그널 금융 시장 개척을 위한 경제 뉴스 등록 로그인 공백없는 라틴 문자 비밀번호가 이 이메일로 전송될 것입니다 오류 발생됨 Google으로 로그인 웹사이트 정책 및 이용약관에 동의합니다. 계정이 없으시면, 가입하십시오 MQL5.com 웹사이트에 로그인을 하기 위해 쿠키를 허용하십시오. 브라우저에서 필요한 설정을 활성화하시지 않으면, 로그인할 수 없습니다. 사용자명/비밀번호를 잊으셨습니까? Google으로 로그인
중개인이 OrderComment를 덮어쓸 수 있습니다.
당신은 원하고 있습니다 ... 이제 내 요구 사항에 따라 가격이 이익으로 7 pip [103.603] 일 때 손절매
첫 번째와 두 번째 거래는 1핍 이익[103.543]이 되고 세 번째 거래의 손절매는 103.386으로 유지됩니다.
extern int BreakEven = 7을 만듭니다.
(* 10 ) pipvalue를 얻기 위해 5자리 브로커에서 수정
오, 예, 이것은 확실히 단점입니다. 저녁부터 내 모든 노력은 이제 헛된 것입니다!
' 주문댓글 ' 기능에 따라 거래를 구분하는 방법을 시도해보고 코드를 작성했습니다.
어쨌든, 주어진 코드는 손절매 부분을 BE 또는 원하는 지점으로 이동하지만 여전히 '세 번째' 거래에 대한 내 문제는 해결되지 않습니다.
나는 또한 코드의 이 BE 움직이는 부분을 가지고 있지만 세 번째 거래를 위해 움직이지 않는 SL에 갇혔습니다.
다른 아이디어가 떠올랐습니다. 지금 시도해 보세요.
그리고 이것이 유효했습니까?
string comment_sell="판매 주문";
SellOrder=OrderSend(Symbol(), iOrderType_Sell, LotSize, OpenPrice, Slippage, dStopLossPrice, dTakeProfitPrice, comment_sell , MagicNumber, 0, Red);
if (OrderComment()=="comment_sell") // ?
유효한가요?
EA를 EURUSD 차트 에 첨부했다고 가정해 보겠습니다.
if (Order_Symbol()==EURUSD)
현재 차트가 EURUSD인지 여부를 비교합니까?
여기까지는 '매직넘버'를 통해 주문을 구별하는 방법입니다.
중괄호는 균형이 맞지 않습니다.
이게 가능해?
이 방법으로 3개의 다른 매직넘버를 찾아야 합니다.
내가 할 수있는 것처럼 보입니다.
좋아, 지속적으로 열심히 일한 후(적어도 나에게는) EA를 '오류 무료'로 만들었습니다!
변경 사항 게시:
Set_Magic_Number() 함수 와 혼동이 있습니다.
내가 올바르게 정의했는가? 또한 다른 함수에서 호출하는 동안 올바르게 작동합니까?
문안 인사
Set_Magic_Number() 함수와 혼동이 있습니다.
내가 올바르게 정의했는가? 또한 다른 함수에서 호출하는 동안 올바르게 작동합니까?
문안 인사
여기에서 귀하의 기호가 "EURUSD"가 아님을 읽었습니다.
올바른 기호를 사용해야 합니다
나는 여기에서 귀하의 기호가 "EURUSD"가 아니라는 것을 읽었습니다.
올바른 기호를 사용해야 합니다
문제가 되지 않습니다. 제가 EA를 테스트하고 있는 브로커의 심볼은 EURUSD,GBPUSD입니다....
기호가 EURUSDpro인 브로커에 EA를 첨부하면 'pro'만 추가하겠습니다.
내 코드를 검토했습니까?
최소 수익 특성은 '실패'입니다.
거래의 손실/이익에 관계없이 실행될 때마다 열려 있는 모든 거래를 닫는 것입니다!
하지만 내 목표는 이렇지 않다.
거래가 이익 영역에 들어갔다가 시장이 다시 돌아오기 시작하면 이 '최소 이익' 기능이
그 거래는 내가 원하는 최소 이익으로 마감되었습니다.
그리고 여기에서도 '세 번째' 거래가 이 기능의 영향을 받는 것을 원하지 않습니다.
나는 그런 것을 쓰려고 노력했지만 지금은 작동하지 않습니다.
문제가 되지 않습니다. 제가 EA를 테스트하고 있는 브로커의 심볼은 EURUSD,GBPUSD입니다....
기호가 EURUSDpro인 브로커에 EA를 첨부하면 'pro'만 추가하겠습니다.
내 코드를 검토했습니까?
최소 수익 특성은 '실패'입니다.
거래의 손실/이익에 관계없이 실행될 때마다 열려 있는 모든 거래를 닫는 것입니다!
하지만 내 목표는 이렇지 않다.
거래가 이익 영역에 들어갔다가 시장이 다시 돌아오기 시작하면 이 '최소 이익' 기능이
그 거래는 내가 원하는 최소 이익으로 마감되었습니다.
그리고 여기에서도 '세 번째' 거래가 이 기능의 영향을 받는 것을 원하지 않습니다.
나는 그런 것을 쓰려고 노력했지만 지금은 작동하지 않습니다.
이것을 처리하는 방법을 모르기 때문에 너무 복잡하게 만듭니다.
더 많이 읽고 스스로 프로그래밍하려고 하면 할수록 더 복잡한 것을 만드는 것이 더 쉬워집니다.
그러나 하나의 거래에 대해 프로그램이 작동하도록 시작한 다음 나중에 더 많은 거래를 시도하는 경우 간단한 것부터 시작합니다.
많이 배워야 합니다.
간단하게 작성된 프로그램을 선택하고 테스트를 위해 약간 변경하면
당신은 그 프로그램이 어떻게 작동하는지 배울 수 있습니다
당신이 시작한 문제
내가 어떻게 할지 봐
Symbol()에 대해 다른 입력이 필요하지 않음
3가지 매직넘버..
문제가 되지 않습니다. 제가 EA를 테스트하고 있는 브로커의 심볼은 EURUSD,GBPUSD입니다....
기호가 EURUSDpro인 브로커에 EA를 첨부하면 'pro'만 추가하겠습니다.
내 코드를 검토했습니까?
최소 수익 기능은 '실패'입니다.
거래의 손실/이익에 관계없이 실행될 때마다 열려 있는 모든 거래를 닫는 것입니다!
하지만 내 목표는 이렇지 않다.
거래가 이익 영역에 들어갔다가 시장이 다시 돌아오기 시작하면 이 '최소 이익' 기능이
그 거래는 내가 원하는 최소 이익으로 마감되었습니다.
그리고 여기에서도 '세 번째' 거래가 이 기능의 영향을 받는 것을 원하지 않습니다.
나는 그런 것을 쓰려고 노력했지만 지금은 작동하지 않습니다.
나는 당신의 코드를 컴파일했습니다 80 오류 6 경고
대부분 선언되지 않은 식별자
모든 식별자가 선언된 코드가 필요합니다.
파일이 너무 크면 첨부
파일을 컴파일하고 오류를 확인하십시오 .