코딩 도움말 - 페이지 395

 

EA는 카운터 포지션을 열지 않습니다

안녕하세요 MQL 코더 여러분,

내 EA의 버그에 대해 질문이 있습니다. 반대 추세 위치를 열지 않는 것 같습니다(첨부된 스크린샷 참조).

그것은 거래를 마감하고 있지만 새로운 주어진 추세 방향을 따르기 위해 새로운 거래를 열지 않습니다.

// Indicator HMA NMC

double trendc = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,1);

double trendp = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,2);

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

//| BUY |

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

if(trendc!=trendp)

{

if(trendc==1) // code for buy

OpenBuy();

return(0);

}

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

//| SELL |

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

if(trendc==-1) // code for sell

{

OpenSell();

return(0);

}

}

[/CODE]

[CODE]

void CheckForClose()

{

RefreshRates();

double trendc_c = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,1);

double trendp_c = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,2);

for(int i=0;i<OrdersTotal(); i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!= MAGIC) continue;

if(OrderSymbol() != s_symbol) continue;

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

//| Close BUY |

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

if(trendc_c!=trendp_c) // Check trend

{

if(OrderType()==OP_BUY)

{

if(trendc_c==-1) //is buy?

{

bool buyClose=OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,clCloseBuy);

if(buyClose==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert= StringConcatenate("Close Buy Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts == true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Bid: ",MarketInfo(s_symbol,MODE_BID)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

}

break;

}

}

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

//| Close SELL |

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

if(trendc_c!=trendp_c)

{

if(OrderType()==OP_SELL)

{

if(trendc_c==1) // SELL

{

bool sellClose= OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_ASK),Slippage*pipMultiplier,clCloseSell);

if(sellClose == false)

{

ErrorCode = GetLastError();

ErrDesc = ErrorDescription(ErrorCode);

ErrAlert=StringConcatenate("Close Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

}

break;

}

}

}

}

미리 감사합니다!

 
secretcode:
친애하는 믈라덴

이 게시물과 같이 첨부된 표시기에 '밴드 추가'가 가능한가요? https://www.mql5.com/en/forum/172894/page45

저 표시기는 엘리트 섹션에서 가져온 것이지만 밴드를 추가하는 방식이 마음에 듭니다.

도움을 주셔서 감사합니다.

비밀 코드

비밀 코드

다음은 밴드가 추가된 버전입니다. ema_variation__filter_amp_bands_amp_mtf.ex4

 
mladen:
secretcode 다음은 밴드가 추가된 버전입니다. ema_variation__filter_amp_bands_amp_mtf.ex4

믈라덴 감사합니다 나는 당신의 전문 지식에 정말 감사합니다

감사합니다

비밀 코드

 
tfi_markets:
안녕하세요 MQL 코더 여러분,

내 EA의 버그에 대해 질문이 있습니다. 반대 추세 위치를 열지 않는 것 같습니다(첨부된 스크린샷 참조).

그것은 거래를 마감하고 있지만 새로운 주어진 추세 방향을 따르기 위해 새로운 거래를 열지 않습니다.

// Indicator HMA NMC

double trendc = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,1);

double trendp = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,2);

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

//| BUY |

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

if(trendc!=trendp)

{

if(trendc==1) // code for buy

OpenBuy();

return(0);

}

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

//| SELL |

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

if(trendc==-1) // code for sell

{

OpenSell();

return(0);

}

}

[/CODE]

[CODE]

void CheckForClose()

{

RefreshRates();

double trendc_c = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,1);

double trendp_c = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,2);

for(int i=0;i<OrdersTotal(); i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!= MAGIC) continue;

if(OrderSymbol() != s_symbol) continue;

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

//| Close BUY |

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

if(trendc_c!=trendp_c) // Check trend

