새로운 기능 "FileSave"는 바이너리 형식으로만 파일을 저장합니까?
CGraphic.mqh 클래스에 대한 제안.
그래프 개체를 삭제하려면 GraphPlot 메서드를 변경해야 합니다.
//| Create graphic of one curve and return resource name |
//+------------------------------------------------------------------+
string GraphPlot( const double &y[],ENUM_CURVE_TYPE type=CURVE_POINTS)
{
string name= "Graphic" +( string )( GetTickCount ()+ MathRand ());
ulong width = ChartGetInteger ( 0 , CHART_WIDTH_IN_PIXELS );
ulong height= ChartGetInteger ( 0 , CHART_HEIGHT_IN_PIXELS );
CGraphic graphic;
//--- create graphic and add curves
graphic.Create( 0 ,name, 0 , 65 , 45 ,( int )( 0.6 *width),( int )( 0.65 *height));
graphic.CurveAdd(y,type);
//--- plot curves
graphic.CurvePlotAll();
graphic.Update();
//--- return resource name
//return graphic.ResourceName();
return graphic.ChartObjectName();
}
예를 들어, 이제 차트에 "Graphic27489614"라는 개체가 있고, graphic.ResourceName() 메서드는 "::Graphic2748961427502758"을 반환하고, graphic.ChartObjectName() 메서드는 "Graphic27489614"를 반환합니다. 그리고 변경 을 하면 객체의 이름으로 ObjectDelete를 호출하여 그래프 객체를 삭제할 수 있습니다.
CGraphic.mqh 클래스에 대한 제안.
그래프 개체를 삭제하려면 GraphPlot 메서드를 변경해야 합니다.
예를 들어, 이제 차트에 "Graphic27489614"라는 개체가 있고, graphic.ResourceName() 메서드는 "::Graphic2748961427502758"을 반환하고, graphic.ChartObjectName() 메서드는 "Graphic27489614"를 반환합니다. 그리고 변경 을 하면 객체의 이름으로 ObjectDelete를 호출하여 그래프 객체를 삭제할 수 있습니다.
그래서 이 기회는 이미 있습니다. CGraphic::ChartObjectName () 메서드를 호출하는 것만으로 삭제할 개체의 이름을 얻습니다.
PS 또는 CGraphic::Destroy () 메서드도 있습니다.
CGraphic.mqh 클래스에 대한 제안.
아니요. 두 방법 모두 작동하지 않고(CGraphic::ChartObjectName()은 "NULL"을 반환함), CGraphic::Destroy()는 차트 삭제에 대해 전혀 작동하지 않습니다.
둘 다 나를 위해 일합니다. 이 스크립트를 테스트하고 버전을 보여주세요. 왜 그것이 당신에게 효과가 없었는지 궁금해하십시오.
스크립트에서 두 가지 방법을 테스트할 수 있습니다.
//| Test.mq5 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
//---
#include <Math/Stat/Binomial.mqh>
#include <Graphics/Graphic.mqh>
//--- Размер массива
#define ARRAY_SIZE 50
//---
double array_values[ARRAY_SIZE];
double array_results[ARRAY_SIZE];
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart ( void )
{
string name = "Graphic" ;
ulong width =:: ChartGetInteger ( 0 , CHART_WIDTH_IN_PIXELS );
ulong height =:: ChartGetInteger ( 0 , CHART_HEIGHT_IN_PIXELS );
//---
CGraphic graphic;
//--- create graphic
graphic.Create( 0 ,name, 0 , 65 , 45 ,( int )( 0.6 *width),( int )( 0.65 *height));
//---
InitArray();
CCurve *curve1=graphic.CurveAdd(array_values,CURVE_POINTS);
//---
graphic.CurvePlotAll();
graphic.Update();
//---
for ( int i= 0 ; i< 10 ; i++)
{
InitArray();
curve1.Update(array_values);
//---
graphic.CurvePlotAll();
graphic.Update();
//---
Sleep ( 500 );
}
//---
graphic.Destroy();
//---
:: Print ( __FUNCTION__ , " > graphic.ChartObjectName(): " ,graphic.ChartObjectName());
if (!:: ObjectDelete ( 0 ,graphic.ChartObjectName()))
Print ( __FUNCTION__ , " > Объект уже удалён!" );
}
//+------------------------------------------------------------------+
//| Генерация значений |
//+------------------------------------------------------------------+
void InitArray( void )
{
for ( int j= 0 ; j<ARRAY_SIZE; j++)
array_values[j]=j;
Shuffle(array_values);
}
//+------------------------------------------------------------------+
//| Тасование значений массива |
//+------------------------------------------------------------------+
void Shuffle( double &array[])
{
for ( uint i= 0 ; i<ARRAY_SIZE; i++)
RandomSwap(array_values,i);
}
//+------------------------------------------------------------------+
//| Случайно поменять элементы местами |
//+------------------------------------------------------------------+
void RandomSwap( double &array[], uint i)
{
//--- Случайный индекс для замены
uint j=:: rand ()%ARRAY_SIZE;
//--- Меняем местами
double temp =array[i];
array[i] =array[j];
array[j] =temp;
}
//+------------------------------------------------------------------+
나는 원래 이 예제를 여기에서 괴롭혔습니다( MetaTrader 5 플랫폼 빌드 1485의 새 버전에서 가져옴: 추가 테스트 모드 및 표준 라이브러리의 차트 작성 )
//| Test_1.mq5 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
#include <Math/Stat/Binomial.mqh>
#include <Graphics/Graphic.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnStart ( void )
{
double vars[ 101 ];
double results[ 101 ];
const int N= 2000 ;
//---
MathSequence( 0 ,N, 20 ,vars);
MathProbabilityDensityBinomial(vars,N, M_PI / 10 , true ,results);
GraphPlot(results);
//---
}
#include <Math\Stat\Normal.mqh>
#include <Graphics\Graphic.mqh>
void OnStart()
{
//---
double random_values[];
double pdf[];
double cdf[];
double x[];
if(MathRandomNormal(0,1,1000000,random_values))
{
if(MathProbabilityDensityEmpirical(random_values,200,x,pdf))
{
GraphPlot(x,pdf,CURVE_LINES);
//---
DebugBreak();
}
if(MathCumulativeDistributionEmpirical(random_values,200,x,cdf))
{
GraphPlot(x,cdf,CURVE_LINES);
//---
DebugBreak();
}
}
}
나는 원래 이 예제를 여기에서 괴롭혔습니다( MetaTrader 5 플랫폼 빌드 1485의 새 버전에서 가져옴: 추가 테스트 모드 및 표준 라이브러리의 차트 작성 )
//| Test_1.mq5 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property version "1.00"
#include <Math/Stat/Binomial.mqh>
#include <Graphics/Graphic.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnStart ( void )
{
double vars[ 101 ];
double results[ 101 ];
const int N= 2000 ;
//---
MathSequence( 0 ,N, 20 ,vars);
MathProbabilityDensityBinomial(vars,N, M_PI / 10 , true ,results);
GraphPlot(results);
//---
}
일반적으로 삭제하는 동안 다음을 수행합니다.
ChartRedraw ();
SL/TP가 OnTradeTransaction()에서 작동했는지 어떻게 알 수 있습니까?
다음은 내가 한 일입니다. 도움이 되지 않았습니다.
const MqlTradeRequest &request, // структура запроса
const MqlTradeResult &result) // структура ответа
{
if (trans.type == TRADE_TRANSACTION_HISTORY_ADD )
{
datetime date = TimeCurrent ();
MqlDateTime dateT;
TimeToStruct (date, dateT);
dateT.hour += 1 ;
date = StructToTime (dateT);
if ( HistorySelect ( TimeCurrent (), date))
{
int dealsTotal = HistoryDealsTotal ();
ulong ticketD = HistoryDealGetTicket (dealsTotal - 1 );
if ( HistoryDealGetString (ticketD, DEAL_SYMBOL ) == Symbol ())
{
ENUM_DEAL_ENTRY entry = ( ENUM_DEAL_ENTRY ) HistoryDealGetInteger (ticketD, DEAL_ENTRY );
if (entry == DEAL_ENTRY_OUT )
{
int ordersTotal = HistoryOrdersTotal ();
ulong ticketO = HistoryOrderGetTicket (ordersTotal - 1 );
if ( HistoryOrderGetString (ticketO, ORDER_SYMBOL ) == Symbol ())
{
double orderPrice = HistoryOrderGetDouble (ticketO, ORDER_PRICE_OPEN );
double orderSL = HistoryOrderGetDouble (ticketO, ORDER_SL );
double orderTP = HistoryOrderGetDouble (ticketO, ORDER_TP );
if (orderPrice == orderSL)
Print ( "Сработал SL" );
if (orderPrice == orderTP)
Print ( "Сработал TP" );
}
}
}
}
}
}
그리고 일반적으로 어떤 식 으로든 더 쉽게 불가능합니다!
새로운 기능 "FileSave"는 바이너리 형식으로만 파일을 저장합니까?
//| Scripts_Test.mq5 |
//| Copyright 2012, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
//--- входные параметры
input int rates_to_save= 1000 ; // количество
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart ()
{
string filename= _Symbol + "_ticks.csv" ;
MqlRates rates[];
//---
int copied= CopyRates ( Symbol (), Period (), 0 ,rates_to_save,rates);
if (copied!=- 1 )
{
PrintFormat ( " CopyRates(%s) copied %d rates" , Symbol (),copied);
//--- запишем тики в файл
if (!FileSave(filename,rates, FILE_COMMON ))
PrintFormat ( "FileSave() failed, error=%d" , GetLastError ());
}
else
PrintFormat ( "Failed CopyRates(%s), Error=" , _Symbol , GetLastError ());
}
//+------------------------------------------------------------------+
내가하고 싶은 것 : 파일을 "csv"형식으로 저장 Excel에서 열려면.