포럼을 어지럽히 지 않도록 모든 초보자 질문. 프로, 놓치지 마세요. 너 없이는 아무데도 - 6. - 페이지 554

 
Vinin :


정말 감사합니다!
 

splxgf : - 정말 감사합니다! 모든 것이 시계처럼 작동합니다!

다음은 백분율에 대한 핍 대신 " splxgf :" 로 재작업된 Igor Kim의 손익분기점 코드입니다.

//+----------------------------------------------- ------------------------------+
//| 저자 : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------- ------------------------------+
//| 버전: 2009년 4월 23일 |
//| 설명 : 정지 수준을 손익분기점으로 전환 |
//+----------------------------------------------- ------------------------------+
//| 옵션: |
//| sy - 악기 이름("" - 모든 문자, |
//| NULL - 현재 문자) |
//| 연산 - 연산(-1 - 임의의 위치) |
//| mn - MagicNumber( -1 - 모든 마법) |
//+----------------------------------------------- ------------------------------+
무효 MovingInWL(문자열 sy=NULL, int op=-1, int mn=-1) {

이중 포, pp, PercentStep, MoveStoplossLevel,StoplossLevel;
정수 i, k=OrdersTotal();

if (sy=="0") sy=Symbol();
(i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
if (mn<0 || OrderMagicNumber()==mn) {

po=시장 정보(주문 기호(), MODE_POINT);

if (주문유형()==OP_BUY) {
PercentStep=(OrderTakeProfit()-OrderOpenPrice())/po/( 138 - 23 );
MoveStoplossLevel = OrderOpenPrice() + PercentStep*( 76 - 23 );
StoplossLevel = OrderOpenPrice() + PercentStep*( 51 - 23 );
if (OrderStopLoss()-OrderOpenPrice()<StoplossLevel*po) {
pp=시장 정보(주문 기호(), MODE_BID);
if (pp-OrderOpenPrice()>MoveStoplossLevel*po) {
ModifyOrder(-1, OrderOpenPrice()+StoplossLevel*po, -1);
}
}

}


(주문 유형()==OP_SELL) {
PercentStep=(OrderTakeProfit()-OrderOpenPrice())/po/(138-23);
MoveStoplossLevel = OrderOpenPrice() - PercentStep*(76-23);
StoplossLevel = OrderOpenPrice() - PercentStep*(51-23);
if (OrderStopLoss()==0 || OrderOpenPrice()-OrderStopLoss()<StoplossLevel*po) {
pp=시장 정보(주문 기호(), MODE_ASK);
if (OrderOpenPrice()-pp>MoveStoplossLevel*po) {
ModifyOrder(-1, OrderOpenPrice()-StoplossLevel*po, -1);

}
}
}
}
}
}
}
}

//+----------------------------------------------- ------------------------------+

숫자:

138 은 % 피보나치 단위의 이익실현입니다.

23 은 % 피보나치 단위의 주문 시작 가격 입니다.

피보나치 그리드의 76 %, 가격 도달하면 손절매가 피보나치 그리드의 51 %로 이동합니다.

e-MovingInWL2 Expert Advisor의 기능.

 
int start()
{

Trailing();


double Line11=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 1);
double Line12=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 4, 2);
double Line21=iCustom(Symbol(), 0, "TDI Red Green", RSI_Period, RSI_Price, Volatility_Band, RSI_Price_Line, RSI_Price_Type, Trade_Signal_Line, Trade_Signal_Type, 5, 1);

if (timeprev == Time[0]) return(0);
timeprev = Time[0];

ma0=iMA(NULL,0,10,0,MODE_SMA,PRICE_CLOSE,1);
ma1=iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,1);
ma2=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,1);
ma3=iMA(NULL,0,800,0,MODE_SMA,PRICE_CLOSE,1);

