표시기 내부 텍스트 - 페이지 3

 
supermagix :

OBJPROP_XDISTANCE 및 OBJPROP_YDISTANCE 이동 하면 최적의 지점을 찾을 수 있습니다.

OBJPROP_YDISTANCE 값을 500으로 변경하면

레이블이 한 픽셀 이동하지 않습니다

 //--- create object
  
   ObjectCreate ( 0 ,objectName, OBJ_TEXT ,window, 0 , 0 );
 //ObjectSetString(0,objectName,OBJPROP_TEXT,string(ExtRSIBuffer[rates_total-1]));
   ObjectSetString ( 0 ,objectName, OBJPROP_TEXT , DoubleToString (ExtRSIBuffer[rates_total- 1 ], 2 ));
   ObjectSetInteger ( 0 ,objectName, OBJPROP_COLOR , Red );
   ObjectSetString ( 0 ,objectName, OBJPROP_FONT , "Arial" );
   ObjectSetInteger ( 0 ,objectName, OBJPROP_FONTSIZE , 20 );
 //ObjectSetInteger (0,objectName, OBJPROP_CORNER, corner);
   ObjectSetInteger ( 0 ,objectName, OBJPROP_XDISTANCE , 0 );
   ObjectSetInteger ( 0 ,objectName, OBJPROP_YDISTANCE , 500 );
   
   datetime tm[ 1 ];
   CopyTime ( _Symbol , _Period , 0 , 1 ,tm);
   ObjectSetInteger ( 0 ,objectName, OBJPROP_TIME ,tm[ 0 ]);
   ObjectSetDouble ( 0 ,objectName, OBJPROP_PRICE ,ExtRSIBuffer[rates_total- 1 ]);
 
walb99 :

라벨을 오른쪽 상단 모서리 에 어떻게 넣을 수 있습니까?

이 문제를 조사하겠습니다. 감사합니다.
 
Rosh :

이러한 지표를 작성하기 전에 MQL5를 조금 배워야 합니다. 너무 어색한 실수를 저질렀습니다.



배우려고 하지만 mql5에 대한 간단한 튜토리얼이나 코스가 존재하지 않습니다. 실수로부터 배우고 당신의 도움을 요청해야 합니다.

나는 당신이 쓴 이 지시를 이해할 수 없습니다.

 int i=prev_calculated;
   if (i> 0 ) prev_calculated--;
   for (;i<rates_total;i++)

컴파일 할 때 오류가 있습니다.

 
supermagix :

배우려고 하지만 mql5에 대한 간단한 튜토리얼이나 코스가 존재하지 않습니다. 실수에서 배우고 도움을 요청해야 합니다.

나는 당신이 쓴 이 지시를 이해할 수 없습니다.

컴파일 할 때 오류가 있습니다.

잘못 입력했습니다, 죄송합니다. 오른쪽은

 int i=prev_calculated;
   if (i> 0 ) i--;
   for (;i<rates_total;i++)
 
Rosh :

잘못 입력했습니다, 죄송합니다. 오른쪽은

여기에 더 올바른 코드가 있습니다. 사용하십시오.

 //+------------------------------------------------------------------+
//|                                                     CCIcolor.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "Copyright 2009, MetaQuotes Software Corp."
#property link         "http://www.mql5.com"
#property description "Relative Strength Index"
//--- indicator settings
#property indicator_separate_window

#property indicator_buffers 4
#property indicator_plots 3
//--- input parameters
input int       CCIPeriod= 14 ;         // Period for calculating the CCI
input int       CCIPeriodTurbo= 6 ;     // Period for calculating the TURBOCCI
input ENUM_APPLIED_PRICE   price1= PRICE_CLOSE ; // Method of calculating

//---- plot CCI_LINE
#property indicator_label1   "CCI_LINE"
#property indicator_type1   DRAW_LINE
#property indicator_color1  Black
#property indicator_style1  STYLE_SOLID
#property indicator_width1   3

//---- plot CCI_TURBO_LINE
#property indicator_label2   "CCI_TURBO_LINE"
#property indicator_type2  DRAW_LINE
#property indicator_color2  Navy
#property indicator_style2  STYLE_SOLID
#property indicator_width2   1

