묻다! - 페이지 174

 

표시기 코드에 대한 질문-----(3줄)

1.왜 2개의 표시된 기능 이 deinit에 있습니까?

2. 왜 표시된 선에 720 값이 있습니까?

코드:

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

//| DailyBreakout.mq4 |

//| Copyright © 2008, Robert Hill. |

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

#property copyright "Copyright © 2008, Robert Hill"

#property link "NONE"

#property indicator_chart_window

//---- input parameters

extern bool Alerts = false;

extern int GMTshift = 0;

extern int LabelShift = 20;

extern int LineShift = 40;

extern string pd = "PipsAboveBelowSR for Alert";

extern int PipDistance = 1;

extern color StandardFontColor = White;

extern int StandardFontSize = 8;

extern color SupportColor = Red;

extern color ResistanceColor = Lime;

datetime LabelShiftTime, LineShiftTime;

double yesterday_high=0;

double yesterday_low=0;

double LastHigh,LastLow,x;

double R1=0;

double S1=0;

bool firstS1=true;

bool firstR1=true;

double myPoint;

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

myPoint = SetPoint(Symbol());

//----

return(0);

}

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

//| Custor indicator deinitialization function |

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

int deinit()

{

//---- TODO: add your code here

//----

ObjectDelete("R1 Label");

ObjectDelete("R1 Line");

ObjectDelete("S1 Label");

ObjectDelete("S1 Line");

return(0);

}

double SetPoint(string mySymbol)// <<<<<<<-----why here on the deinit?????----------------

{

double mPoint, myDigits;

myDigits = MarketInfo (mySymbol, MODE_DIGITS);

if (myDigits < 4)

mPoint = 0.01;

else

mPoint = 0.0001;

return(mPoint);

}

int DoAlerts()//<<<<<<<<<-------why here on the deint??????-----------------

{

double DifAboveR1,PipsLimit;

double DifBelowS1;

DifBelowS1 = S1 - Close[0];

DifAboveR1 = Close[0] - R1;

PipsLimit = PipDistance * myPoint;

if (DifBelowS1 > PipsLimit) firstS1 = true;

if (DifBelowS1 0)

{

if (firstS1)

{

Alert("Below S1 Line by ",DifBelowS1, " for ", Symbol(),"-",Period());

PlaySound("alert.wav");

firstS1=false;

}

}

if (DifAboveR1 > PipsLimit) firstR1 = true;

if (DifAboveR1 0)

{

if (firstR1)

{

Alert("Above R1 Line by ",DifAboveR1," for ", Symbol(),"-",Period());

Sleep(2000);

PlaySound("timeout.wav");

firstR1=false;

}

}

}

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

//| Custom indicator iteration function |

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

int start()

{

int counted_bars=IndicatorCounted();

//---- TODO: add your code here

double day_high=0;

double day_low=0;

double yesterday_open=0;

double today_open=0;

double cur_day=0;

double prev_day=0;

int cnt=720;//<<<<<----why 720 ????????--------------------------------------------------

//---- exit if period is greater than 4 hr charts

if(Period() > 240)

{

Print("Error - Chart period is greater than 4 hr.");

return(-1); // then exit

}

//---- Get new daily prices & calculate pivots

cur_day=0;

prev_day=0;

//---- Get new daily prices & calculate pivots

while (cnt!= 0)

{

cur_day = TimeDay(Time[cnt]- (GMTshift*3600));

if (prev_day != cur_day)

{

yesterday_high = day_high;

yesterday_low = day_low;

day_high = High[cnt];

day_low = Low[cnt];

prev_day = cur_day;

}

if (High[cnt]>day_high)

{

day_high = High[cnt];

}

if (Low[cnt]<day_low)

{

day_low = Low[cnt];

}

cnt--;

}

S1 = yesterday_low;

R1 = yesterday_high;

LabelShiftTime = Time[LabelShift];

LineShiftTime = Time[LineShift];

//---- Set line labels on chart window

DisplayLabel("R1 label", "R1", R1, StandardFontSize, StandardFontColor);

DisplayLabel("S1 label", "S1", S1, StandardFontSize, StandardFontColor);

//--- Draw Pivot lines on chart

DisplayLine("S1 line", S1, 0, STYLE_DASHDOTDOT, SupportColor);

DisplayLine("R1 line", R1, 0, STYLE_DASHDOTDOT, ResistanceColor);

//---- done

// Now check for Alert

if (Alerts) DoAlerts();

//----

return(0);

}

