후행 정지 및 후행 이익 - 페이지 2

 
Arav007 :


죄송합니다. 사실 제가 조금 혼란스러워졌습니다.

경우 (iOpenOrders_Buy = 3 )

여기서 Total Opened Buy 주문이 '3'이면 코드는 다음 부분으로 진행됩니다.

if (iOpenOrders_Buy > 0 )

그런 다음 Total Opened Buy 주문의 수가 '0'보다 크면 다음으로 진행됩니다.

if (iOpenOrders_Buy == 3 )

그런 다음 Open Buy 주문 수가 3이면 BuyOrder_1이 열리고 '2' 같으면 BuyOrder_2가 열리고 BuyOrder_3은 Opened Buy 주문 수가 1과 같습니다.

내 말이 맞아?

 double dTakeProfitPrice_1= 10 ;

double dTakeProfitPrice_2= 20 ;

double dTakeProfitPrice_3= 0 ;
double BuyOrder_1,.......,.......;
if (Buy Condition Met && iOpenOrders_Buy == 0 )
{

iOpenOrders_Buy = 3 ;

{

if (iOpenOrders_Buy  > 0 ) // we have to open new Buy orders

{

if (iOpenOrders_Buy == 3 )
         {
         BuyOrder_1= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1, "Buy Order" ,MagicNumber, 0 ,Blue);
         if (BuyOrder_1 > 0 ).......
         

         }
if (iOpenOrders_Buy == 2 )
         {
         BuyOrder_2= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_2, "Buy Order" ,MagicNumber, 0 ,Blue);
....



if (iOpenOrders_Buy == 1 )
         {
         BuyOrder_3= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_3, "Buy Order" ,MagicNumber, 0 ,Blue);
....
}

변경된 코드를 다시 보니 맞나요?? 괜찮나요??
 
deVries :

변경된 코드를 다시 보니 맞나요?? 괜찮나요??


나는 그렇게 생각하지 않는다.

if (구매 조건 충족 && iOpenOrders_Buy == 0 )

즉, '매수조건이 충족됨'이고 '오픈매수' 주문이 없는 것 아닌가요?

그런 다음 코드는 iOpenOrders_Buy = 3 인 다음 줄로 진행합니다 .

그래서 EA에 이미 3개의 열린 주문이 있다고 들었습니다. 맞죠?

그러나 Open Buy 주문이 없다는 것을 알고 코드를 입력하면 iOpenOrders_Buy = 3 을 할당하는 이유는 무엇입니까 ? ?

또한 목표는 세 가지 거래 중 하나가 계속 실행되고 마지막 거래가 마감될 때 '신규' 매수 주문만 열립니다.

그래서 이것은 있어야합니다

if (iOpenOrders_Buy== 0 ) // 열린 구매 주문이 없으므로 새로운 구매 주문을 열어야 합니다.


EA가 매수 조건을 얻게 되면 다른 이익실현 으로 3개의 거래를 엽니다.

그런 다음 두 거래가 어쨌든(TP 또는 SL에 의해) 마감되면 세 번째 거래는 계속 실행됩니다.

 double dTakeProfitPrice_1= 10 ;

double dTakeProfitPrice_2= 20 ;

double dTakeProfitPrice_3= 0 ;

double BuyOrder_1,BuyOrder_2,BuyOrder_3;  

iMaxOrders= 3 ; 

iOpenOrders_Buy = CntOrd(iOrderType_Buy,MagicNumber, Symbol ());   //counting open buy orders. 

if (Buy Condition Met && iOpenOrders_Buy == 0 ) //Buy condition has met and there is no Open Buy Order

{ 

if (iOpenOrders_Buy < iMaxOrders) //This will Limit the desired number of orders; Though this is not necessary.

{

BuyOrder_1= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1, "Buy Order" ,MagicNumber, 0 ,Blue); 

//First order opened with TP1 

BuyOrder_2= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_2, "Buy Order" ,MagicNumber, 0 ,Blue);

//Second order opened with TP2  

BuyOrder_3= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_3, "Buy Order" ,MagicNumber, 0 ,Blue);

////Third order opened with TP3  

} 

} 

else {

print ( "There is already a Running Order" )

} 

이에 대해 어떻게 생각하세요? 위와 같이 하면 되지 않을까요?

문안 인사

 
Arav007 :


나는 그렇게 생각하지 않는다.


이에 대해 어떻게 생각하세요? 위와 같이 하면 되지 않을까요?

문안 인사

