MQL4 및 MQL5에 대한 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론 - 페이지 63 1...565758596061626364656667686970...1953 새 코멘트 [삭제] 2017.01.09 09:04 #621 Vitaly Muzichenko : 기존 막대를 확인 중입니다. double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 ); 가격이 오르고 레벨 70을 넘어 무역에 진입합니다. 막대가 닫히면 이미 RSI가 더 낮은 것을 볼 수 있지만 그 전에는 더 높았다가 다시 수준 아래로 돌아갔습니다. 닫힌 막대를 확인하면 이런 일이 발생하지 않고 확인된 신호에 항목이 표시됩니다. 이중 rsi= iRSI ( _Symbol , 0 ,RSIperiod , PRICE_CLOSE , 1 ); 이중 rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 ); 분명한. 고맙습니다. [삭제] 2017.01.09 09:44 #622 다음과 같이 작성: (아마도 틀릴 수 있음) double tp,sl,OrderBuy= 0 ,OrderSell= 0 ; double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell; int tiket; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit () { return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick () { OrderBuy= 0 ; OrderSell= 0 ; for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) //Цикл по всем ордерам { if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ) && OrderSymbol ()== Symbol () && OrderMagicNumber ()==MagicNumber) //Выбрали ордер { if ( OrderType ()== OP_BUY ) { OrderBuy++; //Кол. покупок } if ( OrderType ()== OP_SELL ) { OrderSell++; //Кол. продаж } } } double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 ); double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 ); double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 ); //+------------------------------------------------------------------+ double StopLossLevel; double TakeProfitLevel; if (StopLoss> 0 ) StopLossLevel= Bid -StopLoss* Point ; else StopLossLevel= 0.0 ; if (TakeProfit> 0 ) TakeProfitLevel= Ask +TakeProfit* Point ; else TakeProfitLevel= 0.0 ; tpBuy= NormalizeDouble ( Ask +TakeProfit* _Point , _Digits ); slBuy= NormalizeDouble ( Bid -StopLoss* _Point , _Digits ); tpSell= NormalizeDouble ( Bid -TakeProfit* _Point , _Digits ); slSell= NormalizeDouble ( Ask +StopLoss* _Point , _Digits ); ///--- if (OrderBuy== 0 && rsi>Urov_70 && rsi1<Urov_70 && rsi2<Urov_70) { tiket= OrderSend ( _Symbol , OP_BUY ,Lot, Ask ,slippage,slBuy,tpBuy, NULL ,MagicNumber, 0 , clrBlue ); if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ()); } if (OrderSell== 0 && rsi<Urov_30 && rsi1>Urov_30 && rsi2>Urov_30) { tiket= OrderSend ( _Symbol , OP_SELL ,Lot, Bid ,slippage,slSell,tpSell, NULL ,MagicNumber, 0 , clrRed ); if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ()); } } //+------------------------------------------------------------------+ 결과는 다음과 같습니다. 교차점이 없을 때 주문이 열립니다... Any questions from newcomers Questions from Beginners MQL4 초보자의 질문 MQL4 MT4 Vitaly Muzichenko 2017.01.09 09:51 #623 Ibragim Dzhanaev : 다음과 같이 작성: (아마도 틀릴 수 있음) } } double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 ); double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 ); double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 ); //+------------------------------------------------------------------+ double StopLossLevel; 결과는 다음과 같습니다. 교차점이 없을 때 주문이 열립니다... 왜 현재 막대가 필요합니까? double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 ); ??? 재작성된 코드는 이전과 정확히 동일한 조건을 충족합니다. 0 막대에서 가격이 수준을 넘고 거래가 열렸습니다. 나중에 가격이 다시 반환되고 RSI가 수준 아래로 반환되었습니다. 결과적으로 막대가 닫힌 후, 더 이상 신호가 없습니다. 계산에 영점 막대를 사용하지 마십시오. [삭제] 2017.01.09 10:12 #624 Vitaly Muzichenko : 왜 현재 막대가 필요한가요? double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 ); ??? 재작성된 코드는 이전과 정확히 동일한 조건을 충족합니다. 0 막대에서 가격이 수준을 넘고 거래가 열렸습니다. 나중에 가격이 다시 반환되고 RSI가 수준 아래로 반환되었습니다. 결과적으로 막대가 닫힌 후, 더 이상 신호가 없습니다. 계산에 영점 막대를 사용하지 마십시오. 공장. 고맙습니다. [삭제] 2017.01.09 11:33 #625 오류가 발생하는 이유를 알려주십시오. double tp,sl,OrderBuy= 0 ,OrderSell= 0 ; double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell; int tiket; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit () { return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick () { OrderBuy= 0 ; OrderSell= 0 ; for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) //Цикл по всем ордерам { if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ) && OrderSymbol ()== Symbol () && OrderMagicNumber ()==MagicNumber) //Выбрали ордер { if ( OrderType ()== OP_BUY ) { OrderBuy++; //Кол. покупок } if ( OrderType ()== OP_SELL ) { OrderSell++; //Кол. продаж } } } //double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0); double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 ); double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 ); //+------------------------------------------------------------------+ double StopLossLevel; double TakeProfitLevel; if (StopLoss> 0 ) StopLossLevel= Bid -StopLoss* Point ; else StopLossLevel= 0.0 ; if (TakeProfit> 0 ) TakeProfitLevel= Ask +TakeProfit* Point ; else TakeProfitLevel= 0.0 ; tpBuy= NormalizeDouble ( Ask +TakeProfit* _Point , _Digits ); slBuy= NormalizeDouble ( Bid -StopLoss* _Point , _Digits ); tpSell= NormalizeDouble ( Bid -TakeProfit* _Point , _Digits ); slSell= NormalizeDouble ( Ask +StopLoss* _Point , _Digits ); ///--- if (CountBuy()+CountSell()== 0 && rsi1>Urov_70 && rsi2<Urov_70) { tiket= OrderSend ( _Symbol , OP_BUY ,Lot, Ask ,slippage,slBuy,tpBuy, NULL ,MagicNumber, 0 , clrBlue ); if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ()); } if (CountBuy()+CountSell()== 0 && rsi1<Urov_30 && rsi2>Urov_30) { tiket= OrderSend ( _Symbol , OP_SELL ,Lot, Bid ,slippage,slSell,tpSell, NULL ,MagicNumber, 0 , clrRed ); if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ()); } } //+------------------------------------------------------------------+ int CountBuy() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--); { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true ) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY ) count++; } } return (count); } //+------------------------------------------------------------------+ int CountSell() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--); { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true ) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL ) count++; } } return (count); } //+------------------------------------------------------------------+ Any questions from newcomers Questions from Beginners MQL4 초보자의 질문 MQL4 MT4 Sergey Gritsay 2017.01.09 11:40 #626 Ibragim Dzhanaev : 오류가 발생하는 이유를 알려주십시오. double tp,sl,OrderBuy= 0 ,OrderSell= 0 ; double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell; int tiket; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit () { return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick () { OrderBuy= 0 ; OrderSell= 0 ; for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) //Цикл по всем ордерам { if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ) && OrderSymbol ()== Symbol () && OrderMagicNumber ()==MagicNumber) //Выбрали ордер { if ( OrderType ()== OP_BUY ) { OrderBuy++; //Кол. покупок } if ( OrderType ()== OP_SELL ) { OrderSell++; //Кол. продаж } } } //double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0); double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 ); double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 ); //+------------------------------------------------------------------+ double StopLossLevel; double TakeProfitLevel; if (StopLoss> 0 ) StopLossLevel= Bid -StopLoss* Point ; else StopLossLevel= 0.0 ; if (TakeProfit> 0 ) TakeProfitLevel= Ask +TakeProfit* Point ; else TakeProfitLevel= 0.0 ; tpBuy= NormalizeDouble ( Ask +TakeProfit* _Point , _Digits ); slBuy= NormalizeDouble ( Bid -StopLoss* _Point , _Digits ); tpSell= NormalizeDouble ( Bid -TakeProfit* _Point , _Digits ); slSell= NormalizeDouble ( Ask +StopLoss* _Point , _Digits ); ///--- if (CountBuy()+CountSell()== 0 && rsi1>Urov_70 && rsi2<Urov_70) { tiket= OrderSend ( _Symbol , OP_BUY ,Lot, Ask ,slippage,slBuy,tpBuy, NULL ,MagicNumber, 0 , clrBlue ); if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ()); } if (CountBuy()+CountSell()== 0 && rsi1<Urov_30 && rsi2>Urov_30) { tiket= OrderSend ( _Symbol , OP_SELL ,Lot, Bid ,slippage,slSell,tpSell, NULL ,MagicNumber, 0 , clrRed ); if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ()); } } //+------------------------------------------------------------------+ int CountBuy() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--); { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true ) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY ) count++; } } return (count); } //+------------------------------------------------------------------+ int CountSell() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--); { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true ) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL ) count++; } } return (count); } //+------------------------------------------------------------------+ 그런데 여기 for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--); 그것은해야한다 for ( int trade= OrdersTotal ()- 1 ; trade>= 0 ; trade--); 그렇지 않으면 마지막 주문을 놓칠 것입니다 Vitaly Muzichenko 2017.01.09 11:50 #627 Ibragim Dzhanaev : 오류가 발생하는 이유를 알려주십시오. for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--); { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true ) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL ) count++; } } return (count); } //+------------------------------------------------------------------+ 추가의 ";" int CountBuy() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<< { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY ) count++; } } return (count); } //+------------------------------------------------------------------+ int CountSell() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<< { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL ) count++; } } return (count); } 따라서 다음과 같은 경우 더 좋을 것입니다. for ( int trade= 0 ; trade< OrdersTotal (); trade++) [삭제] 2017.01.09 12:03 #628 Sergey Gritsay : 그런데 여기 for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--); 그것은해야한다 for ( int trade= OrdersTotal ()- 1 ; trade>= 0 ; trade--); 그렇지 않으면 마지막 주문을 놓칠 것입니다 고맙습니다. [삭제] 2017.01.09 12:04 #629 Vitaly Muzichenko : 추가의 ";" int CountBuy() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<< { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY ) count++; } } return (count); } //+------------------------------------------------------------------+ int CountSell() { int count= 0 ; for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<< { if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )) { if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL ) count++; } } return (count); } 따라서 다음과 같은 경우 더 좋을 것입니다. for ( int trade= 0 ; trade< OrdersTotal (); trade++) 고맙습니다. Mickey Moose 2017.01.10 21:29 #630 안녕하세요 여러분, 표현을 쓰는 방법 다섯 번째 로트는 로트 1과 4 주문의 합과 같습니다. 티켓 정의를 통해 첫 번째 또는 마지막을 찾을 수 있습니다. 현재 그리드의 지속적인 변화를 감안할 때 중간체를 찾는 방법은 무엇입니까? 각 주문은 어떻게든 어딘가에 저장되어야 함을 의미합니다. 글쎄, 차이가 있습니까? ~ 사이 void OnTick () { if uslovie1== true {...} if uslovie2== true {...} if uslovie3== true {...} }И void OnTick () { { if uslovie1== true {...} else if {...} else if {...} } } Any questions from newcomers 초보자의 질문 MQL4 MT4 [경고, 주제 닫힘!] 포럼을 1...565758596061626364656667686970...1953 새 코멘트 트레이딩 기회를 놓치고 있어요: 무료 트레이딩 앱 복사용 8,000 이상의 시그널 금융 시장 개척을 위한 경제 뉴스 등록 로그인 공백없는 라틴 문자 비밀번호가 이 이메일로 전송될 것입니다 오류 발생됨 Google으로 로그인 웹사이트 정책 및 이용약관에 동의합니다. 계정이 없으시면, 가입하십시오 MQL5.com 웹사이트에 로그인을 하기 위해 쿠키를 허용하십시오. 브라우저에서 필요한 설정을 활성화하시지 않으면, 로그인할 수 없습니다. 사용자명/비밀번호를 잊으셨습니까? Google으로 로그인
기존 막대를 확인 중입니다. double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 );
가격이 오르고 레벨 70을 넘어 무역에 진입합니다. 막대가 닫히면 이미 RSI가 더 낮은 것을 볼 수 있지만 그 전에는 더 높았다가 다시 수준 아래로 돌아갔습니다.
닫힌 막대를 확인하면 이런 일이 발생하지 않고 확인된 신호에 항목이 표시됩니다.
이중 rsi= iRSI ( _Symbol , 0 ,RSIperiod , PRICE_CLOSE , 1 );
이중 rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 );
다음과 같이 작성: (아마도 틀릴 수 있음)
double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ()
{
OrderBuy= 0 ; OrderSell= 0 ;
for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) //Цикл по всем ордерам
{
if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ) && OrderSymbol ()== Symbol () && OrderMagicNumber ()==MagicNumber) //Выбрали ордер
{
if ( OrderType ()== OP_BUY )
{
OrderBuy++; //Кол. покупок
}
if ( OrderType ()== OP_SELL )
{
OrderSell++; //Кол. продаж
}
}
}
double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 );
double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 );
double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 );
//+------------------------------------------------------------------+
double StopLossLevel;
double TakeProfitLevel;
if (StopLoss> 0 ) StopLossLevel= Bid -StopLoss* Point ; else StopLossLevel= 0.0 ;
if (TakeProfit> 0 ) TakeProfitLevel= Ask +TakeProfit* Point ; else TakeProfitLevel= 0.0 ;
tpBuy= NormalizeDouble ( Ask +TakeProfit* _Point , _Digits );
slBuy= NormalizeDouble ( Bid -StopLoss* _Point , _Digits );
tpSell= NormalizeDouble ( Bid -TakeProfit* _Point , _Digits );
slSell= NormalizeDouble ( Ask +StopLoss* _Point , _Digits );
///---
if (OrderBuy== 0 && rsi>Urov_70 && rsi1<Urov_70 && rsi2<Urov_70)
{
tiket= OrderSend ( _Symbol , OP_BUY ,Lot, Ask ,slippage,slBuy,tpBuy, NULL ,MagicNumber, 0 , clrBlue );
if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ());
}
if (OrderSell== 0 && rsi<Urov_30 && rsi1>Urov_30 && rsi2>Urov_30)
{
tiket= OrderSend ( _Symbol , OP_SELL ,Lot, Bid ,slippage,slSell,tpSell, NULL ,MagicNumber, 0 , clrRed );
if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ());
}
}
//+------------------------------------------------------------------+
결과는 다음과 같습니다. 교차점이 없을 때 주문이 열립니다...
다음과 같이 작성: (아마도 틀릴 수 있음)
}
double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 );
double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 );
double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 );
//+------------------------------------------------------------------+
double StopLossLevel;
결과는 다음과 같습니다. 교차점이 없을 때 주문이 열립니다...
왜 현재 막대가 필요합니까? double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 ); ???
재작성된 코드는 이전과 정확히 동일한 조건을 충족합니다. 0 막대에서 가격이 수준을 넘고 거래가 열렸습니다. 나중에 가격이 다시 반환되고 RSI가 수준 아래로 반환되었습니다. 결과적으로 막대가 닫힌 후, 더 이상 신호가 없습니다.
계산에 영점 막대를 사용하지 마십시오.
왜 현재 막대가 필요한가요? double rsi= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 0 ); ???
재작성된 코드는 이전과 정확히 동일한 조건을 충족합니다. 0 막대에서 가격이 수준을 넘고 거래가 열렸습니다. 나중에 가격이 다시 반환되고 RSI가 수준 아래로 반환되었습니다. 결과적으로 막대가 닫힌 후, 더 이상 신호가 없습니다.
계산에 영점 막대를 사용하지 마십시오.
오류가 발생하는 이유를 알려주십시오.
double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ()
{
OrderBuy= 0 ; OrderSell= 0 ;
for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) //Цикл по всем ордерам
{
if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ) && OrderSymbol ()== Symbol () && OrderMagicNumber ()==MagicNumber) //Выбрали ордер
{
if ( OrderType ()== OP_BUY )
{
OrderBuy++; //Кол. покупок
}
if ( OrderType ()== OP_SELL )
{
OrderSell++; //Кол. продаж
}
}
}
//double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 );
double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 );
//+------------------------------------------------------------------+
double StopLossLevel;
double TakeProfitLevel;
if (StopLoss> 0 ) StopLossLevel= Bid -StopLoss* Point ; else StopLossLevel= 0.0 ;
if (TakeProfit> 0 ) TakeProfitLevel= Ask +TakeProfit* Point ; else TakeProfitLevel= 0.0 ;
tpBuy= NormalizeDouble ( Ask +TakeProfit* _Point , _Digits );
slBuy= NormalizeDouble ( Bid -StopLoss* _Point , _Digits );
tpSell= NormalizeDouble ( Bid -TakeProfit* _Point , _Digits );
slSell= NormalizeDouble ( Ask +StopLoss* _Point , _Digits );
///---
if (CountBuy()+CountSell()== 0 && rsi1>Urov_70 && rsi2<Urov_70)
{
tiket= OrderSend ( _Symbol , OP_BUY ,Lot, Ask ,slippage,slBuy,tpBuy, NULL ,MagicNumber, 0 , clrBlue );
if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ());
}
if (CountBuy()+CountSell()== 0 && rsi1<Urov_30 && rsi2>Urov_30)
{
tiket= OrderSend ( _Symbol , OP_SELL ,Lot, Bid ,slippage,slSell,tpSell, NULL ,MagicNumber, 0 , clrRed );
if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ());
}
}
//+------------------------------------------------------------------+
int CountBuy()
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--);
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true )
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY )
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
int CountSell()
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--);
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true )
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL )
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
오류가 발생하는 이유를 알려주십시오.
double slSell,slBuy,tpSell,tpBuy,TotalBiu,TotalSell;
int tiket;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ()
{
OrderBuy= 0 ; OrderSell= 0 ;
for ( int i= OrdersTotal ()- 1 ; i>= 0 ; i--) //Цикл по всем ордерам
{
if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ) && OrderSymbol ()== Symbol () && OrderMagicNumber ()==MagicNumber) //Выбрали ордер
{
if ( OrderType ()== OP_BUY )
{
OrderBuy++; //Кол. покупок
}
if ( OrderType ()== OP_SELL )
{
OrderSell++; //Кол. продаж
}
}
}
//double rsi=iRSI(_Symbol,0,RSIperiod,PRICE_CLOSE,0);
double rsi1= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 1 );
double rsi2= iRSI ( _Symbol , 0 ,RSIperiod, PRICE_CLOSE , 2 );
//+------------------------------------------------------------------+
double StopLossLevel;
double TakeProfitLevel;
if (StopLoss> 0 ) StopLossLevel= Bid -StopLoss* Point ; else StopLossLevel= 0.0 ;
if (TakeProfit> 0 ) TakeProfitLevel= Ask +TakeProfit* Point ; else TakeProfitLevel= 0.0 ;
tpBuy= NormalizeDouble ( Ask +TakeProfit* _Point , _Digits );
slBuy= NormalizeDouble ( Bid -StopLoss* _Point , _Digits );
tpSell= NormalizeDouble ( Bid -TakeProfit* _Point , _Digits );
slSell= NormalizeDouble ( Ask +StopLoss* _Point , _Digits );
///---
if (CountBuy()+CountSell()== 0 && rsi1>Urov_70 && rsi2<Urov_70)
{
tiket= OrderSend ( _Symbol , OP_BUY ,Lot, Ask ,slippage,slBuy,tpBuy, NULL ,MagicNumber, 0 , clrBlue );
if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ());
}
if (CountBuy()+CountSell()== 0 && rsi1<Urov_30 && rsi2>Urov_30)
{
tiket= OrderSend ( _Symbol , OP_SELL ,Lot, Bid ,slippage,slSell,tpSell, NULL ,MagicNumber, 0 , clrRed );
if (tiket< 0 ) Print ( "Ошибка открытия ордера № - " , GetLastError ());
}
}
//+------------------------------------------------------------------+
int CountBuy()
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--);
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true )
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY )
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
int CountSell()
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--);
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true )
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL )
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
오류가 발생하는 이유를 알려주십시오.
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--);
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES )== true )
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL )
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
추가의 ";"
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<<
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES ))
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY )
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
int CountSell()
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<<
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES ))
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL )
count++;
}
}
return (count);
}
따라서 다음과 같은 경우 더 좋을 것입니다.
그런데 여기
추가의 ";"
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<<
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES ))
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_BUY )
count++;
}
}
return (count);
}
//+------------------------------------------------------------------+
int CountSell()
{
int count= 0 ;
for ( int trade= OrdersTotal ()- 1 ; trade> 0 ; trade--) ; <<<
{
if ( OrderSelect (trade, SELECT_BY_POS , MODE_TRADES ))
{
if ( OrderSymbol ()== _Symbol && OrderMagicNumber ()==MagicNumber && OrderType ()== OP_SELL )
count++;
}
}
return (count);
}
따라서 다음과 같은 경우 더 좋을 것입니다.
안녕하세요 여러분, 표현을 쓰는 방법
다섯 번째 로트는 로트 1과 4 주문의 합과 같습니다.
티켓 정의를 통해 첫 번째 또는 마지막을 찾을 수 있습니다.
현재 그리드의 지속적인 변화를 감안할 때 중간체를 찾는 방법은 무엇입니까?
각 주문은 어떻게든 어딘가에 저장되어야 함을 의미합니다.
글쎄, 차이가 있습니까?
~ 사이
{
if uslovie1== true {...}
if uslovie2== true {...}
if uslovie3== true {...}
}
И
void OnTick ()
{
{
if uslovie1== true
{...}
else if {...}
else if {...}
}
}