//---- Set line labels on chart window

void DisplayLabel(string LabelName, string LabelText, double LabelPos, int LabelFontSize, color LabelColor)

{

if(ObjectFind(LabelName) != 0)

{

ObjectCreate(LabelName, OBJ_TEXT, 0, LabelShiftTime, LabelPos);

ObjectSetText(LabelName, LabelText, LabelFontSize, "Arial", LabelColor);

}

else

{

ObjectMove(LabelName, 0, LabelShiftTime, LabelPos);

}

}

//--- Draw Pivot lines on chart

void DisplayLine(string LineName, double LinePos, int LineWidth, int LineStyle, color LineColor)

{

if(ObjectFind(LineName) != 0)

{

ObjectCreate(LineName, OBJ_HLINE, 0, LineShiftTime, LinePos);

ObjectSet(LineName, OBJPROP_STYLE, LineStyle);

ObjectSet(LineName, OBJPROP_COLOR, LineColor);

if (LineWidth > 0) ObjectSet(LineName, OBJPROP_WIDTH, LineWidth);

}

else

{

ObjectMove(LineName, 0, LineShiftTime, LinePos);

}

}

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

전리품 감사합니다.

 

ERAN123

1. deinit()에 있지 않고 deinit() 바로 뒤에 있습니다(deinit()와 start() 사이). mql에서는 프로시저와 함수 가 작성되는 순서를 따를 필요가 없습니다. 코드 끝에 init()를 넣을 수 있으며 여전히 작동합니다.

2. 각 틱에서 계산을 720바로 고정합니다. 왜요? 그건 작가님께 여쭤보시면 될 것 같아요.

ERAN123:
1.왜 2개의 표시된 기능이 deinit에 있습니까?

2. 왜 표시된 선에 720 값이 있습니까?

코드:

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

//| DailyBreakout.mq4 |

//| Copyright © 2008, Robert Hill. |

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

#property copyright "Copyright © 2008, Robert Hill"

#property link "NONE"

#property indicator_chart_window

//---- input parameters

extern bool Alerts = false;

extern int GMTshift = 0;

extern int LabelShift = 20;

extern int LineShift = 40;

extern string pd = "PipsAboveBelowSR for Alert";

extern int PipDistance = 1;

extern color StandardFontColor = White;

extern int StandardFontSize = 8;

extern color SupportColor = Red;

extern color ResistanceColor = Lime;

datetime LabelShiftTime, LineShiftTime;

double yesterday_high=0;

double yesterday_low=0;

double LastHigh,LastLow,x;

double R1=0;

double S1=0;

bool firstS1=true;

bool firstR1=true;

double myPoint;

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

myPoint = SetPoint(Symbol());

//----

return(0);

}

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

//| Custor indicator deinitialization function |

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

int deinit()

{

//---- TODO: add your code here

//----

ObjectDelete("R1 Label");

ObjectDelete("R1 Line");

ObjectDelete("S1 Label");

ObjectDelete("S1 Line");

return(0);

}

double SetPoint(string mySymbol)// <<<<<<<-----why here on the deinit?????----------------

{

double mPoint, myDigits;

myDigits = MarketInfo (mySymbol, MODE_DIGITS);

if (myDigits < 4)

mPoint = 0.01;

else

mPoint = 0.0001;

return(mPoint);

}

int DoAlerts()//<<<<<<<<<-------why here on the deint??????-----------------