{

if(OrderType()==OP_BUY)

{

if(trendc_c==-1) //is buy?

{

bool buyClose=OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,clCloseBuy);

if(buyClose==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert= StringConcatenate("Close Buy Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts == true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Bid: ",MarketInfo(s_symbol,MODE_BID)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

}

break;

}

}

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

//| Close SELL |

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

if(trendc_c!=trendp_c)

{

if(OrderType()==OP_SELL)

{

if(trendc_c==1) // SELL

{

bool sellClose= OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_ASK),Slippage*pipMultiplier,clCloseSell);

if(sellClose == false)

{

ErrorCode = GetLastError();

ErrDesc = ErrorDescription(ErrorCode);

ErrAlert=StringConcatenate("Close Sell Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts==true) Alert(ErrAlert);

ErrLog=StringConcatenate("Ask: ",MarketInfo(s_symbol,MODE_ASK)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

}

break;

}

}

}

}

미리 감사합니다!

tfi_markets

두 break 문을 한 줄 위로 이동하십시오( "}" 안에 있도록).

[삭제]  

안녕하세요 믈라덴님

이 코드에서 내가 잘못한 부분을 알려주시겠습니까?

첨부된 지표 모든 피벗, 전일 시가선, 전일 종가선 및 당일 시가선도 표시하도록 재작업했습니다.

그러나 지표가 일치하지 않습니다. 그것은 항상 피벗을 올바르게 표시하지만 일일 오픈, 이전 날짜 오픈 및 닫기 라인에 대해 추가한 코드를 전혀 표시하지 않는 경우는 거의 없습니다.

이유를 모르겠습니다. 코드가 피벗 코드와 같아 모두 표시되어야 하고 때로는 표시되지만 항상 표시되지는 않습니다. 내가 뭔가를 잘못했지만 무엇인지 확실하지 않습니다.

많은 감사

PG

allpivots_daily.mq4

파일:
 
pgtips:
안녕하세요 믈라덴님

이 코드에서 내가 잘못한 부분을 알려주시겠습니까?

첨부된 지표 모든 피벗, 전일 시가선, 전일 종가선 및 당일 시가선도 표시하도록 재작업했습니다.

그러나 지표가 일치하지 않습니다. 그것은 항상 피벗을 올바르게 표시하지만 일일 오픈, 이전 날짜 오픈 및 닫기 라인에 대해 추가한 코드를 전혀 표시하지 않는 경우는 거의 없습니다.

이유를 모르겠습니다. 코드가 피벗 코드와 같아 모두 표시되어야 하고 때로는 표시되지만 항상 표시되지는 않습니다. 내가 뭔가를 잘못했지만 무엇인지 확실하지 않습니다.

많은 감사

PG

allpivots_daily.mq4

PG

정상적으로 작동합니다(생성된 개체 목록 참조). 겹치는 가격이 있는지 확인(일부 선이 보이지 않을 수 있음)

또한 ObjectDel() 함수에 새로 만든 줄을 추가하는 것을 잊지 마십시오.

파일:
objects.gif  49 kb
[삭제]  

Mladen에게 감사드립니다. 계속 확인 했는데 "" 안의 줄 이름에 대해 내가 예상한 것과는 다른 것 같습니다.

시간과 도움에 항상 감사드립니다.

PG

mladen:
PG

정상적으로 작동합니다(생성된 개체 목록 참조). 겹치는 가격이 있는지 확인(일부 선이 보이지 않을 수 있음)

 
pgtips:
Mladen에게 감사드립니다. 계속 확인했는데 "" 안의 줄 이름에 대해 내가 예상한 것과는 다른 것 같습니다.

시간과 도움에 항상 감사드립니다.

PG

개체의 이름은 항상 고유해야 합니다. 그러나 내가 본 한 당신이 그것을 처리했습니다.

[삭제]  

감사합니다, 믈라덴,

나는 문제가 있고 그것은 :

마지막 판매 후 첫 번째 신호 구매, 코드의 저항 또는 "srUp" 이상에서 막대가 닫힌 후에 있어야 합니다.

판매와 동일, 지원 또는 "srDown" 아래에서 닫혀 있어야 합니다.

코드에서 이것을 어떻게 고칠 수 있습니까?

그리고 두 번째는 이전에 질문한 1번이었습니다. 다른 색상으로 판매한 후 첫 번째 구매 신호를 표시하도록 코드를 수정하는 방법은 무엇입니까?

#속성엄격

#속성 표시기_차트_창