if (CountBuy()>5 && Volume[0]==1 && Ask > ma0 && Ask > ma1 && Ask > ma3)
{
if (Line11>Level1&&Line12<Level1&&Line11>Line12)
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask-sl*Point, Ask+tp*Point, comment, Magic, 0, Blue);
}

if (CountSell()>5 && Volume[0]==1 && Bid < ma0 && Bid < ma1 && Ask < ma3)
{
if (Line11>Level2&&Line12>Level1&&Line11>Line12)
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Ask+sl*Point,Ask-tp*Point, comment, Magic, 0, Red);
}

return(0);
}


TDI Red Green 표시기를 사용하여 주문을 시작하라는 신호가 있는 코드에서 오류를 찾는 데 도움을 주세요.

테스터는 거래를 열지 않거나 하나만 열었습니다. 어떤 오류도 보고하지 않습니다.

버퍼 표시기가 올바르게 표시되었습니다.

나는 며칠 동안 mql4 언어 만 배우고 있습니다, 초보자)))

미리 도와주셔서 감사합니다!!!
 
나는 그러한 딜레마에 빠졌습니다. for-loop가 있다고 가정 해 봅시다.

 int Array_1[][];
int Array_2[][];
int Array_3[][];
int Array_4[][];
 . . . 


start() {

   for ( int k= 1 ; k<=N; k++) {

       if (k== 1 ) {
         Используем массив ARRAY_1
      }
       if (k== 2 ) {
         Используем массив ARRAY_2
      }
       if (k== 3 ) {
         Используем массив ARRAY_3
      }
      . . . 
   } // for ( int k= 1 ; k<=N; k++) {

} // start() {

매개변수 N은 변수 값입니다. 즉, 변경될 때마다 코드를 다시 실행하여 해당 배열 아래에 "if" 조건을 추가(또는 제거)해야 합니다.

질문 - 어떤 식으로든 하나의 "if"만 사용할 수 있지만 배열 이름에서(또는 다른 방식으로) 변수 "k"를 사용하는 것이 가능합니까? 저것들. ARRAY_{k} 같은 것. 배열을 터미널 변수로 바꿀 수 있다는 것을 알고 있지만 이것은 이미 극단적인 경우입니다. 어레이에 대한 유사한 솔루션이 있습니까?
 
chief2000 :
나는 그러한 딜레마에 빠졌습니다. for-loop가 있다고 가정 해 봅시다.


매개변수 N은 변수 값입니다. 즉, 변경될 때마다 코드를 다시 실행하여 해당 배열 아래에 "if" 조건을 추가(또는 제거)해야 합니다.

질문 - 어떤 식으로든 하나의 "if"만 사용할 수 있지만 배열 이름에서(또는 다른 방식으로) 변수 "k"를 사용하는 것이 가능합니까? 저것들. ARRAY_{k} 같은 것. 배열을 터미널 변수로 바꿀 수 있다는 것을 알고 있지만 이것은 이미 극단적인 경우입니다. 어레이에 대한 유사한 솔루션이 있습니까?

다음과 같은 경우에 할 수 있습니다.

 // Константы
#define   Version     "TT-Pod 1.2.6"
#define   MyError     4999
#define   Infinity     100000000.0
#define   Zero                 0.00000001
#define   TypesTotal   24
// Глобальные переменные и массивы
int       LastBar,
         Visibility,
         Groups[ 2 ],
         MainGroup[ 2 ],
         OldMG[ 2 ],
         StumbleNumber[ 2 ];
double    QualityMax[ 2 ];
datetime DeadLine,
         OldStopLine,
         StartTime[ 2 ],
         NewTime;
color     ЦветЛиний[ 2 ],
         Цвет 123 [ 2 ],
         ЦветХорды[ 2 ];
