코딩하는 방법? - 페이지 115

 
matrixebiz:
나는 이것을 해서 똑같은 일을 하고 있지 않은가?;

if (Hour() 17) TradeHour = false;

의미, 시간이 12와 17 사이인 경우 TradeHour=true , 맞습니까?

(내 매수/매도 명세서에 && TradeHour 추가)

다음 진술을 부정:

if(Hour()>=12 && Hour()<17)

TradingEnabled=true;

[/CODE]

is

[CODE]

if(Hour()=17)

TradingEnabled=false;

 

하나 더 코드에 재진입 지연을 추가하여 거래가 막 열리고 닫히면 60분 정도 기다렸다가 거래 조건이 여전히 충족되는지 다시 확인 합니다.

고맙습니다

 
matrixebiz:
하나 더 코드에 재진입 지연을 추가하여 거래가 막 열리고 닫히면 60분 정도 기다렸다가 거래 조건이 여전히 충족되는지 다시 확인합니다. 고맙습니다

귀하의 요청이 무엇인지 명확하지 않습니다.

거래 조건 확인 과 다음 거래 사이에 60분을 기다리시겠습니까?

이것이 귀하의 요청이라면 다음과 같이 작동해야 합니다.

// Global variable

bool TradingEnabled = true; // flag to enable/disabled trading logic

bool TradingCheckDone = false; // flag to know if a a check was just done

datetime LastCheckTime = 0; // Time when the last check was done

.... somewhere in EA start() function ....

if( !TradingCheckDone )

{

// Default: We assume that trading logic must run ...

TradingEnabled = true;

// ... but only between 12:00:00 and 16:59:59

if(Hour()=17)

TradingEnabled=false;

// We must remember a check was just done

TradingCheckDone = true;

// We must even know when it was done

LastCheckTime = TimeCurrent();

} else

{

// if a hour has passed since the last check, it's time to retry

if( TimeCurrent() - LastCheckTime >= 3600 )

{

TradingCheckDone = false;

}

}

 
gorgoroth:
귀하의 요청이 무엇인지 명확하지 않습니다.

거래 조건 확인과 다음 거래 사이에 60분을 기다리시겠습니까?

이것이 귀하의 요청이라면 다음과 같이 작동해야 합니다.

// Global variable

bool TradingEnabled = true; // flag to enable/disabled trading logic

bool TradingCheckDone = false; // flag to know if a a check was just done

datetime LastCheckTime = 0; // Time when the last check was done

.... somewhere in EA start() function ....

if( !TradingCheckDone )

{

// Default: We assume that trading logic must run ...

TradingEnabled = true;

// ... but only between 12:00:00 and 16:59:59

if(Hour()=17)

TradingEnabled=false;

// We must remember a check was just done

TradingCheckDone = true;

// We must even know when it was done

LastCheckTime = TimeCurrent();

} else

{

// if a hour has passed since the last check, it's time to retry

if( TimeCurrent() - LastCheckTime >= 3600 )

{

TradingCheckDone = false;

}

}

아니요, 거래가 방금 발생하여 마감된 경우에만 EA가 1시간 동안 기다렸다가 거래 조건이 여전히 충족되는지 확인 하고, 충족되면 확인, 다시 거래하지만 그렇지 않은 경우에만 해당됩니다. 이 코드는 내가 원하는 작업을 수행합니까? TimeCurrent 확인으로 인해 테스터에서 작동합니까?

편집: 매시간 거래가 마감된 직후 확인을 수행한 다음 상태 확인을 위해 한 시간을 기다리면 됩니다. 그런 다음 하루에 다른 거래가 생성되고 닫히면 다시 한 시간을 기다리십시오. 신호가 없으면 다음 거래가 열리고 닫힐 때까지 더 이상 수표를 기다리지 않아도 됩니다.

고맙습니다