#속성 표시기_버퍼 4

#property indicator_color1 clrLime

#property indicator_color2 clrRed

#property indicator_color3 clr마젠타

#property indicator_color4 clrCyan

#define 구매 1

#define 판매 2

이중 구매[],

팔다[],

우선구매[],

첫 판매[];

int OnInit() {

SetIndexBuffer(0,FirstBuy);

SetIndexBuffer(1,FirstSell);

SetIndexBuffer(2,구매);

SetIndexBuffer(3,판매);

for(int i=0; i<4; i++) {

SetIndexStyle(i,DRAW_ARROW,STYLE_SOLID,2);}

SetIndexArrow(0,233);

SetIndexArrow(1,234);

SetIndexArrow(2,233);

SetIndexArrow(3,234);

반환(INIT_SUCCEEDED);}

무효 OnDeinit(const int 이유) {}

int OnCalculate(const int rate_total, const int prev_calculated, const datetime &time[],

const 이중 &open[], const 이중 &high[], const 이중 &low[],

const double &close[], const long &tick_volume[], const long &volume[],

const int &spread[]) {

정적 정수 lastSignal = 0;

for(int i=MathMin(rates_total-prev_calculated, Rates_total-1); i>=0; i--) {

FirstBuy=FirstSell=구매=판매=EMPTY_VALUE;

datetime when=시간;

int w=iBarShift(NULL,PERIOD_H4, 언제),

x=iBarShift(NULL,PERIOD_H1, 언제),

y=iBarShift(NULL,PERIOD_M15,때),

z=iBarShift(NULL,PERIOD_M5, 언제);

이중 srUpH4 = iCustom(NULL,PERIOD_H4,"지지 및 저항(배리)",0,w),

srDownH4 = iCustom(NULL,PERIOD_H4,"지지 및 저항(배리)",1,w),

MidH4 = (srUpH4+srDownH4)/2,

srUpH1 = iCustom(NULL,PERIOD_H1,"지지 및 저항(배리)",0,x),

srDownH1 = iCustom(NULL,PERIOD_H1,"지지 및 저항(배리)",1,x),

MidH1 = (srUpH1+srDownH1)/2,

srUp15M = iCustom(NULL,PERIOD_M15,"지지 및 저항(배리)",0,y),

srDown15M = iCustom(NULL,PERIOD_M15,"지지 및 저항(배리)",1,y),

Mid15M = (srUp15M+srDown15M)/2,

srUp5M = iCustom(NULL,PERIOD_M5,"지지 및 저항(배리)",0,z),

srDown5M = iCustom(NULL,PERIOD_M5,"지지 및 저항(배리)",1,z),

Mid5M = (srUp5M+srDown5M)/2,

srUp = iCustom(NULL,0,"지지 및 저항(배리)",0,i),

srDown = iCustom(NULL,0,"지지 및 저항(배리)",1,i);

if(ClosesrUp) { // 첫 번째 신호 구매

매수=낮음-_포인트; }

또 다른 {

구매=EMPTY_VALUE; }

if(Close>Mid5M && Close>srUp) { // 두 번째 매수 신호

매수=낮음-_포인트; }

또 다른 {

구매=EMPTY_VALUE; }

if(Close>MidH4 && Close>Mid15M && Close<srDown) { // 첫 번째 신호 매도

매도=높음+_포인트; }

또 다른 {

판매=EMPTY_VALUE; }

if(Close<Mid5M && Close<srDown) { // 두 번째 신호 매도

매도=높음+_포인트; }

또 다른 {

판매=EMPTY_VALUE; }}

반환(요금_총계);}

이것은 내가 경고에 대해 가지고 있는 것입니다. 그것을 사용할 것인가 아니면 Alert( t("text for pop up"))을 대신 사용할 것인가?

무효 SoundAlert(날짜 시간 i, 문자열 디렉토리) {

정적 날짜/시간 lastAlert=0;

if(lastAlert!=i) {

Alert(StringFormat("%s 신호가 %s의 %s에 있음",dir,Symbol(),TimeToStr(i)));

lastAlert=i;}}

감사합니다

파일:
signals.png  31 kb