아니요 주문 보내기가 성공하지 못하면 어떻게 됩니까? 실패할 경우 열어야 하는 거래를 어떻게 확인 합니까?

iOpenOrders_Buy = 3 을 할당하는 이유는 무엇입니까 ? ?

주문 전송이 성공하면 3개의 새로운 거래를 열어야 합니다. iOpenOrders_Buy new value

만약 iOpenOrders_Buy는 0이 됩니다. 3개의 거래가 있습니다.

 
deVries :

아니요 주문 보내기가 성공하지 못하면 어떻게 됩니까? 실패할 경우 열어야 하는 거래를 어떻게 확인합니까?

iOpenOrders_Buy = 3 을 할당하는 이유 ; ?

주문 전송이 성공하면 3개의 새로운 거래를 열어야 합니다. iOpenOrders_Buy new value

만약 iOpenOrders_Buy는 0이 됩니다. 3번의 거래가 있습니다.

 int iLastError;

 for (count=iMaxOrders; count> 0 ; count--)

{

if (count== 3 ) {

 BuyOrder_1= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1, "Buy Order" ,MagicNumber, 0 ,Blue);

if (BuyOrder_1> 0 ) //Checking if the order was opened or not

{ 

Print ( "Buy Order 1 Opened successfully" );

}

else {

 Print ( "Order Sending Error" );

iLastError = GetLastError();

iMaxOrders= 3 ; //Setting iMaxOrders to 3 again thus it goes back and try to open that order again

} 

}

 if (count== 2 ) {

 BuyOrder_2= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_2, "Buy Order" ,MagicNumber, 0 ,Blue);

if (BuyOrder_2> 0 ) {

Print ( "Buy Order 2 Opened successfully" );

}

else {

 Print ( "Order Sending Error" );

iLastError = GetLastError();

iMaxOrders= 2 ;

}  

}

if (count== 1 ) {

 BuyOrder_3= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_3, "Buy Order" ,MagicNumber, 0 ,Blue);

if (BuyOrder_3> 0 ) {

Print ( "Buy Order 3 Opened successfully" );

}

else {

 Print ( "Order Sending Error" );

iLastError = GetLastError();

iMaxOrders= 1 ;

}  

}

} 

예, 'Ordersend()'가 주문을 열지 못할 가능성이 매우 높습니다.

이제 그 이유를 이해했습니다.

if (iOpenOrders_Buy > 0 ) // 새로운 구매 주문 을 열어야 합니다.

귀하의 코드에 사용되었습니다. 이미 iopendOrders=3으로 설정했으므로 이를 확인할 것입니다.

그러나 나중에 iopendOrders의 값이 계속 변경되는 방식에 대해 혼란스러워했습니다.

아마도 내 제한된 두뇌로 인해 메커니즘을 파악하지 못했을 것입니다. 그래서 위의 방법으로 당신의 논리를 구현하려고했습니다.

이것이 당신이 주어진 코드에 언급한 것입니까?

문안 인사

 
Arav007 :

예, 'Ordersend()'가 주문을 열지 못할 가능성이 매우 높습니다.

이제 그 이유를 이해했습니다.

if (iOpenOrders_Buy > 0 ) // 새로운 구매 주문을 열어야 합니다.

귀하의 코드에 사용되었습니다. 이미 iopendOrders=3으로 설정했으므로 이를 확인할 것입니다.

그러나 나중에 iopendOrders의 값이 계속 변경되는 방식에 대해 혼란스러워했습니다.

아마도 내 제한된 두뇌로 인해 메커니즘을 파악하지 못했을 것입니다. 그래서 위의 방법으로 당신의 논리를 구현하려고했습니다.

이것이 당신이 주어진 코드에 언급한 것입니까?

문안 인사


 if (BuyOrder_1> 0 ) //Checking if the order was opened or not

{ 

Print ( "Buy Order 1 Opened successfully" );
count = count - 1;
}

 
deVries :



신경쓰지 마세요. 하지만 다시 혼란스러워졌습니다!

내가 사용하는 경우

카운트=카운트-1; ~ 후에

인쇄 ( " 구매 주문 1이 성공적으로 열렸습니다" );

즉, 첫 번째 구매 주문이 열리면 count 값이 1 감소합니다.

따라서 다음 함수에 들어갈 때 다음 'if' 조건은 다음과 같습니다.

if (count== 2 ) {}

count의 값은 '2'가 되었습니다. [카운트=3-1=2]

이게 옳은 거니?

 
Arav007 :


제발 신경쓰지 마세요. 하지만 다시 저는 혼란스러워졌습니다!

