묻다! - 페이지 17 1...101112131415161718192021222324...182 새 코멘트 Eaglehawk 2006.07.08 18:19 #161 이봐, 코더들! Aaragorn과 나는 최근에 이 작업을 하고 있습니다. extern int MagicNumber = 0; extern bool SignalMail = False; extern bool EachTickMode = False; extern double Lots = 0.1; extern int Slippage = 3; extern bool StopLossMode = False; extern int StopLoss = 5; extern bool TakeProfitMode = True; extern int TakeProfit = 50; extern bool TrailingStopMode = False; extern int TrailingStop = 5; extern int MaxOpenTrade = 1; extern int Shift = 2; extern double Slope = 2; extern int EnterEMA = 38; extern int ExitEMA = 1500; #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 int BarCount; int Current; bool TickCheck = False; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ double Buy1_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double Buy1_2 = iClose(NULL, 0, Current + 0); double Buy2_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift); double Buy2_2 = iClose(NULL, 0, Current + Shift); double Sell1_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double Sell1_2 = iClose(NULL, 0, Current + 0); double Sell2_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift); double Sell2_2 = iClose(NULL, 0, Current + Shift); double CloseBuy1_1 = iClose(NULL, 0, Current + 0); double CloseBuy1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double CloseSell1_1 = iClose(NULL, 0, Current + 0); double CloseSell1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ bool IsTrade = False; for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { IsTrade = True; if(OrderType() == OP_BUY) { //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy) | //+------------------------------------------------------------------+ if (Sell1_1 < CloseBuy1_2) Order = SIGNAL_CLOSEBUY; //+------------------------------------------------------------------+ //| Signal End(Exit Buy) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } if(TrailingStopMode && TrailingStop > 0) { if(Bid - OrderOpenPrice() > Point * TrailingStop) { if(OrderStopLoss() < Bid - Point * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); if (!EachTickMode) BarCount = Bars; continue; } } } } else { //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell) | //+------------------------------------------------------------------+ if (Sell1_1 > CloseBuy1_2) Order = SIGNAL_CLOSESELL; //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } if(TrailingStopMode && TrailingStop > 0) { if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); if (!EachTickMode) BarCount = Bars; continue; } } } } } } //+------------------------------------------------------------------+ //| Signal Begin(Entry logics) | //+------------------------------------------------------------------+ if (Buy1_1 < Buy1_2 && Buy2_1 Buy2_1*/) Order = SIGNAL_BUY; if (Sell1_1 > Sell1_2 && Sell2_1 > Sell2_2/* && Sell1_1 + Slope*Point < Sell2_1*/) Order = SIGNAL_SELL; //+------------------------------------------------------------------+ //| Signal End | //+------------------------------------------------------------------+ if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { IsTrade = False;//---allows multiple orders to open if(!IsTrade) { if (AccountFreeMargin() < (1000 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (StopLossMode) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0; if (TakeProfitMode) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0; if(OrdersTotal() < MaxOpenTrade) Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("BUY order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy"); } else { Print("Error opening BUY order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { IsTrade = False;//---allows multiple orders to open if(!IsTrade) { if (AccountFreeMargin() < (1000 * Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } if (StopLossMode) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0; if (TakeProfitMode) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0; if(OrdersTotal() < MaxOpenTrade) Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("SELL order opened : ", OrderOpenPrice()); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell"); } else { Print("Error opening SELL order : ", GetLastError()); } } if (EachTickMode) TickCheck = True; if (!EachTickMode) BarCount = Bars; return(0); } } if (!EachTickMode) BarCount = Bars; return(0); } //+------------------------------------------------------------------+ "Shift"는 되돌아본 기간의 수이고 "Slope"는 "EnterEMA"가 "Shift"에서 위로 이동한 핍 수입니다. 우리는 여전히 전략을 완성하고 있는데, 당신이 뭔가를 도와줄 수 있는지 궁금합니다. Ask! Indicators with alerts/signal Anyone want to write [삭제] 2006.07.10 02:42 #162 이것은 내가 질문이 있는 코드로 범위를 좁히기 전에 약간의 컨텍스트를 제공하기 위한 것입니다... #property copyright "Aaragorn" #property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/" extern int MagicNumber = 0; extern bool SignalMail = False; extern bool EachTickMode = False; extern double Lots = 0.35; extern int Slippage = 3; extern bool StopLossMode = False; extern int StopLoss = 5; extern bool TakeProfitMode = True; extern int TakeProfit = 42; extern bool TrailingStopMode = False; extern int TrailingStop = 10; extern int MaxOpenTrade = 1; extern int Shift = 3; //extern double Slope = 2; extern int EntLongEMA = 46; extern int EntShortEMA = 1; extern int ExitEMA = 52; extern int TrendEMA = 150; //+-----------close based on not triggering trailing stop in allotted time----------------+ extern int MonitorInMinutes = 60; // minutes after open to check state of trade extern int ThresholdMove = 1; // if after that time we don't have +'x' pips we will exit extern int MinsMultiplier = 90; // multiplies the MonitorInMinutes to make minutes (if 'x'=60) into hours #define SIGNAL_NONE 0 #define SIGNAL_BUY 1 #define SIGNAL_SELL 2 #define SIGNAL_CLOSEBUY 3 #define SIGNAL_CLOSESELL 4 int BarCount; int Current; bool TickCheck = False; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { BarCount = Bars; if (EachTickMode) Current = 0; else Current = 1; return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { int Order = SIGNAL_NONE; int Total, Ticket; double StopLossLevel, TakeProfitLevel; if (EachTickMode && Bars != BarCount) TickCheck = False; Total = OrdersTotal(); Order = SIGNAL_NONE; //+------------------------------------------------------------------+ //| Variable Begin | //+------------------------------------------------------------------+ double Buy1_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double Buy1_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double Buy2_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift); double Buy2_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift); double Sell1_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double Sell1_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double Sell2_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift); double Sell2_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift); double CloseBuy1_1 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double CloseBuy1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double CloseSell1_1 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double CloseSell1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double C_trendsetter = iMA(NULL, 0, TrendEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0); double S_trendsetter = iMA(NULL, 0, TrendEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift); //+------------------------------------------------------------------+ //| Variable End | //+------------------------------------------------------------------+ //Check position bool IsTrade = False; for (int i = 0; i < Total; i ++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) { IsTrade = True; if(OrderType() == OP_BUY) { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy)Closing logic for long positions | //+------------------------------------------------------------------+ // if (Buy1_1 <= C_trendsetter) Order = SIGNAL_CLOSEBUY; if (Buy1_1 <= C_trendsetter) StopLossMode = True; if (Buy1_1 <= CloseBuy1_2) CloseOrder(); if (Buy1_1 <= CloseBuy1_2) TrailingStopMode = True; //+------------------------------------------------------------------+ //| Signal End(Exit Buy) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(TrailingStopMode && TrailingStop > 0) { if(Bid - OrderOpenPrice() > Point * TrailingStop) { if(OrderStopLoss() < Bid - Point * TrailingStop) { OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen); if (!EachTickMode) BarCount = Bars; TrailingStopMode = False; //resets mode after each order StopLossMode = False; //resets mode after each order continue; } } } } else { //Close //+------------------------------------------------------------------+ //| Signal Begin(Exit Sell)Closing logic for short positions | //+------------------------------------------------------------------+ // if (Buy1_1 >= C_trendsetter) Order = SIGNAL_CLOSEBUY; if (Buy1_1 >= C_trendsetter) StopLossMode = True; if (Sell1_1 >= CloseSell1_2) CloseOrder(); if (Sell1_1 >= CloseSell1_2) TrailingStopMode = True; //+------------------------------------------------------------------+ //| Signal End(Exit Sell) | //+------------------------------------------------------------------+ if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange); if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell"); if (!EachTickMode) BarCount = Bars; IsTrade = False; continue; } //Trailing stop if(TrailingStopMode && TrailingStop > 0) { if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) { if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange); if (!EachTickMode) BarCount = Bars; TrailingStopMode = False; //resets mode after each order StopLossMode = False; //resets mode after each order continue; } } } } } }[/PHP] I am working on the exit logics... This is the buy.closing... //+------------------------------------------------------------------+ //| Signal Begin(Exit Buy)Closing logic for long positions | //+------------------------------------------------------------------+ if (Buy1_1 <= C_trendsetter) Order = SIGNAL_CLOSEBUY; // if (Buy1_1 <= C_trendsetter) StopLossMode = True; if (Buy1_1 <= CloseBuy1_2) CloseOrder(); if (Buy1_1 <= CloseBuy1_2) TrailingStopMode = True; When I turn on the close buy condition it does in fact close the trade. see attached. [PHP]//+------------------------------------------------------------------+ //| Signal Begin(Exit Buy)Closing logic for long positions | //+------------------------------------------------------------------+ // if (Buy1_1 <= C_trendsetter) Order = SIGNAL_CLOSEBUY; if (Buy1_1 <= C_trendsetter) StopLossMode = True; if (Buy1_1 <= CloseBuy1_2) CloseOrder(); if (Buy1_1 <= CloseBuy1_2) TrailingStopMode = True; 손절매 가 트리거된 경우 잠시 후 닫혀야 했지만 그렇지 않았지만 후행 중지가 분명히 트리거되었습니다(첨부 참조). 파일: executedclose.gif 54 kb partialexecutedlogic.gif 62 kb Ask! Anyone want to write How To Make Trade [삭제] 2006.07.10 16:43 #163 그래도 시키는 대로 하지 않고... 그것은 첫 번째 거래에서 마감했지만 두 번째 거래에서는 마감하지 않았습니다. 첨부된 참조. 파일: partialexecutedlogic_1.gif 63 kb my_second_strategytester.mq4 14 kb [삭제] 2006.07.10 21:52 #164 if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSEBUY; 이것은 작동하는 것 같습니다. 버그를 찾았습니다... 이것은해야합니다 if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSESELL; 반바지를 위해... 너무 많이 복사해서 붙여넣다 보니 주문 신호를 놓쳤습니다..오이. [삭제] 2006.07.10 21:53 #165 if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSEBUY; 해야한다 if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSESELL; [삭제] 2006.07.10 21:57 #166 색상 질문 이동 평균선이 전략 테스터 차트에서 열릴 때 지정한 색상으로 만들려면 어떻게 해야 합니까? 전략 테스터 차트를 열 때 화살표를 더 크게 표시하려면 어떻게 합니까? kidhudi 2006.07.10 23:00 #167 미래를 향해 직선으로 투영되는 이동 평균 봉투 를 갖는 것이 가능하다고 생각하십니까? Eaglehawk 2006.07.10 23:15 #168 kidhudi: 미래를 향해 직선으로 투영되는 이동 평균 봉투를 갖는 것이 가능하다고 생각하십니까? 이동 평균은 과거 "x" 기간 평균에 의해 결정되며, 예를 들어 이동 평균을 종가에 적용하면 한 기간은 1.3417에서 마감되고 다음 기간은 5핍, 다음 5핍은 더 높은 등의 경우 이동 평균은 해당 값을 "평균"하여 현재 값. 가격은 항상 변하기 때문에 100핍 정도를 되돌아보는 이동 평균만이 대부분의 경우 직선에 가깝게 보입니다. 귀하의 질문에 대한 답변으로 가능한 경우 알려주세요! (ㅋㅋㅋ) witchazel 2006.07.12 06:52 #169 안녕하세요, 저는 가격 교차를 하려고 하는 EA에서 일하고 있습니다. 교차했는지 어떻게 알 수 있습니까? 내가 만약 Ask>iCustom() 하면 그것은 위에 있을 때마다 주문을 넣습니다. 내가 if ask=iCustom()을 수행하면 분당 수행하기 때문에 구매를 놓치게 됩니다. 거래 책에서 나는 Ask[-1] =iCustom인 경우 할 것이지만 Ask 및 Bid에 기록이 없기 때문에 여기에서 해결할 수 없습니다. kevmcfoster 2006.07.12 11:41 #170 추가 차트 안녕, 이것은 아마도 이 스레드와 관련이 없을 것입니다. 하지만 Silver, audnzd, nzdusd, platanium 등과 같은 metatrader 4에 대한 추가 차트를 추가하는 방법을 알고 싶었습니다. 누군가 메타트레이더 폴더에 붙여넣기를 이 차트를 얻었지만 잃어버린 것 같습니다. 누군가 여기에서 저를 도와주세요. thnx 케브 1...101112131415161718192021222324...182 새 코멘트 트레이딩 기회를 놓치고 있어요: 무료 트레이딩 앱 복사용 8,000 이상의 시그널 금융 시장 개척을 위한 경제 뉴스 등록 로그인 공백없는 라틴 문자 비밀번호가 이 이메일로 전송될 것입니다 오류 발생됨 Google으로 로그인 웹사이트 정책 및 이용약관에 동의합니다. 계정이 없으시면, 가입하십시오 MQL5.com 웹사이트에 로그인을 하기 위해 쿠키를 허용하십시오. 브라우저에서 필요한 설정을 활성화하시지 않으면, 로그인할 수 없습니다. 사용자명/비밀번호를 잊으셨습니까? Google으로 로그인
이봐, 코더들!
Aaragorn과 나는 최근에 이 작업을 하고 있습니다.
extern bool SignalMail = False;
extern bool EachTickMode = False;
extern double Lots = 0.1;
extern int Slippage = 3;
extern bool StopLossMode = False;
extern int StopLoss = 5;
extern bool TakeProfitMode = True;
extern int TakeProfit = 50;
extern bool TrailingStopMode = False;
extern int TrailingStop = 5;
extern int MaxOpenTrade = 1;
extern int Shift = 2;
extern double Slope = 2;
extern int EnterEMA = 38;
extern int ExitEMA = 1500;
#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
if (EachTickMode) Current = 0; else Current = 1;
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+
double Buy1_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Buy1_2 = iClose(NULL, 0, Current + 0);
double Buy2_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift);
double Buy2_2 = iClose(NULL, 0, Current + Shift);
double Sell1_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Sell1_2 = iClose(NULL, 0, Current + 0);
double Sell2_1 = iMA(NULL, 0, EnterEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift);
double Sell2_2 = iClose(NULL, 0, Current + Shift);
double CloseBuy1_1 = iClose(NULL, 0, Current + 0);
double CloseBuy1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseSell1_1 = iClose(NULL, 0, Current + 0);
double CloseSell1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+
bool IsTrade = False;
for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy) |
//+------------------------------------------------------------------+
if (Sell1_1 < CloseBuy1_2) Order = SIGNAL_CLOSEBUY;
//+------------------------------------------------------------------+
//| Signal End(Exit Buy) |
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
if(TrailingStopMode && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {
//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell) |
//+------------------------------------------------------------------+
if (Sell1_1 > CloseBuy1_2) Order = SIGNAL_CLOSESELL;
//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
if(TrailingStopMode && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Signal Begin(Entry logics) |
//+------------------------------------------------------------------+
if (Buy1_1 < Buy1_2 && Buy2_1 Buy2_1*/) Order = SIGNAL_BUY;
if (Sell1_1 > Sell1_2 && Sell2_1 > Sell2_2/* && Sell1_1 + Slope*Point < Sell2_1*/) Order = SIGNAL_SELL;
//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
IsTrade = False;//---allows multiple orders to open
if(!IsTrade) {
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (StopLossMode) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (TakeProfitMode) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;
if(OrdersTotal() < MaxOpenTrade)
Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
IsTrade = False;//---allows multiple orders to open
if(!IsTrade) {
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (StopLossMode) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
if (TakeProfitMode) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;
if(OrdersTotal() < MaxOpenTrade)
Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}
if (!EachTickMode) BarCount = Bars;
return(0);
}
//+------------------------------------------------------------------+"Shift"는 되돌아본 기간의 수이고 "Slope"는 "EnterEMA"가 "Shift"에서 위로 이동한 핍 수입니다. 우리는 여전히 전략을 완성하고 있는데, 당신이 뭔가를 도와줄 수 있는지 궁금합니다.
이것은 내가 질문이 있는 코드로 범위를 좁히기 전에 약간의 컨텍스트를 제공하기 위한 것입니다...
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"
extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = False;
extern double Lots = 0.35;
extern int Slippage = 3;
extern bool StopLossMode = False;
extern int StopLoss = 5;
extern bool TakeProfitMode = True;
extern int TakeProfit = 42;
extern bool TrailingStopMode = False;
extern int TrailingStop = 10;
extern int MaxOpenTrade = 1;
extern int Shift = 3;
//extern double Slope = 2;
extern int EntLongEMA = 46;
extern int EntShortEMA = 1;
extern int ExitEMA = 52;
extern int TrendEMA = 150;
//+-----------close based on not triggering trailing stop in allotted time----------------+
extern int MonitorInMinutes = 60; // minutes after open to check state of trade
extern int ThresholdMove = 1; // if after that time we don't have +'x' pips we will exit
extern int MinsMultiplier = 90; // multiplies the MonitorInMinutes to make minutes (if 'x'=60) into hours
#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;
if (EachTickMode) Current = 0; else Current = 1;
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+
double Buy1_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Buy1_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Buy2_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift);
double Buy2_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift);
double Sell1_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Sell1_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Sell2_1 = iMA(NULL, 0, EntLongEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift);
double Sell2_2 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift);
double CloseBuy1_1 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseBuy1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseSell1_1 = iMA(NULL, 0, EntShortEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseSell1_2 = iMA(NULL, 0, ExitEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double C_trendsetter = iMA(NULL, 0, TrendEMA, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double S_trendsetter = iMA(NULL, 0, TrendEMA, 0, MODE_EMA, PRICE_CLOSE, Current + Shift);
//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+
//Check position
bool IsTrade = False;
for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
IsTrade = True;
if(OrderType() == OP_BUY) {
//Close
//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy)Closing logic for long positions |
//+------------------------------------------------------------------+
// if (Buy1_1 <= C_trendsetter) Order = SIGNAL_CLOSEBUY;
if (Buy1_1 <= C_trendsetter) StopLossMode = True;
if (Buy1_1 <= CloseBuy1_2) CloseOrder();
if (Buy1_1 <= CloseBuy1_2) TrailingStopMode = True;
//+------------------------------------------------------------------+
//| Signal End(Exit Buy) |
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(TrailingStopMode && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
TrailingStopMode = False; //resets mode after each order
StopLossMode = False; //resets mode after each order
continue;
}
}
}
} else {
//Close
//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell)Closing logic for short positions |
//+------------------------------------------------------------------+
// if (Buy1_1 >= C_trendsetter) Order = SIGNAL_CLOSEBUY;
if (Buy1_1 >= C_trendsetter) StopLossMode = True;
if (Sell1_1 >= CloseSell1_2) CloseOrder();
if (Sell1_1 >= CloseSell1_2) TrailingStopMode = True;
//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(TrailingStopMode && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) BarCount = Bars;
TrailingStopMode = False; //resets mode after each order
StopLossMode = False; //resets mode after each order
continue;
}
}
}
}
}
}[/PHP]
I am working on the exit logics... This is the buy.closing...
//| Signal Begin(Exit Buy)Closing logic for long positions |
//+------------------------------------------------------------------+
if (Buy1_1 <= C_trendsetter) Order = SIGNAL_CLOSEBUY;
// if (Buy1_1 <= C_trendsetter) StopLossMode = True;
if (Buy1_1 <= CloseBuy1_2) CloseOrder();
if (Buy1_1 <= CloseBuy1_2) TrailingStopMode = True;When I turn on the close buy condition it does in fact close the trade.
see attached.
[PHP]//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy)Closing logic for long positions |
//+------------------------------------------------------------------+
// if (Buy1_1 <= C_trendsetter) Order = SIGNAL_CLOSEBUY;
if (Buy1_1 <= C_trendsetter) StopLossMode = True;
if (Buy1_1 <= CloseBuy1_2) CloseOrder();
if (Buy1_1 <= CloseBuy1_2) TrailingStopMode = True;손절매 가 트리거된 경우 잠시 후 닫혀야 했지만 그렇지 않았지만 후행 중지가 분명히 트리거되었습니다(첨부 참조).
그래도 시키는 대로 하지 않고...
그것은 첫 번째 거래에서 마감했지만 두 번째 거래에서는 마감하지 않았습니다. 첨부된 참조.
if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSEBUY;
이것은 작동하는 것 같습니다.
버그를 찾았습니다...
이것은해야합니다
if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSESELL;
반바지를 위해...
너무 많이 복사해서 붙여넣다 보니 주문 신호를 놓쳤습니다..오이.
if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSEBUY;
해야한다
if (Buy1_1 + StopLoss*Point <= C_trendsetter) 주문 = SIGNAL_CLOSESELL;
색상 질문
이동 평균선이 전략 테스터 차트에서 열릴 때 지정한 색상으로 만들려면 어떻게 해야 합니까?
전략 테스터 차트를 열 때 화살표를 더 크게 표시하려면 어떻게 합니까?
미래를 향해 직선으로 투영되는 이동 평균 봉투 를 갖는 것이 가능하다고 생각하십니까?
미래를 향해 직선으로 투영되는 이동 평균 봉투를 갖는 것이 가능하다고 생각하십니까?
이동 평균은 과거 "x" 기간 평균에 의해 결정되며,
예를 들어 이동 평균을 종가에 적용하면 한 기간은 1.3417에서 마감되고 다음 기간은 5핍, 다음 5핍은 더 높은 등의 경우 이동 평균은 해당 값을 "평균"하여 현재 값.
가격은 항상 변하기 때문에 100핍 정도를 되돌아보는 이동 평균만이 대부분의 경우 직선에 가깝게 보입니다.
귀하의 질문에 대한 답변으로 가능한 경우 알려주세요! (ㅋㅋㅋ)
안녕하세요, 저는 가격 교차를 하려고 하는 EA에서 일하고 있습니다.
교차했는지 어떻게 알 수 있습니까?
내가 만약 Ask>iCustom() 하면 그것은 위에 있을 때마다 주문을 넣습니다.
내가 if ask=iCustom()을 수행하면 분당 수행하기 때문에 구매를 놓치게 됩니다.
거래 책에서 나는 Ask[-1] =iCustom인 경우 할 것이지만 Ask 및 Bid에 기록이 없기 때문에 여기에서 해결할 수 없습니다.
추가 차트
안녕,
이것은 아마도 이 스레드와 관련이 없을 것입니다. 하지만 Silver, audnzd, nzdusd, platanium 등과 같은 metatrader 4에 대한 추가 차트를 추가하는 방법을 알고 싶었습니다. 누군가 메타트레이더 폴더에 붙여넣기를 이 차트를 얻었지만 잃어버린 것 같습니다. 누군가 여기에서 저를 도와주세요.
thnx
케브