내가 언급한 올바른 설정으로 수정할 수 있는 경우 약간의 EA가 첨부되어 있습니다. 감사해요

파일:
ozfx_method.mq4  11 kb
 

Buy_Limit 및 Buy_Stop

지정가 주문과 지정가 주문의 차이점은 무엇입니까?

감사해요

 
gorgoroth:
안녕하세요 여러분,

EA에서 구성 설정을 관리하는 기능 세트를 개발했습니다.

이러한 함수는 C++ DLL에서 내보내고 내보낸 각 함수에는 내 MQL4에서 요청한 대류를 호출하는 __stdcall이 있습니다.

내 문제는 함수가 EA에 문자열을 반환해야 할 때 발생합니다.

당연히 함수는 다음을 수행할 수 없습니다.

- 지역 변수에 대한 포인터 반환(변수가 범위를 벗어남)

- dll 전역 변수에 대한 포인터 반환(동시 액세스 문제)

- 힙 할당 문자열에 대한 포인터 반환(EA에서 호출할 메모리를 해제하는 함수 필요: 이 접근 방식이 마음에 들지 않음)

그래서 EA에서 문자열과 문자열 크기를 전달하기로 결정했습니다. 에스:

string buffer;

GetString( buffer, 30 );

[/CODE]

and from the c++ dll, something like this

void __stdcall GetString( LPTSTR buffer, int BufSize )

{

// Read a string from a some source

....

// -1 to take into account the terminating null character

StringCchCopy( buffer, BufSize-1, ReadStringFromASource );

}

[/CODE]

Here starts the weird behaviour of MQL managing strings returned from a DLL.

using the following code:

string buffer;

GetString( buffer, 30 );

the first time buffer contains the right string. A first question arises: buffer is not initialized but after calling GetString it contains the string returned. I have to suppose that MQL allocates space for a string variable when it's declared.

Next time GetString() is called the string returned seems to be truncated to the length-1 of the previous string length and not resetted as expected because of the 'string buffer;' statement.

Tried even:

[CODE]

string buffer = " "; // 'allocate' 30 blank characters

GetString( buffer, StringLen(buffer) );

but after the first time, when the execution returns to this code, the assignment of buffer does not work any more and buffer still contains the previous read string, and it seems it can only contains the number of characters of his content.

At first I have thought that the null character is not handled very well by MQL and modified the c++ code like this ...

[CODE]

CopyMemory( buffer, ReadStringFromASource, min(BufferSize,ReadStringFromASourceLength) );

종료 null 문자를 추가하지 않습니다.

그러나 MQL에서 호출하면 문자열이 전혀 반환되지 않습니다.

누군가가 답을 가지고 있습니까?

아무도 DLL에서 문자열을 반환하는 데 문제가 있습니까?

 

도움이 필요해..

누구든지 나에게 코드를 보여줄 수 있습니까? 내 EA에 첨부하려면..

신호당 하나의 주문.. 때때로 나는 다른 TF의 3개의 신호 원인이 있습니다. 모든 신호가 열리기를 원합니다.

또는 막대당 하나의 주문이 필요하지만 각 타임프레임은 하나의 EA에 연결되는 코드입니다. 차트를 많이 열고 싶지 않습니다.

 

내 BuyStop에 어떤 문제가 있습니까?

ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,Ask+Distance*Point,Slippage,Bid-Distance-StopLoss*Point,Ask+Distance+TakeProfit*Point,"",MagicNumber,0,Blue);

 
matrixebiz:
내 BuyStop에 어떤 문제가 있습니까?

ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,Ask+Distance*Point,Slippage,Bid-Distance-StopLoss*Point,Ask+Distance+TakeProfit*Point,"",MagicNumber,0,Blue);

당신의 손절매와 이익실현 ..

추가하기 전에 거리에 *point를 추가해야 합니다.

또는

Bid-((Distance-StopLoss)*Point),Ask+((Distance+TakeProfit)*Point)