{

double DifAboveR1,PipsLimit;

double DifBelowS1;

DifBelowS1 = S1 - Close[0];

DifAboveR1 = Close[0] - R1;

PipsLimit = PipDistance * myPoint;

if (DifBelowS1 > PipsLimit) firstS1 = true;

if (DifBelowS1 0)

{

if (firstS1)

{

Alert("Below S1 Line by ",DifBelowS1, " for ", Symbol(),"-",Period());

PlaySound("alert.wav");

firstS1=false;

}

}

if (DifAboveR1 > PipsLimit) firstR1 = true;

if (DifAboveR1 0)

{

if (firstR1)

{

Alert("Above R1 Line by ",DifAboveR1," for ", Symbol(),"-",Period());

Sleep(2000);

PlaySound("timeout.wav");

firstR1=false;

}

}

}

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

//| Custom indicator iteration function |

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

int start()

{

int counted_bars=IndicatorCounted();

//---- TODO: add your code here

double day_high=0;

double day_low=0;

double yesterday_open=0;

double today_open=0;

double cur_day=0;

double prev_day=0;

int cnt=720;//<<<<<----why 720 ????????--------------------------------------------------

//---- exit if period is greater than 4 hr charts

if(Period() > 240)

{

Print("Error - Chart period is greater than 4 hr.");

return(-1); // then exit

}

//---- Get new daily prices & calculate pivots

cur_day=0;

prev_day=0;

//---- Get new daily prices & calculate pivots

while (cnt!= 0)

{

cur_day = TimeDay(Time[cnt]- (GMTshift*3600));

if (prev_day != cur_day)

{

yesterday_high = day_high;

yesterday_low = day_low;

day_high = High[cnt];

day_low = Low[cnt];

prev_day = cur_day;

}

if (High[cnt]>day_high)

{

day_high = High[cnt];

}

if (Low[cnt]<day_low)

{

day_low = Low[cnt];

}

cnt--;

}

S1 = yesterday_low;

R1 = yesterday_high;

LabelShiftTime = Time[LabelShift];

LineShiftTime = Time[LineShift];

//---- Set line labels on chart window

DisplayLabel("R1 label", "R1", R1, StandardFontSize, StandardFontColor);

DisplayLabel("S1 label", "S1", S1, StandardFontSize, StandardFontColor);

//--- Draw Pivot lines on chart

DisplayLine("S1 line", S1, 0, STYLE_DASHDOTDOT, SupportColor);

DisplayLine("R1 line", R1, 0, STYLE_DASHDOTDOT, ResistanceColor);

//---- done

// Now check for Alert

if (Alerts) DoAlerts();

//----

return(0);

}

//---- Set line labels on chart window

void DisplayLabel(string LabelName, string LabelText, double LabelPos, int LabelFontSize, color LabelColor)

{

if(ObjectFind(LabelName) != 0)

{

ObjectCreate(LabelName, OBJ_TEXT, 0, LabelShiftTime, LabelPos);

ObjectSetText(LabelName, LabelText, LabelFontSize, "Arial", LabelColor);

}

else

{

ObjectMove(LabelName, 0, LabelShiftTime, LabelPos);

}

}

//--- Draw Pivot lines on chart

void DisplayLine(string LineName, double LinePos, int LineWidth, int LineStyle, color LineColor)

{

if(ObjectFind(LineName) != 0)

{

ObjectCreate(LineName, OBJ_HLINE, 0, LineShiftTime, LinePos);

ObjectSet(LineName, OBJPROP_STYLE, LineStyle);

ObjectSet(LineName, OBJPROP_COLOR, LineColor);

if (LineWidth > 0) ObjectSet(LineName, OBJPROP_WIDTH, LineWidth);

}

else

{

ObjectMove(LineName, 0, LineShiftTime, LinePos);

}

}

//+------------------------------------------------------------------+
전리품 감사합니다.
 

안녕 mladen

재생해주셔서 감사합니다.

1. 방금 이것을 눈치 챘습니다 (나는 이것을 눈치 채지 못했습니다)

2. 진짜 미스터리

 

보류 중인 주문 은 라이트 도움이 필요합니다 !!!!!!!!

안녕하세요 친구

보류 중인 주문에 대해 질문이 있습니다.

나는 2개의 보류 중인 주문을 사고 팔고 있습니다.

저는 그저 초보 mql 프로그래머이며 지금은 제 능력을 넘어섰습니다.

어떤 방향 친구????