string    NameTangent[ 2 ]     ={ "RaisingTangent"      , "ReducingTangent"      },
         NameTrend[ 2 ]       ={ "RaisingTrend"        , "ReducingTrend"        },
         NameBorder[ 2 ]      ={ "RaisingBorder"       , "ReducingBorder"       },
         NameLevel1[ 2 ]      ={ "RaisingLevel_1_"     , "ReducingLevel_1_"     },
         NameLevel12[ 2 ]     ={ "RaisingLevel_2_"     , "ReducingLevel_2_"     },
         NameLevel2[ 2 ]      ={ "RaisingLevel_3_"     , "ReducingLevel_3_"     },
         NameLevel22[ 2 ]     ={ "RaisingLevel_4_"     , "ReducingLevel_4_"     },
         NameMainLevel1[ 2 ]  ={ "MainRaisingLevel_1" , "MainReducingLevel_1" },
         NameMainLevel12[ 2 ] ={ "MainRaisingLevel_3" , "MainReducingLevel_3" },
         NameMainLevel2[ 2 ]  ={ "MainRaisingLevel_2" , "MainReducingLevel_2" },
         NameMainLevel22[ 2 ] ={ "MainRaisingLevel_4" , "MainReducingLevel_4" },
         NameTrace[ 2 ]       ={ "RaisingTrace"        , "ReducingTrace"        },
         NameAttention[ 2 ]   ={ "RaisingAttention"    , "ReducingAttention"    },
         NameSpiral[ 2 ]      ={ "RaisingSpiral"       , "ReducingSpiral"       },
         NameSpan[ 2 ]        ={ "RaisingSpan"         , "ReducingSpan"         },
         NameMainLevel0[ 2 ]  ={ "MainRaisingLevel_0" , "MainReducingLevel_0" },
         NameMainLevel5[ 2 ]  ={ "MainRaisingLevel_5" , "MainReducingLevel_5" },
         NameMainLevel6[ 2 ]  ={ "MainRaisingLevel_6" , "MainReducingLevel_6" },
         NameBaseLevel[ 2 ]   ={ "RaisingBaseLevel"    , "ReducingBaseLevel"    },
         Name123[ 2 ]         ={ "RaisingTrendBreak"   , "ReducingTrendBreak"   },
         NameSpiralBorder[ 2 ]={ "RaisingSpiralBorder" , "ReducingSpiralBorder" },
         NameDirector[ 2 ]    ={ "RaisingDirector"     , "ReducingDirector"     },
         NameHorizont[ 2 ]    ={ "RaisingHorizont"     , "ReducingHorizont"     },
         NameStumble[ 2 ]     ={ "RaisingStumble"      , "ReducingStumble"      },
         РежимРаботы        = " " ,
         TextTangent[ 2 ]     ={ ""                                   , "" },
         TextTrend[ 2 ]       ={ ""                                   , "" },
         TextTrace[ 2 ]       ={ ""                                   , "" },
         TextBorder[ 2 ]      ={ ""                                   , "" },
         TextLevel1[ 2 ]      ={ ""                                   , "" },
         TextLevel12[ 2 ]     ={ ""                                   , "" },
         TextLevel2[ 2 ]      ={ ""                                   , "" },
         TextLevel22[ 2 ]     ={ ""                                   , "" },
         TextSpan[ 2 ]        ={ ""                                   , "" },
         TextDirector[ 2 ]    ={ "                                              Директорная ВТ"
                             , "                                              Директорная НТ" },
         TextHorizont[ 2 ]    ={ "                                              Горизонт ВТ"
                             , "                                              Горизонт НТ" },
         Text123[ 2 ]         ={ "Пробой ВТ"                          , "Пробой НТ" },
         TextAttention[ 2 ]   ={ "В! "                                , "Н! " },
         TextSpiral[ 2 ]      ={ "          ВТ"                       , "          НТ" },
         TextSpiralBorder[ 2 ]={ "               ВГр"                 , "               НГр" },
         TextMainLevel0[ 2 ]  ={ "ВУр0"                               , "НУр0" },
         TextMainLevel1[ 2 ]  ={ "     ВУр1"                          , "     НУр1" },
         TextMainLevel2[ 2 ]  ={ "          ВУр2"                     , "          НУр2" },
         TextMainLevel12[ 2 ] ={ "" , "" },
         TextMainLevel22[ 2 ] ={ "                    ВУр4"           , "                    НУр4" },
         TextMainLevel5[ 2 ]  ={ "                         ВУр5"      , "                         НУр5" },
         TextMainLevel6[ 2 ]  ={ "                              ВУр6" , "                              НУр6" },
         TextBaseLevel[ 2 ]   ={ "                ВБУ"                , "                НБУ" },
         TextStumble[ 2 ]     ={ ""                                   , "" };
