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

 
investeo :

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

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

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


당분간은 붙이고

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

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

감사합니다.

안녕

이 비디오에 첨부된 오디오가 없습니다.

SampleTextIndicator의 코드를 게시할 수 있습니까?

문안 인사

 
walb99 :

안녕

이 비디오에 첨부된 오디오가 없습니다.

SampleTextIndicator의 코드를 게시할 수 있습니까?

문안 인사


안녕

비디오에 오디오 트랙이 포함되어 있지 않습니다. 다른 랩톱에 코드를 남겨 두었기 때문에 오늘 저녁에 코드를 게시합니다.

 

코드가 매우 우아하지 않을 수 있지만 제대로 작동합니다.


 //+------------------------------------------------------------------+
//|                                          SampleTextIndicator.mq5 |
//|                                            Copyright Investeo.pl |
//|                                                      Investeo.pl |
//+------------------------------------------------------------------+
#property copyright "Investeo.pl"
#property link       "http://Investeo.pl"
#property version   "1.00"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
#property indicator_minimum 0
#property indicator_maximum 100


string label2_name= "indicator_label" ;
int window=- 1 ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
//---
   IndicatorSetString ( INDICATOR_SHORTNAME , "Hello... PRESS A-W-S-D-C TO PLAY" );
   
   return ( 0 );
  }
//+------------------------------------------------------------------+
//| 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[])
{
//---
//--- return value of prev_calculated for next call
 
   if (( ENUM_PROGRAM_TYPE ) MQL5InfoInteger ( MQL5_PROGRAM_TYPE )== PROGRAM_INDICATOR )
     {
      window= ChartWindowFind ();
       Print (window);
     }
     
     if ( ObjectFind ( 0 ,label2_name)< 0 )
     {
       ObjectCreate ( 0 ,label2_name, OBJ_LABEL ,window, 0 , 0 );         
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_XDISTANCE , 10 );
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_YDISTANCE , 10 );
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_COLOR , LightPink );
       ObjectSetString ( 0 ,label2_name, OBJPROP_TEXT , "HELLO WORLD" );
       ObjectSetString ( 0 ,label2_name, OBJPROP_FONT , "Arial" );
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_FONTSIZE , 14 );
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_SELECTABLE ,false);
       ChartRedraw (window);                                      
     } 
     else
     {
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_XDISTANCE ,( int ) GlobalVariableGet ( "prop_x" ));
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_YDISTANCE ,( int ) GlobalVariableGet ( "prop_y" ));
       ObjectSetString ( 0 ,label2_name, OBJPROP_TEXT , "x: " 
                                    + IntegerToString (( int ) GlobalVariableGet ( "prop_x" )) 
                                    + " y: " 
                                    + IntegerToString (( int ) GlobalVariableGet ( "prop_y" )));
       ObjectSetInteger ( 0 ,label2_name, OBJPROP_CORNER ,( int ) GlobalVariableGet ( "corner" ));
                                          
     }
     
   
   
   return (rates_total);
}
  
