코딩 도움말 - 페이지 263

 
mladen:
MrWigglesworth 유형 4로 dema가 추가된 버전은 다음과 같습니다. ma__dema_crossover_with_arrow_and_email.mq4

엄청난! 도움을 주셔서 감사합니다.

즐거운 휴일 보내세요!!

 

이제 코드에서 브로커의 GMT(내 GMT가 아님)를 자동으로 찾을 수 있는 사람이 있습니까?

 
techmac:
이제 코드에서 브로커의 GMT(내 GMT가 아님)를 자동으로 찾을 수 있는 사람이 있습니까?

브로커를 위한 자동 방법 없음

 

안녕하세요 mladen님

실제 차트에서 몇 시간을 잘라낸 스크립트에 대해 질문했습니다. 이제 차트에 시간 오프셋이 있도록 각 막대에 지연을 적용하고 싶습니다.

그런 식으로 시도했지만 작동하지 않습니다(내 생각처럼)

input int TimeDelay_Minutes = 60;

input int StartHour = 8;

input int StartMinute = 0;

input int CloseHour = 16;

input int CloseMinute = 30;

int InpPeriodMultiplier=1; // Period multiplier factor

int ExtHandle=-1;

//+------------------------------------------------------------------+

//| script program start function |

//+------------------------------------------------------------------+

void OnStart()