// Внешние переменные
extern double   МинНаклонТренда         = 0.0 ,       // Фильтры "ложных" трендовых
               МаксНаклонТренда        =Infinity;
extern string   Варианты= "1=Hb, 2=Hb/H, 3=H, 4=V, 5=N" ;
extern int      КритерийВыбора          = 5 ,
               МинБазовыйПериод        = 1 ,
               МаксБазовыйПериод       =Infinity,
               БарНачала               =Infinity,   // Параметры отображения
               БарОкончания            = 1 ,
               ПериодИмитацииТиков     = 2000 ,
               СдвигИндикатораТиков    = 10 ,
               ЗнакИндикатораТиков     = 159 ,
               РазмерИндикатораТиков   = 5 ,
               ТолщинаТрендовой        = 3 ;
extern color    ЦветПоддержки           =Green,
               ЦветВосходящейХорды     =LimeGreen,
               Цвет 123 ВТ               =LightYellow,
               ЦветСопротивления       =Red,
               ЦветНисходящейХорды     =HotPink,
               Цвет 123 НТ               =LightYellow,
               ЦветВертикалей          =DimGray,
               ЦветИндикатораТиков     =DarkOrange;
extern bool     ОчиститьЭкран           = true ,
               ПоказыватьВсе           = false ,
               РежимОтладки            = true ,       // Режим работы программы
               СтатическийРежим        = false ,
               МоделироватьДинамику    = false ,
               ПечататьПредупреждения  = false ;