void OnDeinit( const int reason)
{
   if ( ObjectFind (window,label2_name)>= 0 )
       ObjectDelete (window,label2_name);
      
 

안녕

코드를 게시해 주셔서 감사합니다.

표시기가 단순히 오른쪽 상단 모서리 에 어떤 종류의 텍스트를 넣는 방식으로 코드를 변경해 주시겠습니까?

별도의 창에서 모든 지표에 사용할 수 있는 샘플

 
walb99 :

안녕

코드를 게시해 주셔서 감사합니다.

표시기가 단순히 오른쪽 상단 모서리 에 어떤 종류의 텍스트를 넣는 방식으로 코드를 변경해 주시겠습니까?

별도의 창에서 모든 지표에 사용할 수 있는 샘플


설명이 포함된 코드를 넣었습니다.

브,

인베스테오


 //+------------------------------------------------------------------+
//|                                         UpperRightCornerText.mq5 |
//|                                      Copyright 2010, Investeo.pl |
//|                                               http://Investeo.pl |
//+------------------------------------------------------------------+
#property copyright "2010, Investeo.pl"
#property link       "http://Investeo.pl"
#property version   "1.00"
#property indicator_separate_window
#property indicator_plots   1

string label_info= "label1" ;
int window=- 1 ;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- initialize a label in upper right corner

   // find indicator's window handle
   if (( ENUM_PROGRAM_TYPE ) MQL5InfoInteger ( MQL5_PROGRAM_TYPE )== PROGRAM_INDICATOR )
     window= ChartWindowFind ();

   // check if label object does not already exist and create it
   if ( ObjectFind ( 0 ,label_info)< 0 )
  {
       // Create label in indicator's window 
       ObjectCreate ( 0 ,label_info, OBJ_LABEL ,window, 0 , 0 );         
       // Set X and Y distance from UPPER RIGHT CORNER
       ObjectSetInteger ( 0 ,label_info, OBJPROP_XDISTANCE , 200 );
       ObjectSetInteger ( 0 ,label_info, OBJPROP_YDISTANCE , 20 );
       ObjectSetInteger ( 0 ,label_info, OBJPROP_CORNER , CORNER_RIGHT_UPPER );
       // Set text properties: colour, font and font size
       ObjectSetInteger ( 0 ,label_info, OBJPROP_COLOR , LightPink );
       ObjectSetString ( 0 ,label_info, OBJPROP_FONT , "Arial" );
       ObjectSetInteger ( 0 ,label_info, OBJPROP_FONTSIZE , 14 );
       // Set text to display
       ObjectSetString ( 0 ,label_info, OBJPROP_TEXT , "HELLO I am a label" );
  } else Print ( "label_info already exists" ); 
  

//---
   return ( 0 );
  }
//+------------------------------------------------------------------+
//| 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[])
  {
//---
//--- return value of prev_calculated for next call
   return (rates_total);
  }
//+------------------------------------------------------------------+

void OnDeinit( const int reason)
  {
//---
   if (! ObjectFind ( 0 ,label_info)< 0 )
       ObjectDelete ( 0 , label_info);
  }
 

간단한 지표에 대한 제안이 필요합니다.

닫기 > EMA 34 = 녹색 히스토감 또는 ....선 또는 ....화살표...

닫기< EMA 34 = 리드 히스토그램 또는...선 또는...화살표...

도움에 감사드립니다

 
investeo :


설명이 포함된 코드를 넣었습니다.

브,

인베스테오


안녕하세요 인베스테오

감사합니다. 코드가 작동합니다. 즉, 레이블이 표시되지만 값이 업데이트되지 않습니다. 내가 실수를 했나요?

여기 내 코드가 있습니다.

 //+------------------------------------------------------------------+
//|                                                                                                                                                     Color MA |
//|                                                                                        Copyright 2009, EarnForex.com |
//|                                                                                                       http://www.earnforex.com |
//+------------------------------------------------------------------+
#property copyright "2009, EarnForex.com"
#property link "http://www.earnforex.com"
#property version "1.00"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 1

//---- plot MA
#property indicator_label1 "Color MA1"
#property indicator_type1 DRAW_COLOR_LINE
#property indicator_color1 Lime, Red
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1



//#include <MovingAverages.mqh>

//--- input parameters
input int MA1_Period = 10 ;
input ENUM_MA_METHOD MA1_Mode = MODE_EMA ;
input ENUM_APPLIED_PRICE MA1_Price = PRICE_CLOSE ;
input int MA1_Shift = 0 ;

input int CountBars= 200 ;

string label_info= "" ; 
int window=- 1 ;




color label_color;
double MA_Value;
double myPrice;
double myMAnow;


int nDigits;





//--- indicator buffers
double MA1TempBuffer[];
double MA1Buffer[];
double MA1ColorBuffer[];





int ma1_handle;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                                                            |
//+------------------------------------------------------------------+
void OnInit()
{
         SetIndexBuffer ( 0 , MA1Buffer, INDICATOR_DATA );
         SetIndexBuffer ( 1 , MA1ColorBuffer, INDICATOR_COLOR_INDEX );
         PlotIndexSetDouble ( 0 , PLOT_EMPTY_VALUE , 0.0 );
         PlotIndexSetInteger ( 0 , PLOT_SHIFT ,MA1_Shift);
        

        
        
         IndicatorSetString ( INDICATOR_SHORTNAME , "Color_MA[" + IntegerToString (MA1_Period)+ "]" );
         IndicatorSetInteger ( INDICATOR_DIGITS , _Digits );
   
 if ( Symbol ()== "EURUSD" || Symbol ()== "GBPUSD" || Symbol ()== "EURCHF" || Symbol ()== "USDCAD" || Symbol ()== "EURGBP" || Symbol ()== "AUDUSD" || Symbol ()== "USDCHF" || Symbol ()== "6S_CONT" )  nDigits = 4 ; else nDigits = 2 ;

         ma1_handle = iMA ( NULL , 0 , MA1_Period, 0 , MA1_Mode, MA1_Price); 
        
        
  
   label_info= "myMA" + IntegerToString (MA1_Mode)+ IntegerToString (MA1_Period);
        
   
   //--- initialize a label in upper right corner

           // find indicator's window handle
   if (( ENUM_PROGRAM_TYPE ) MQL5InfoInteger ( MQL5_PROGRAM_TYPE )== PROGRAM_INDICATOR )
     window= ChartWindowFind ();
     
     
        
   
}