//---- plot CCI_HISTOGRAM
#property indicator_label3   "CCI_HISTO"
#property indicator_type3   DRAW_COLOR_HISTOGRAM
#property indicator_color3  Red,Green
#property indicator_style3  STYLE_SOLID
#property indicator_width3   2


//----- level
#property indicator_level1       - 100.0
#property indicator_level2         100.0
#property indicator_level3       - 200.0
#property indicator_level4         200.0
#property indicator_level5       - 50.0
#property indicator_level6         50.0
//--- indicator buffers

double          CCI_LINEBuffer[]; //  CCI_LINE
double          CCI_TURBOBuffer[]; //  CCI TURBO_LINE
double          HISTOGRAM[];       //  HISTOGRAM
double          HISTOGRAMColor[];       //  HISTOGRAM
int             copied;
int   CCIhandle;
int CCI_TURBO_handle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

void OnInit()
  {
//--- indicator buffers mapping

   SetIndexBuffer ( 0 ,CCI_LINEBuffer, INDICATOR_DATA ); //buffer LINE
   SetIndexBuffer ( 1 ,CCI_TURBOBuffer, INDICATOR_DATA ); //buffer Turbo
   SetIndexBuffer ( 2 ,HISTOGRAM, INDICATOR_DATA ); //buffer Histogram
   SetIndexBuffer ( 3 ,HISTOGRAMColor, INDICATOR_COLOR_INDEX ); //buffer Histogram

                                                           //name of separate window 
   IndicatorSetString ( INDICATOR_SHORTNAME , "MYCCI" );
//--- Create the indicator of CCI LINR
   CCIhandle= iCCI ( NULL , 0 ,CCIPeriod,price1);

//--- Create the indicator of CCI TURBO
   CCI_TURBO_handle= iCCI ( NULL , 0 ,CCIPeriodTurbo,price1);

//---
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int OnCalculate( const int rates_total,
                 const int prev_calculated,
                 const int begin,
                 const double &price[]
                )
  {
//--- not all data may be calculated
   int calculated= BarsCalculated (CCIhandle);
   if (calculated<rates_total)
     {
       Print ( "Not all data of CCIhandle is calculated (" ,calculated, "bars ). Error" , GetLastError ());
       return ( 0 );
     }
//--- not all data may be calculated
   calculated= BarsCalculated (CCI_TURBO_handle);
   if (calculated<rates_total)
     {
       Print ( "Not all data of CCI_TURBO_handle is calculated (" ,calculated, "bars ). Error" , GetLastError ());
       return ( 0 );
     }

//--- we can copy not all data
   int to_copy;
   if (prev_calculated>rates_total || prev_calculated< 0 ) to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
       if (prev_calculated> 0 ) to_copy++;
     }
//---- get CCI buffers
   if ( CopyBuffer (CCIhandle, 0 , 0 ,to_copy,CCI_LINEBuffer)<= 0 )
     {
       Print ( "getting CCIhandle is failed! Error" , GetLastError ());
       return ( 0 );
     }

   if ( CopyBuffer (CCI_TURBO_handle, 0 , 0 ,to_copy,CCI_TURBOBuffer)<= 0 )
     {
       Print ( "getting CCI_TURBO_handle is failed! Error" , GetLastError ());
       return ( 0 );
     }

   int i=prev_calculated;
   if (i> 0 ) i--;
   for (;i<rates_total;i++)
     {
      HISTOGRAM[i]=CCI_LINEBuffer[i];
       if (CCI_LINEBuffer[i]< 0 )
        {
         HISTOGRAMColor[i]= 0.0 ; //HISTOGRAM RED
        }
       if (CCI_LINEBuffer[i]> 0 )
        {
         HISTOGRAMColor[i]= 1.0 ; //HISTOGRAM Green
        }
     }

//--- return value of prev_calculated for next call
   return (rates_total);

  }
//+------------------------------------------------------------------+
 
Rosh :

여기에 더 올바른 코드가 있습니다. 사용하십시오.


나는 이 지시를 제거했다

 int i=prev_calculated;
   if (i> 0 ) i--;
   /// /// / if(prev_calculated!=0) return(prev_calculated);
   for (;i<rates_total;i++)