//-----------------------------------------------------------------------------
// Удаление созданных графических объектов
void ClearScreen(){
   int Dimension= 2 *TypesTotal;
   string Name, Pref[];
   Comment ( "                                                       " +
           "                                                       " +
           "                                                       " );
   ArrayResize (Pref,Dimension);
   Pref[ 0 ]=NameTangent[ 0 ];
   Pref[ 1 ]=NameTangent[ 1 ];
   Pref[ 2 ]=NameTrend[ 0 ];
   Pref[ 3 ]=NameTrend[ 1 ];
   Pref[ 4 ]=NameBaseLevel[ 0 ];
   Pref[ 5 ]=NameBaseLevel[ 1 ];
   Pref[ 6 ]=NameTrace[ 0 ];
   Pref[ 7 ]=NameTrace[ 1 ];
   Pref[ 8 ]=NameLevel12[ 0 ];
   Pref[ 9 ]=NameLevel12[ 1 ];
   Pref[ 10 ]=NameLevel22[ 0 ];
   Pref[ 11 ]=NameLevel22[ 1 ];
   Pref[ 12 ]=NameBorder[ 0 ];
   Pref[ 13 ]=NameBorder[ 1 ];
   Pref[ 14 ]=NameLevel2[ 0 ];
   Pref[ 15 ]=NameLevel2[ 1 ];
   Pref[ 16 ]=NameMainLevel12[ 0 ];
   Pref[ 17 ]=NameMainLevel12[ 1 ];
   Pref[ 18 ]=NameMainLevel22[ 0 ];
   Pref[ 19 ]=NameMainLevel22[ 1 ];
   Pref[ 20 ]=NameSpiralBorder[ 0 ];
   Pref[ 21 ]=NameSpiralBorder[ 1 ];
   Pref[ 22 ]=NameMainLevel2[ 0 ];
   Pref[ 23 ]=NameMainLevel2[ 1 ];
   Pref[ 24 ]=NameAttention[ 0 ];
   Pref[ 25 ]=NameAttention[ 1 ];
   Pref[ 26 ]=NameLevel1[ 0 ];
   Pref[ 27 ]=NameLevel1[ 1 ];
   Pref[ 28 ]=NameMainLevel1[ 0 ];
   Pref[ 29 ]=NameMainLevel1[ 1 ];
   Pref[ 30 ]=NameSpiral[ 0 ];
   Pref[ 31 ]=NameSpiral[ 1 ];
   Pref[ 32 ]=NameSpan[ 0 ];
   Pref[ 33 ]=NameSpan[ 1 ];
   Pref[ 34 ]=NameMainLevel0[ 0 ];
   Pref[ 35 ]=NameMainLevel0[ 1 ];
   Pref[ 36 ]=NameMainLevel5[ 0 ];
   Pref[ 37 ]=NameMainLevel5[ 1 ];
   Pref[ 38 ]=NameMainLevel6[ 0 ];
   Pref[ 39 ]=NameMainLevel6[ 1 ];
   Pref[ 40 ]=Name123[ 0 ];
   Pref[ 41 ]=Name123[ 1 ];
   Pref[ 42 ]=NameDirector[ 0 ];
   Pref[ 43 ]=NameDirector[ 1 ];
   Pref[ 44 ]=NameStumble[ 0 ];
   Pref[ 45 ]=NameStumble[ 1 ];
   Pref[ 46 ]=NameHorizont[ 0 ];
   Pref[ 47 ]=NameHorizont[ 1 ];
   int i, k= ObjectsTotal ()- 1 ;
   while ( k>= 0 ){
      Name= ObjectName (k);
      i=Dimension- 1 ;
       while ( i>= 0 ){
         if ( StringSubstr (Name, 0 , StringLen (Pref[i]))==Pref[i] ){
             if ( ! ObjectDelete (Name) ) {
               if ( !РежимОтладки ) PlaySound ( "alert.wav" );
               Print ( "***** " +Name+ ": ошибка удаления " +GetLastError()+ " при очистке экрана" );
         }  }
         i--;
      }
      k--;
   }
   return ;
}
 
tara :

다음과 같은 경우 다음을 수행할 수 있습니다.


무슨 말인지 말로 설명할 수 있나요?
 
chief2000 :

무슨 말인지 말로 설명할 수 있나요?


죄송합니다. 주의가 분산되었습니다.

배열 인덱스는 식별자의 일부가 됩니다.

 

다음은 간단한 코드입니다.

나는 모든 50번째 촛불에 그것을 원한다

프로그램은 수직선을 보였다 .

문제

프로그램은 첫 번째 양초에만 하나의 수직선을 노출합니다(50의 배수).

고맙습니다.

 double p;

int start()
{

p= Bars % 50 ;
if (p< 1 )
ObjectCreate ( 0 , OBJ_VLINE , 0 , Time [ 1 ], 0   );

                     
return ( 0 );
}
 
tara :


배열 인덱스는 식별자의 일부가 됩니다.


내가 이해하는 한 귀하의 솔루션은 제 경우에는 작동하지 않지만 확인할 가치가 있는 한 가지 아이디어를 제공했습니다. 고맙습니다!
 
solnce600 :

다음은 간단한 코드입니다.

나는 모든 50번째 촛불에 그것을 원한다

프로그램은 수직선을 나타냈다.

문제

프로그램은 첫 번째 양초에만 하나의 수직선을 노출합니다(50의 배수).

고맙습니다.

같은 이름으로 여러 개체를 만들려고 하지만 불가능합니다. 개체 이름은 고유해야 합니다(예: 시간).

 ObjectCreate ( Time [ i ], OBJ_VLINE , 0 , Time [ i ], 0 );

처음입니다. 두 번째: 주기는 어디에 있습니까? 스크립트는 어떻게 촛불을 계산합니까?