모두에게 좋은 하루. 조언자가 있습니다 - 추세의 교차점에 대한 신호와 수평선 특정 색상. 트렌드와 특정 스타일의 수평선이 교차하는 지점에서 삐 소리가 나도록 리메이크하기로 했다. 일어난. 그러나 추세선이 교차할 때 신호를 보내기 위해 필요합니다. 오른쪽으로만 빔이 있습니다. 나는 무엇을 해야 하는지 이해한다
OBJPROP_RAY_RIGHT
하지만 내가 따라잡을 때까지 어디서 어떻게. 미리 감사드립니다.
//+------------------------------------------------------------------+//| TrendlineCrossAlert.mq5 |//| Copyright 2018, Strx |//| https://www.mql5.com/en/users/strx |//+------------------------------------------------------------------+#define EAName "TrendlineCrossAlert"#define EAVersion "1.01"#property copyright"Copyright 2018, Strx"#property link"https://www.mql5.com/en/users/strx"#property version EAVersion
#property description"Horizontal and Trendlines cross detection on any pair/timeframe"#property description"good for scalping on small timeframes (M1 to M15) and trend following on bigger ones."#property description"It send notifications when price crosses trendlines and horizontal lines"#property description"of specified color and when it happens, it change its color to CrossedColor input parameter"#property description"to be sure not to send multiple notifications for same line"#include <Arrays\ArrayString.mqh>
#include <Trade\SymbolInfo.mqh>
#include <ChartObjects\ChartObject.mqh>
#include <ChartObjects\ChartObjectsLines.mqh>
//--- External inputssinputENUM_LINE_STYLE MonitoringStyle = STYLE_SOLID ; //MonitoringColor, EA only monitors this lines stylesinputENUM_LINE_STYLE CrossedStyle = STYLE_DASH ; //CrossedColor, EA changes crossed lines style to this valuesinputbool EnableAlerts = true ;
sinputbool EnableNotifications= true ;
sinputbool EnableEmails= false ;
//+------------------------------------------------------------------+//| Trendlines and Horizontal lines crossing notification expert//+------------------------------------------------------------------+class CTrendlineCrossAlertExpert
{
protected :
CSymbolInfo m_symbol; // symbol info object//--- Logic vars
CArrayString m_objectNames;
public :
CTrendlineCrossAlertExpert( void );
~CTrendlineCrossAlertExpert( void );
bool Init( void );
void Deinit( void );
bool Processing( void );
protected :
//--- Inline functions string FormatPrice( double price){ returnStringFormat ( "%." +( string )m_symbol. Digits ()+ "f" ,price); };
bool IsNewBar(){ returniVolume ( NULL , 0 , 0 )== 1 ; };
//--- Logic functionsint FindActiveObjects();
bool ActiveObject( string objName);
bool PriceCrossed( string objName);
void NotifyCrossing( string objName);
};
//--- global expert
CTrendlineCrossAlertExpert ExtExpert;
//+------------------------------------------------------------------+//| Constructor |//+------------------------------------------------------------------+
CTrendlineCrossAlertExpert::CTrendlineCrossAlertExpert( void ){}
//+------------------------------------------------------------------+//| Destructor |//+------------------------------------------------------------------+
CTrendlineCrossAlertExpert::~CTrendlineCrossAlertExpert( void ){}
//+------------------------------------------------------------------+//| Initialization and checking for input parameters |//+------------------------------------------------------------------+bool CTrendlineCrossAlertExpert::Init( void )
{
//--- initialize common information
m_symbol.Name( Symbol ()); // symbol return ( true );
}
//+------------------------------------------------------------------+//| main function returns true if any position processed |//+------------------------------------------------------------------+bool CTrendlineCrossAlertExpert::Processing( void )
{
bool rv= false ;
int i;
string objName;
if (m_symbol.RefreshRates())
{
if (FindActiveObjects())
{
for (i= 0 ; i<m_objectNames.Total(); i++)
{
objName=m_objectNames[i];
if (PriceCrossed(objName))
{
ObjectSetInteger ( 0 ,objName, OBJPROP_STYLE ,CrossedStyle);
NotifyCrossing(objName);
}
}
}
}
Comment (EAName, " v." ,EAVersion, " parameters: MonitoringStyle=" ,MonitoringStyle, ", CrossedStyle=" ,CrossedStyle, ", EnableAlerts=" ,EnableAlerts, ", EnableNotifications=" ,EnableNotifications, ", EnableEmails=" ,EnableEmails, "\n" ,
"Monitoring " ,m_objectNames.Total(), " lines" );
return (rv);
}
//+------------------------------------------------------------------+//| Send Notifications function//+------------------------------------------------------------------+void CTrendlineCrossAlertExpert::NotifyCrossing( string objName)
{
string msg= "Price crossed line ''" +objName+ "' on " +m_symbol.Name();
if (EnableAlerts) Alert (msg);
if (EnableNotifications) SendNotification (msg);
if (EnableEmails) SendMail (EAName+ " Event" ,msg);
Print (msg);
}
//+------------------------------------------------------------------+//| Returns true if objName has been crossed up or down by current price//+------------------------------------------------------------------+bool CTrendlineCrossAlertExpert::PriceCrossed( string objName)
{
ENUM_OBJECT objType;
double objPrice= 0.0 ,openPrice,curPrice;
objType=( ENUM_OBJECT ) ObjectGetInteger ( 0 ,objName, OBJPROP_TYPE );
if (objType== OBJ_HLINE )
{
objPrice= ObjectGetDouble ( 0 , objName, OBJPROP_PRICE );
} elseif (objType== OBJ_TREND ){
objPrice= ObjectGetValueByTime ( 0 ,objName, TimeCurrent (), 0 );
}
if (objPrice)
{
openPrice= iOpen ( NULL , 0 , 0 );
curPrice = iClose ( NULL , 0 , 0 );
return (openPrice<=objPrice && curPrice>objPrice) || (openPrice>=objPrice && curPrice<objPrice);
}
returnfalse ;
}
//+------------------------------------------------------------------+//| Returns true if object has to be monitored based on color and//| previous crosses//+------------------------------------------------------------------+bool CTrendlineCrossAlertExpert::ActiveObject( string objName)
{
int objStyle=( int ) ObjectGetInteger ( 0 ,objName, OBJPROP_STYLE , 0 );
return objStyle == MonitoringStyle;
}
//+------------------------------------------------------------------+//| Returns the list of object to be monitored//+------------------------------------------------------------------+int CTrendlineCrossAlertExpert::FindActiveObjects()
{
m_objectNames.Clear();
int nHLines= ObjectsTotal ( 0 ,- 1 , OBJ_HLINE ),
nTrendLines= ObjectsTotal ( 0 ,- 1 , OBJ_TREND ),
i;
string objName;
for (i= 0 ; i<nHLines; i++)
{
objName= ObjectName ( 0 ,i, 0 , OBJ_HLINE );
if (ActiveObject(objName))
{
m_objectNames.Add(objName);
}
}
for (i= 0 ; i<nTrendLines; i++)
{
objName= ObjectName ( 0 ,i, 0 , OBJ_TREND );
if (ActiveObject(objName))
{
m_objectNames.Add(objName);
}
}
return m_objectNames.Total();
}
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit ( void )
{
if (!ExtExpert.Init())
return ( INIT_FAILED );
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+//| Expert new tick handling function |//+------------------------------------------------------------------+voidOnTick ( void )
{
ExtExpert.Processing();
}
//+------------------------------------------------------------------+
Типы объектов - Константы объектов - Константы, перечисления и структуры - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
거래를 시작하기 위한 코드를 게시할 수 있습니까? 작동하지 않는 이유를 알아보겠습니다.
아니요
매개변수 0은 이 차트에 속함을 나타냅니다.
죄송합니다 기능과 혼동
StringFind
거래를 시작하기 위한 코드를 게시할 수 있습니까? 작동하지 않는 이유를 알아보겠습니다.
다음은 귀하의 기능입니다.
여기에 귀하의 기능을 삽입했습니다
첫 번째
OrderOfSymbol=CounterOrderTradeType(- 1 );
여기로 가져와야합니다
나머지는 이제 수정하겠습니다.여기에 귀하의 기능을 삽입했습니다
노력하다
추가 조정 및 업데이트
아직 집에 없어서 내일 테스트 해보겠습니다. 고맙습니다.
아직 집에 없어서 내일 테스트 해보겠습니다. 고맙습니다.
모두에게 좋은 하루. 조언자가 있습니다 - 추세의 교차점에 대한 신호와 수평선 특정 색상. 트렌드와 특정 스타일의 수평선이 교차하는 지점에서 삐 소리가 나도록 리메이크하기로 했다. 일어난. 그러나 추세선이 교차할 때 신호를 보내기 위해 필요합니다. 오른쪽으로만 빔이 있습니다. 나는 무엇을 해야 하는지 이해한다
OBJPROP_RAY_RIGHT
안녕하세요.
아이디어에 따르면 고문은 조건을 확인하고 새로운 막대가 나타나면 주문을 열어야합니다.
" 함수 선언은 전역, 네임스페이스 또는 클래스 범위에서만 허용됩니다" 오류가 발생합니다. 번역: "함수 선언은 전역 범위, 네임스페이스 또는 클래스에서만 허용됩니다."
난 아직도 이해가 안돼, 멍청아. 어디에서 읽어야 하는지 알려주세요. 미리 감사드립니다!)
***