히스토그램이 각 가격 변동 에 대해 업데이트되지 않았기 때문입니다.

문제가 있을 수 있다고 생각합니다(반환).

맞다?

도와 주셔서 감사합니다

.......다른 변경을 하고 있습니다.....

 
supermagix :

나는 이 지시를 제거했다

히스토그램이 각 가격 변동 에 대해 업데이트되지 않았기 때문입니다.

문제가 있을 수 있다고 생각합니다(반환).

맞다?

도와 주셔서 감사합니다

.......다른 변경을 하고 있습니다.....

맞습니다. 디버그 목적으로 구현되었습니다. 제 글에서 삭제했습니다.
 

히스토그램의 색상을 얻기 위한 프로그램을 수정했지만 작동하지 않습니다.

문제가 카운터에 있다고 생각합니다. FOR.....주기에서 맞습니까?

 //+------------------------------------------------------------------+
//|                                                     CCIcolor.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "Copyright 2009, MetaQuotes Software Corp."
#property link         "http://www.mql5.com"
#property description "CCI"
//--- indicator settings
#property indicator_separate_window

#property indicator_buffers 4
#property indicator_plots 3
//--- input parameters
input int       CCIPeriod= 14 ;         // Period for calculating the CCI
input int       CCIPeriodTurbo= 6 ;     // Period for calculating the TURBOCCI
input ENUM_APPLIED_PRICE   price1= PRICE_CLOSE ; // Method of calculating

//---- plot CCI_LINE
#property indicator_label1   "CCI_LINE"
#property indicator_type1   DRAW_LINE
#property indicator_color1  Black
#property indicator_style1  STYLE_SOLID
#property indicator_width1   3

//---- plot CCI_TURBO_LINE
#property indicator_label2   "CCI_TURBO_LINE"
#property indicator_type2  DRAW_LINE
#property indicator_color2  Navy
#property indicator_style2  STYLE_SOLID
#property indicator_width2   1

//---- plot CCI_HISTOGRAM
#property indicator_label3   "CCI_HISTO"
#property indicator_type3   DRAW_COLOR_HISTOGRAM
#property indicator_color3  Gray,Gold,Red,Green
#property indicator_style3  STYLE_SOLID
#property indicator_width3   2


//----- level
#property indicator_level1       - 100.0
#property indicator_level2         100.0
#property indicator_level3       - 200.0
#property indicator_level4         200.0
#property indicator_level5       - 50.0
#property indicator_level6         50.0
//--- indicator buffers

double          CCI_LINEBuffer[]; //  CCI_LINE
double          CCI_TURBOBuffer[]; //  CCI TURBO_LINE
double          HISTOGRAM[];       //  HISTOGRAM
double          HISTOGRAMColor[];       //  HISTOGRAM
int             copied;
int   CCIhandle;
int CCI_TURBO_handle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