//+------------------------------------------------------------------+
//| 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[])
{
         int limit;
         if (CountBars >= rates_total) limit = 0 ; else limit = rates_total - CountBars; 
        

         CopyBuffer (ma1_handle, 0 , 0 , rates_total, MA1TempBuffer);
        

         for ( int i = rates_total - 1 ; i > limit; i--)
        {
                MA1Buffer[i] = MA1TempBuffer[i];
           double myMA_now = MA1TempBuffer[i];
                 double myMA_previous = MA1TempBuffer[i - 1 ]; //MA One bar ago
                
                
                 
                 if (myMA_now >= myMA_previous) MA1ColorBuffer[i] = 0 ;
                 else if (myMA_now < myMA_previous) MA1ColorBuffer[i] = 1 ;
                        
        }
                

        myMAnow=MA1TempBuffer[rates_total- 1 -MA1_Shift]; 
        


          
   myPrice = SymbolInfoDouble ( _Symbol , SYMBOL_BID );
   
   if (myPrice>myMAnow)label_color= Lime ;   else label_color= Red ; 

   
   


   // check if label object does not already exist and create it
 
   if ( ObjectFind ( 0 ,label_info)< 0 )
  {
       // Create label in indicator's window 
       ObjectCreate ( 0 ,label_info, OBJ_LABEL ,window, 0 , 0 ); 
         // Set X and Y distance from UPPER RIGHT CORNER      
       ObjectSetInteger ( 0 ,label_info, OBJPROP_XDISTANCE , 100 );
       ObjectSetInteger ( 0 ,label_info, OBJPROP_YDISTANCE , 20 );
       ObjectSetInteger ( 0 ,label_info, OBJPROP_CORNER , CORNER_RIGHT_UPPER ); 
          
       // Set text properties: colour, font and font size
       ObjectSetInteger ( 0 ,label_info, OBJPROP_COLOR ,label_color);
       ObjectSetString ( 0 ,label_info, OBJPROP_FONT , "Arial" );
       ObjectSetInteger ( 0 ,label_info, OBJPROP_FONTSIZE , 14 );   
    
       // Set text to display
       ObjectSetString ( 0 ,label_info, OBJPROP_TEXT , DoubleToString (myMAnow,nDigits));

      
     
  } else Print ( "label_info already exists" ); 
  

 
         return (rates_total);
}
//+------------------------------------------------------------------+ 

void OnDeinit( const int reason)
  {
//---
   if (! ObjectFind ( 0 ,label_info)< 0 )
       ObjectDelete ( 0 , label_info);
  }
  
   //------------------------------------------------------------------------
 
supermagix :

간단한 지표에 대한 제안이 필요합니다.

닫기 > EMA 34 = 녹색 히스토감 또는 ....선 또는 ....화살표...

닫기< EMA 34 = 리드 히스토그램 또는...선 또는...화살표...

도움에 감사드립니다


이 목적을 위해 MACD 를 시도할 수 있습니다.
파일:
 
walb99 :
이 목적을 위해 MACD 를 시도할 수 있습니다.

예, 하지만 "지표의 곡선"을 따라가서는 안 되며 변화하는 색상만 표시해야 합니다.

고마워요

 
supermagix :

예, 하지만 "지표의 곡선"을 따라가서는 안 되며 변화하는 색상만 표시해야 합니다.

고마워요

MT4의 표시기는 러시아 색상이라고 합니다.

/go?link=https://www.forexfactory.com/showthread.php?t=173962

HMA를 EMA34로 교체하기만 하면 됩니다.