감사합니다.

 

다음과 같이 사용할 수 있습니다.

void CleanPendingOrders()

{

bool trade.BuyEntered = false;

bool trade.SellEntered = false;

for (int i=OrdersTotal()-1; i>=0; i--)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

//

//

//

//

//

if ( OrderSymbol()==trade.symbol && OrderMagicNumber()==MagicNumber )

{

int type = OrderType();

if (type==OP_BUY && !trade.ByEntered) trade.BuyEntered = true;

if (type==OP_SELL && !trade.SellEntered) trade.SellEntered = true;

if (type >OP_SELL && (trade.ByEntered || trade.BuyEntered))

OrderDelete(OrderTicket());

}

}

}

매직 넘버와 심볼이 같은 일반 주문이 발견되면 보류 중인 주문 을 삭제합니다.

ERAN123:
안녕하세요 친구

보류 중인 주문에 대해 질문이 있습니다.

나는 2개의 보류 중인 주문을 사고 팔고 있습니다.

저는 그저 초보 mql 프로그래머이며 지금은 제 능력을 넘어섰습니다.

어떤 방향 친구????

감사합니다.
 

믈라덴

감사합니다, 확인 하겠습니다.

다시 한번 감사합니다

 

제대로 작동해야합니다

좋은 주말 되세요

ERAN123:
믈라덴

감사합니다, 확인하겠습니다.

다시 한번 감사합니다
 

안녕하세요 상인 여러분!

나는 mql4에서 프로그래밍하려고하는 전략으로 몇 달 동안 거래했습니다.

나는 이렇게 이익을 취 하면서 주문을 실행합니다

"OrderSend(Symbol(), OP_BUY, lot, Ask, 10, 30, Ask+takeprofit, "test", 12345, 0, Green);"

이제 주문이 마감되면 (t/p 또는 s/l) 다른 동일한 주문을 하고 싶습니다.

"OrderSend(Symbol(), OP_BUY, lot, Ask, 10, 30, Ask+takeprofit, "test", 12345, 0, Green);"

이전 매수가 마감될 때마다 매수 포지션을 도입하도록 하는 등.

나는 며칠 전에 mql4를 배우기 시작했고 이것에 갇혀 있습니다. 도와주세요!

 

현재 열려 있는 주문(구매 주문 또는 판매 주문 )의 수를 단순히 계산하고 0일 때 새 위치를 여는 것이 어떻습니까?

qwertet:
안녕하세요 상인 여러분!

나는 mql4에서 프로그래밍하려고하는 전략으로 몇 달 동안 거래했습니다.

나는 이렇게 이익을 취하면서 주문을 실행합니다

"OrderSend(Symbol(), OP_BUY, lot, Ask, 10, 30, Ask+takeprofit, "test", 12345, 0, Green);"

이제 주문이 마감되면 (t/p 또는 s/l) 다른 동일한 주문을 하고 싶습니다.

"OrderSend(Symbol(), OP_BUY, lot, Ask, 10, 30, Ask+takeprofit, "test", 12345, 0, Green);"

이전 매수가 마감될 때마다 매수 포지션을 도입하도록 하는 등.

나는 며칠 전에 mql4를 배우기 시작했고 이것에 갇혀 있습니다. 도와주세요!
 
qwertet:

이전 매수가 마감될 때마다 매수 포지션을 도입하도록 하는 등.

나는 며칠 전에 mql4를 배우기 시작했고 이것에 갇혀 있습니다. 도와주세요!

안녕하세요, MLaden이 맞습니다. 새 주문을 받을 준비가 되었는지 확인하려면 주문을 계산해야 합니다.

다음은 사용할 수 있는 기능입니다.

지정된 매직 번호 와 주문 유형으로 선택한 주문 중에서 이미 개설한 주문의 수를 계산합니다.

주문 유형으로 -1을 입력하면 선택한 매직 번호로 모든 주문을 계산합니다.

즐기다.

int orderCount(int type,int magic)

{

int oc = 0;

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

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderMagicNumber() == magic && (OrderType() == type || type == -1))

oc+=1;

}

return(oc);

}