내가 사용하는 경우

카운트=카운트-1; ~ 후에

인쇄 ( "구매 주문 1이 성공적으로 열렸습니다" );

즉, 첫 번째 구매 주문이 열리면 count 값이 1 감소합니다.

따라서 다음 함수에 들어갈 때 다음 'if' 조건은 다음과 같습니다.

if (count== 2 ) {}

count의 값은 '2'가 되었습니다. [카운트=3-1=2]

이게 옳은 거니?


그것을 시도하십시오 .... 약간의 테스트를 수행
 
deVries :

그것을 시도하십시오 .... 약간의 테스트를 수행


피곤하고 이것이 결과입니다.

아마도 '구매 전 마감 매도 주문' 코드를 올바른 위치에 배치하지 못했을 것입니다. 따라서 원래 코드에 위배되지만 판매 및 구매를 모두 가져옵니다.

그리고 총 '4' 구매 주문이 있습니다!

나는 실패했다 :(

                 double OpenPrice= Ask ;

                 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 );
                
 for ( int count=iMaxOrders; count> 0 ; count--)

{

if (count== 3 ) {

 BuyOrder_1= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1, "Buy Order" ,MagicNumber, 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;
                                iLastError = 0 ;
                                count = count - 1 ; 

}

else {

 iLastError = GetLastError();
                                
                                sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + "    Error sending buy order 1. Error code=" + ErrorDescription(iLastError);

iMaxOrders= 3 ; //Setting iMaxOrders to 3 again thus it goes back and try to open that order again

} 

}

 if (count== 2 ) {

 BuyOrder_2= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_2, "Buy Order" ,MagicNumber, 0 ,Blue);

if (BuyOrder_2> 0 ) { 

sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + "    Buy order 2 sent successfully. Ticket=" + BuyOrder_2;
                                iLastError = 0 ;
                                count = count - 1 ; 

}

else {

 iLastError = GetLastError();
                                
                                sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + "    Error sending buy order 2. Error code=" + ErrorDescription(iLastError);

iMaxOrders= 2 ; //Setting iMaxOrders to 2 again thus it goes back and try to open that order again

} 

}

if (count== 1 ) {

 BuyOrder_3= OrderSend ( Symbol (), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_3, "Buy Order" ,MagicNumber, 0 ,Blue);

if (BuyOrder_3> 0 ) {

sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + "    Buy order 2 sent successfully. Ticket=" + BuyOrder_3;
                                iLastError = 0 ;
                                count = count - 1 ; 
}

else {

  iLastError = GetLastError();
                                
                                sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + "    Error sending buy order 2. Error code=" + ErrorDescription(iLastError);

iMaxOrders= 1 ; //Setting iMaxOrders to 1 again thus it goes back and try to open that order again

}  

}
 

opps, iOpenOrders_Buy == 0 을 넣는 것을 잊었습니다.

이제 이것을 가지고 다시 테스트합니다.

 
double OpenPrice=Ask;

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);
                
//some condition
if(Ask>High[1] && OrdersTotal()<1)int count=3; //(int count=iMaxOrders; count>0; count--)
{
iLastError = 0;
   if (count==3) 
    {
    BuyOrder_1=OrderSend(Symbol(), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_1, "Buy Order",MagicNumber, 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);
          iMaxOrders=3; //Setting iMaxOrders to 3 again thus it goes back and try to open that order again
          } 
    }

   if (count==2) 
    {
    BuyOrder_2=OrderSend(Symbol(), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_2, "Buy Order",MagicNumber, 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);
          iMaxOrders=2; //Setting iMaxOrders to 3 again thus it goes back and try to open that order again
          } 
    }

   if (count==1) 
    {
    BuyOrder_3=OrderSend(Symbol(), iOrderType_Buy, LotSize,OpenPrice,Slippage,dStopLossPrice,dTakeProfitPrice_3, "Buy Order",MagicNumber, 0,Blue);
    if (BuyOrder_3>0) 
      {
      sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + "    Buy order 2 sent successfully. Ticket=" + BuyOrder_3;
      iLastError = 0;
      count = count - 1; 
      }
     else {
          iLastError = GetLastError();                               
          sLog_CheckBuyConditions = sLog_CheckBuyConditions + sNL + "    Error sending buy order 2. Error code=" + ErrorDescription(iLastError);
          iMaxOrders=1; //Setting iMaxOrders to 3 again thus it goes back and try to open that order again
          }
    }  
}    //all code in red not needed