void OnInit()
  {
//--- indicator buffers mapping
   
   SetIndexBuffer ( 0 ,CCI_LINEBuffer, INDICATOR_DATA ); //buffer LINE
   SetIndexBuffer ( 1 ,CCI_TURBOBuffer, INDICATOR_DATA ); //buffer Turbo
   SetIndexBuffer ( 2 ,HISTOGRAM, INDICATOR_DATA ); //buffer Histogram
   SetIndexBuffer ( 3 ,HISTOGRAMColor, INDICATOR_COLOR_INDEX ); //buffer Histogram

                                                           //name of separate window 
   IndicatorSetString ( INDICATOR_SHORTNAME , "MYCCI" );
//--- Create the indicator of CCI LINR
   CCIhandle= iCCI ( NULL , 0 ,CCIPeriod,price1);

//--- Create the indicator of CCI TURBO
   CCI_TURBO_handle= iCCI ( NULL , 0 ,CCIPeriodTurbo,price1);

//---
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate( const int rates_total,
const int prev_calculated,
const datetime & time[],
const double & open[],
const double & high[],
const double & low[],
const double & close[],
const long & tick_volume[],
const long & volume[],
const int & spread[])

 {
//--- not all data may be calculated
   int calculated= BarsCalculated (CCIhandle);
   if (calculated<rates_total)
     {
       Print ( "Not all data of CCIhandle is calculated (" ,calculated, "bars ). Error" , GetLastError ());
       return ( 0 );
     }
//--- not all data may be calculated
   calculated= BarsCalculated (CCI_TURBO_handle);
   if (calculated<rates_total)
     {
       Print ( "Not all data of CCI_TURBO_handle is calculated (" ,calculated, "bars ). Error" , GetLastError ());
       return ( 0 );
     }

//--- we can copy not all data
   int to_copy;
   if (prev_calculated>rates_total || prev_calculated< 0 ) to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
       if (prev_calculated> 0 ) to_copy++;
     }
//---- get CCI buffers
   if ( CopyBuffer (CCIhandle, 0 , 0 ,to_copy,CCI_LINEBuffer)<= 0 )
     {
       Print ( "getting CCIhandle is failed! Error" , GetLastError ());
       return ( 0 );
     }

   if ( CopyBuffer (CCI_TURBO_handle, 0 , 0 ,to_copy,CCI_TURBOBuffer)<= 0 )
     {
       Print ( "getting CCI_TURBO_handle is failed! Error" , GetLastError ());
       return ( 0 );
     }

   int i=prev_calculated;
   if (i> 0 ) i--;
   for (;i<rates_total;i++)
     {
      HISTOGRAM[i]=CCI_LINEBuffer[i];
    
//--- set color histogram Long
        
     if (CCI_LINEBuffer[i+ 5 ]< 0 && CCI_LINEBuffer[i+ 4 ]> 0 && CCI_LINEBuffer[i+ 3 ]> 0 && CCI_LINEBuffer[i+ 2 ]> 0 && CCI_LINEBuffer[i+ 1 ]> 0 )
       HISTOGRAMColor[i]= 1.0 ; // set color Yellow (only one histogram)
      }
       {
       if (CCI_LINEBuffer[i+ 5 ]> 0 && CCI_LINEBuffer[i+ 4 ]> 0 && CCI_LINEBuffer[i+ 3 ]> 0 && CCI_LINEBuffer[i+ 2 ]> 0 && CCI_LINEBuffer[i+ 1 ]> 0 );
        HISTOGRAMColor[i]= 2.0 ; // set color Green
        } 
     
//--- set color histogram Short
      {
       if (CCI_LINEBuffer[i+ 5 ]> 0 && CCI_LINEBuffer[i+ 4 ]< 0 && CCI_LINEBuffer[i+ 3 ]< 0 && CCI_LINEBuffer[i+ 2 ]< 0 && CCI_LINEBuffer[i+ 1 ]< 0 )
        HISTOGRAMColor[i]= 1.0 ; // set color Yellow (onli one histogram)
       }
       {
       if (CCI_LINEBuffer[i+ 5 ]< 0 && CCI_LINEBuffer[i+ 4 ]< 0 && CCI_LINEBuffer[i+ 3 ]< 0 && CCI_LINEBuffer[i+ 2 ]< 0 && CCI_LINEBuffer[i+ 1 ]< 0 )
         HISTOGRAMColor[i]= 3.0 ; // set color Red
       }  

//--- return value of prev_calculated for next call
   return (rates_total);

  }
//+------------------------------------------------------------------+


이걸 봐야 하나:

도움에 감사드립니다

 
Rosh :
이 문제를 조사하겠습니다. 감사합니다.

다른 키 입력을 사용하여 변경된 임시 전역 변수를 통해 지표와 상호 작용하는 개념 증명 EA를 만들었습니다.

모서리는 작동하지만 아래쪽 모서리는 타임라인이 아니라 표시기 프레임에 상대적이라는 점을 기억해야 합니다. 비디오를 참조하십시오.

불행히도 비디오 업로드는 이 포럼에서 작동하지 않는 것 같습니다 :(


당분간은 붙이고

http://www.youshare.com/Guest/c94bb3e9cfe6a424.flv.html

(최상의 결과를 위해 전체 화면 참조)

감사합니다.

 

많은 테스트를 거쳐 이 결과가 나왔습니다.

값 검정 및 녹색 = 차이 히스토그램

밸류 블랙 그레이트 = CCI의 현재 가치

...하지만 히스토그램의 색상에 문제가 있습니다.....