{

datetime time0;

ulong last_fpos=0;

long last_volume=0;

int i, start_pos, periodseconds;

int hwnd=0, cnt=0;

//---- History header

int version=401;

string c_copyright;

string c_symbol=Symbol();

int i_period=Period()*InpPeriodMultiplier;

int i_digits=Digits;

int i_unused[13];

MqlRates rate;

//---

ExtHandle=FileOpenHistory(c_symbol+(string)3+".hst", FILE_BIN|FILE_WRITE|FILE_SHARE_READ|FILE_ANSI);

if(ExtHandle<0)

return;

ArrayInitialize(i_unused,0);

//--- write history file header

FileWriteInteger(ExtHandle, version, LONG_VALUE);

FileWriteString(ExtHandle, c_copyright, 64);

FileWriteString(ExtHandle, c_symbol, 12);

FileWriteInteger(ExtHandle, 3, LONG_VALUE);

FileWriteInteger(ExtHandle, i_digits, LONG_VALUE);

FileWriteInteger(ExtHandle, 0, LONG_VALUE); //timesign

FileWriteInteger(ExtHandle, 0, LONG_VALUE); //last_sync

FileWriteArray(ExtHandle, i_unused, 0, 13);

//--- write history file

periodseconds=i_period*60;

start_pos=Bars-1;

rate.open=Open[start_pos];

rate.low=Low[start_pos];

rate.high=High[start_pos];

rate.tick_volume=(long)Volume[start_pos];

rate.spread=0;

rate.real_volume=0;

//--- normalize open time

rate.time=Time[start_pos]/periodseconds;

rate.time*=periodseconds;

for(i=start_pos-1; i>=0; i--)

{

if(IsStopped())

break;

time0=Time- 1 * 60 *TimeDelay_Minutes;

//--- history may be updated

if(i==0)

{

//--- modify index if history was updated

if(RefreshRates())

i=iBarShift(NULL,0,time0);

}

//---

if((time0>=rate.time+periodseconds || i==0)&& MainTime(time0)==true)

{

if(i==0)

{

rate.time=time0/periodseconds; //NEU

rate.tick_volume+=(long)Volume[0];

if(rate.low>Low[0])

rate.low=Low[0];

if(rate.high<High[0])

rate.high=High[0];

rate.close=Close[0];

}

last_fpos=FileTell(ExtHandle);

last_volume=(long)Volume;

FileWriteStruct(ExtHandle,rate);

cnt++;

if(time0>=rate.time+periodseconds)

{

rate.time=time0/periodseconds;

rate.time*=periodseconds;

rate.open=Open;

rate.low=Low;

rate.high=High;

rate.close=Close;

rate.tick_volume=last_volume;

}

}

else if(MainTime(time0)==true)

{

rate.time=time0/periodseconds; //NEU

rate.tick_volume+=(long)Volume;

if(rate.low>Low)

rate.low=Low;

if(rate.high<High)

rate.high=High;

rate.close=Close;

}

}

FileFlush(ExtHandle);

//Print(cnt," record(s) written");

//--- collect incoming ticks

datetime last_time=LocalTime()-5;

while(!IsStopped())

{

datetime cur_time=LocalTime();

//--- check for new rates

if(RefreshRates())

{

time0=Time[0]- 1 * 60 *TimeDelay_Minutes;

FileSeek(ExtHandle,last_fpos,SEEK_SET);

//--- is there current bar?

if(time0<rate.time+periodseconds && MainTime(time0)==true)

{

rate.tick_volume+=(long)Volume[0]-last_volume;

last_volume=(long)Volume[0];

if(rate.low>Low[0])

rate.low=Low[0];

if(rate.high<High[0])

rate.high=High[0];

rate.close=Close[0];

}

else if(MainTime(time0)==true)

{

//--- no, there is new bar

rate.tick_volume+=(long)Volume[1]-last_volume;

if(rate.low>Low[1])

rate.low=Low[1];

if(rate.high<High[1])

rate.high=High[1];

//--- write previous bar remains

FileWriteStruct(ExtHandle,rate);

last_fpos=FileTell(ExtHandle);

//----

rate.time=time0/periodseconds;

rate.time*=periodseconds;

rate.open=Open[0];

rate.low=Low[0];

rate.high=High[0];

rate.close=Close[0];

rate.tick_volume=(long)Volume[0];

last_volume=rate.tick_volume;

}

//----

FileWriteStruct(ExtHandle,rate);

FileFlush(ExtHandle);

//---

if(hwnd==0)

{

hwnd=WindowHandle(Symbol(),i_period);

if(hwnd!=0)

Print(" "); //Chart window detected

}

//--- refresh window not frequently than 1 time in 2 seconds

if(hwnd!=0 && cur_time-last_time>=2)

{

PostMessageA(hwnd,WM_COMMAND,33324,0);

last_time=cur_time;

}

}

Sleep(50);

}

//---

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{

//---

if(ExtHandle>=0)

{

FileClose(ExtHandle);

ExtHandle=-1;

}

//---

}

 
sunshineh:
안녕하세요 mladen님

실제 차트에서 몇 시간을 잘라낸 스크립트에 대해 질문했습니다. 이제 차트에 시간 오프셋이 있도록 각 막대에 지연을 적용하고 싶습니다.

그런 식으로 시도했지만 작동하지 않습니다(내 생각처럼)

input int TimeDelay_Minutes = 60;

input int StartHour = 8;

input int StartMinute = 0;

input int CloseHour = 16;

input int CloseMinute = 30;

int InpPeriodMultiplier=1; // Period multiplier factor

int ExtHandle=-1;

//+------------------------------------------------------------------+

//| script program start function |

//+------------------------------------------------------------------+

void OnStart()

{

datetime time0;

ulong last_fpos=0;

long last_volume=0;

int i, start_pos, periodseconds;

int hwnd=0, cnt=0;

//---- History header

int version=401;

string c_copyright;

string c_symbol=Symbol();

int i_period=Period()*InpPeriodMultiplier;

int i_digits=Digits;

int i_unused[13];

MqlRates rate;

//---

ExtHandle=FileOpenHistory(c_symbol+(string)3+".hst", FILE_BIN|FILE_WRITE|FILE_SHARE_READ|FILE_ANSI);

if(ExtHandle<0)

return;

ArrayInitialize(i_unused,0);

//--- write history file header

FileWriteInteger(ExtHandle, version, LONG_VALUE);

FileWriteString(ExtHandle, c_copyright, 64);

FileWriteString(ExtHandle, c_symbol, 12);

FileWriteInteger(ExtHandle, 3, LONG_VALUE);

FileWriteInteger(ExtHandle, i_digits, LONG_VALUE);

FileWriteInteger(ExtHandle, 0, LONG_VALUE); //timesign

FileWriteInteger(ExtHandle, 0, LONG_VALUE); //last_sync

FileWriteArray(ExtHandle, i_unused, 0, 13);

//--- write history file

periodseconds=i_period*60;

start_pos=Bars-1;

rate.open=Open[start_pos];

rate.low=Low[start_pos];

rate.high=High[start_pos];

rate.tick_volume=(long)Volume[start_pos];

rate.spread=0;

rate.real_volume=0;

//--- normalize open time

rate.time=Time[start_pos]/periodseconds;

rate.time*=periodseconds;

for(i=start_pos-1; i>=0; i--)

{

if(IsStopped())

break;

time0=Time- 1 * 60 *TimeDelay_Minutes;

//--- history may be updated

if(i==0)

{

//--- modify index if history was updated

if(RefreshRates())

i=iBarShift(NULL,0,time0);

}

//---

if((time0>=rate.time+periodseconds || i==0)&& MainTime(time0)==true)

{

if(i==0)

{

rate.time=time0/periodseconds; //NEU

rate.tick_volume+=(long)Volume[0];

if(rate.low>Low[0])

rate.low=Low[0];

if(rate.high<High[0])

rate.high=High[0];

rate.close=Close[0];

}

last_fpos=FileTell(ExtHandle);

last_volume=(long)Volume;

FileWriteStruct(ExtHandle,rate);

cnt++;

if(time0>=rate.time+periodseconds)

{

rate.time=time0/periodseconds;

rate.time*=periodseconds;

rate.open=Open;

rate.low=Low;

rate.high=High;

rate.close=Close;

rate.tick_volume=last_volume;

}

}

else if(MainTime(time0)==true)

{

rate.time=time0/periodseconds; //NEU

rate.tick_volume+=(long)Volume;

if(rate.low>Low)

rate.low=Low;

if(rate.high<High)

rate.high=High;

rate.close=Close;

}

}

FileFlush(ExtHandle);

//Print(cnt," record(s) written");

//--- collect incoming ticks

datetime last_time=LocalTime()-5;

while(!IsStopped())

{

datetime cur_time=LocalTime();

//--- check for new rates

if(RefreshRates())

{

time0=Time[0]- 1 * 60 *TimeDelay_Minutes;

FileSeek(ExtHandle,last_fpos,SEEK_SET);

//--- is there current bar?

if(time0<rate.time+periodseconds && MainTime(time0)==true)

{

rate.tick_volume+=(long)Volume[0]-last_volume;

last_volume=(long)Volume[0];

if(rate.low>Low[0])

rate.low=Low[0];

if(rate.high<High[0])

rate.high=High[0];

rate.close=Close[0];

}

else if(MainTime(time0)==true)

{

//--- no, there is new bar

rate.tick_volume+=(long)Volume[1]-last_volume;

if(rate.low>Low[1])

rate.low=Low[1];

if(rate.high<High[1])

rate.high=High[1];

//--- write previous bar remains

FileWriteStruct(ExtHandle,rate);

last_fpos=FileTell(ExtHandle);

//----

rate.time=time0/periodseconds;

rate.time*=periodseconds;

rate.open=Open[0];

rate.low=Low[0];

rate.high=High[0];

rate.close=Close[0];

rate.tick_volume=(long)Volume[0];

last_volume=rate.tick_volume;

}

//----

FileWriteStruct(ExtHandle,rate);

FileFlush(ExtHandle);

//---

if(hwnd==0)

{

hwnd=WindowHandle(Symbol(),i_period);

if(hwnd!=0)

Print(" "); //Chart window detected

}

//--- refresh window not frequently than 1 time in 2 seconds

if(hwnd!=0 && cur_time-last_time>=2)

{

PostMessageA(hwnd,WM_COMMAND,33324,0);

last_time=cur_time;

}

}

Sleep(50);

}

//---

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{

//---

if(ExtHandle>=0)

{

FileClose(ExtHandle);

ExtHandle=-1;

}

//---

}

파일에 쓰기 전에 rate.time 에 약간의 시간 이동을 추가한 다음(추가는 양수 또는 음수일 수 있음) 파일에 파일을 작성할 때 원래 값으로 되돌리는 것이 어떻습니까?

 
mladen:
MrWigglesworth 유형 4로 dema가 추가된 버전은 다음과 같습니다. ma__dema_crossover_with_arrow_and_email.mq4

안녕하세요 Mr. MLaden입니다.

오늘 기분이 어떠세요? 5개와 12개의 DEMA 지표가 있는 차트가 첨부되어 있습니다. 또한 차트에는 수정한 ma+DEMA 지표가 있습니다. 그것은 5-ma1 및 12-ma2로 설정되고 두 MA에 대해 유형 4(DEMA)를 선택했습니다...화살표에서 볼 수 있듯이 선과 일치하지 않는 것 같습니다...무엇에 대한 생각 잘못된? 고맙습니다!

 
MrWigglesworth:
안녕하세요 Mr. MLaden입니다.

오늘 기분이 어떠세요? 5개와 12개의 DEMA 지표가 있는 차트가 첨부되어 있습니다. 또한 차트에는 수정한 ma+DEMA 지표가 있습니다. 그것은 5-ma1 및 12-ma2로 설정되고 두 MA에 대해 유형 4(DEMA)를 선택했습니다...화살표에서 볼 수 있듯이 선과 일치하지 않는 것 같습니다...무엇에 대한 생각 잘못된? 고맙습니다!

아, 그런데 여기에 도움이 된다면 제가 사용하고 있는 DEMA 표시기 가 있습니다.

파일:
dema_1.mq4  4 kb
 
MrWigglesworth:
안녕하세요 Mr. MLaden입니다.

오늘 기분이 어떠세요? 5개와 12개의 DEMA 지표가 있는 차트가 첨부되어 있습니다. 또한 차트에는 수정한 ma+DEMA 지표가 있습니다. 그것은 5-ma1 및 12-ma2로 설정되고 두 MA에 대해 유형 4(DEMA)를 선택했습니다...화살표에서 볼 수 있듯이 선과 일치하지 않는 것 같습니다...무엇에 대한 생각 잘못된? 고맙습니다!

비교를 위해 어떤 데마를 사용하고 있습니까?

참고로 데마는 에마의 에마가 아니라 에마와 에마의 2배 차이입니다. 에마의

이에 대한 공식은 여기에서도 찾을 수 있습니다. 이중 지수 이동 평균 - MetaTrader 5 도움말

문안 인사

 
mladen:
비교를 위해 어떤 데마를 사용하고 있습니까?

DEMA .mq4가 첨부된 위의 게시물 2631을 참조하십시오...도움이 되나요?

 
mladen:
비교를 위해 어떤 데마를 사용하고 있습니까?

참고로 데마는 에마의 에마가 아니라 에마와 에마의 2배 차이입니다. 에마의

이에 대한 공식은 여기에서도 찾을 수 있습니다. 이중 지수 이동 평균 - MetaTrader 5 도움말

문안 인사

예, 공식을 암기한 적이 없지만 DEMA에 익숙합니다. 5-SMA(빨간색)와 5-DEMA(초록색)의 실질적인 차이점은 다음과 같습니다.

파일: