코딩하는 방법? - 페이지 207 1...200201202203204205206207208209210211212213214...347 새 코멘트 username1 2009.09.26 21:06 #2061 오픈 포지션 줄이기 반 위치를 닫거나 줄이는 방법을 아는 사람이 있습니까? 우리는 어떤 기능 을 호출합니까? 예: 반대 방향으로 다른 거래를 열지 않고 오픈 포지션을 10랏에서 5랏으로 줄입니까? Ovidiu Marius 2009.09.26 21:27 #2062 '부분 마감'이라고 합니다. bool OrderClose( int ticket, double lots, double price, int slippage, color Color=CLR_NONE) 닫을 로트 수를 지정하기만 하면 됩니다. Roger09 2009.09.27 03:58 #2063 ljuba973: 안녕, 이 방법을 시도 for (int i=OrdersTotal()-1;i>=0 i--) { if (OrderSelect(i, SELECT_BY_POS)) { if (OrderSymbol()==Symbol()&&OrderType()==0) { Ans=OrderClose(OrderTicket(),alLots,Bid,2);// Order closing } if (OrderSymbol()==Symbol()&&OrderType()==1) { Ans=OrderClose(OrderTicket(),alLots,Ask,2);// Order closing } } Roger09 2009.09.27 04:01 #2064 username1: 반 위치를 닫거나 줄이는 방법을 아는 사람이 있습니까? 우리는 어떤 기능을 호출합니까? 예: 반대 방향으로 다른 거래를 열지 않고 오픈 포지션을 10랏에서 5랏으로 줄입니까? 다음과 같이 5 랏에 대한 주문을 마감하십시오. OrderClose(OrderTicket(),5.0,....... ljubas 2009.09.27 07:29 #2065 안녕하세요 로저 도움을 주셔서 감사합니다. 그동안 나는 그것을 작동하도록 고쳤습니다. OrderSend(Symbol(),OP_BUY,alLots,Ask,3,0,0,EA_Tester,Magic); if(OrderSelect(OrdersTotal()-1, SELECT_BY_POS)==true) { alTicker = OrderTicket(); Alert("Bought! ", alTicker); } else Print("OrderSelect failed error code is ",GetLastError()); [/CODE] Like that I found alTicker (after opening position) which I close later on. But your code I will use to optimize my Closing function. Sorry for maybe "beginner's code", I am into mq4 just 2 days ... will improve - I promise Thanks again Roger09: Try this way [CODE] for (int i=OrdersTotal()-1;i>=0 i--) { if (OrderSelect(i, SELECT_BY_POS)) { if (OrderSymbol()==Symbol()&&OrderType()==0) { Ans=OrderClose(OrderTicket(),alLots,Bid,2);// Order closing } if (OrderSymbol()==Symbol()&&OrderType()==1) { Ans=OrderClose(OrderTicket(),alLots,Ask,2);// Order closing } } How to code? Helping with a simple Slawa How to Close fxbg 2009.09.27 18:13 #2066 고정 손절매를 어떻게 배치할 수 있습니까? 안녕, 누군가 코드에 고정 StopLoss를 배치하는 방법을 알려주시겠습니까? //+------------------------------------------------------------------+ //| Daydream by Cothool | //| Recommended: USD/JPY 1H | //+------------------------------------------------------------------+ #define MAGIC_NUM 48213657 //+------------------------------------------------------------------+ extern double Lots = 0.1; extern int ChannelPeriod = 25; extern int Slippage = 3; extern int TakeProfit = 15; //+------------------------------------------------------------------+ double LastOrderTime = 0; double CurrentDirection = 0; double CurrentTakeProfitPrice = 0; //+------------------------------------------------------------------+ void OpenLong() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, "Daydream", MAGIC_NUM, 0, Blue); LastOrderTime = Time[0]; CurrentDirection = 1; } //+------------------------------------------------------------------+ void OpenShort() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, "Daydream", MAGIC_NUM, 0, Red); LastOrderTime = Time[0]; CurrentDirection = -1; } //+------------------------------------------------------------------+ void CloseLong() { int i; if (Time[0] == LastOrderTime) return; if (CurrentDirection != 1) return; for (i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), Bid, 3, White); LastOrderTime = Time[0]; CurrentDirection = 0; } } } //+------------------------------------------------------------------+ void CloseShort() { int i; if (Time[0] == LastOrderTime) return; if (CurrentDirection != -1) return; for (i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_SELL) { OrderClose(OrderTicket(), OrderLots(), Ask, 3, White); LastOrderTime = Time[0]; CurrentDirection = 0; } } } //+------------------------------------------------------------------+ void start() { double HighestValue; double LowestValue; HighestValue = High; LowestValue = Low[Lowest(NULL, 0, MODE_LOW, ChannelPeriod, 1)]; // BUY if (Close[0] < LowestValue) { CloseShort(); OpenLong(); CurrentTakeProfitPrice = Bid + TakeProfit * Point; } // SELL if (Close[0] > HighestValue) { CloseLong(); OpenShort(); CurrentTakeProfitPrice = Ask - TakeProfit * Point; } // Trailing Profit Taking for Long Position if (CurrentDirection == 1) { if (CurrentTakeProfitPrice > Bid + TakeProfit * Point) CurrentTakeProfitPrice = Bid + TakeProfit * Point; if (Bid >= CurrentTakeProfitPrice) CloseLong(); } // Trailing Profit Taking for Short Position if (CurrentDirection == -1) { if (CurrentTakeProfitPrice < Ask - TakeProfit * Point) CurrentTakeProfitPrice = Ask - TakeProfit * Point; if (Ask <= CurrentTakeProfitPrice) CloseShort(); } } //+------------------------------------------------------------------+ 문안 인사! How to code? Slawa How to Close Any EA's that OPEN/CLOSE Roger09 2009.09.27 20:44 #2067 fxbg: 안녕, 누군가 코드에 고정 StopLoss를 배치하는 방법을 알려주시겠습니까? 바꾸다 extern double Lots = 0.1; extern int ChannelPeriod = 25; extern int Slippage = 3; extern int TakeProfit = 15; //+------------------------------------------------------------------+ double LastOrderTime = 0; double CurrentDirection = 0; double CurrentTakeProfitPrice = 0; //+------------------------------------------------------------------+ void OpenLong() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, "Daydream", MAGIC_NUM, 0, Blue); LastOrderTime = Time[0]; CurrentDirection = 1; } //+------------------------------------------------------------------+ void OpenShort() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0, "Daydream", MAGIC_NUM, 0, Red); LastOrderTime = Time[0]; CurrentDirection = -1; } [/CODE] to [CODE]extern double Lots = 0.1; extern int ChannelPeriod = 25; extern int Slippage = 3; extern int TakeProfit = 15; extern int StopLoss = 15; //+------------------------------------------------------------------+ double LastOrderTime = 0; double CurrentDirection = 0; double CurrentTakeProfitPrice = 0; //+------------------------------------------------------------------+ void OpenLong() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask-StopLoss*Point, 0, "Daydream", MAGIC_NUM, 0, Blue); LastOrderTime = Time[0]; CurrentDirection = 1; } //+------------------------------------------------------------------+ void OpenShort() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Bid+StopLoss*Point, 0, "Daydream", MAGIC_NUM, 0, Red); LastOrderTime = Time[0]; CurrentDirection = -1; } How to code? [Archive!] Any rookie question, MQL4 Learning [삭제] 2009.09.27 21:20 #2068 표시기를 수정하는 데 도움이 필요합니다. 안녕하세요 프로그래머 여러분, 포럼에서 내가 거래하는 현재 위치를 보여주는 지표(통화 위치)를 찾았습니다. 이제 차트 하단에 있는 외부 창을 사용하도록 이 표시기를 만들고 글꼴과 색상도 변경할 수 있도록 도와줄 사람을 찾고 싶습니다. 나는 프로그램을 잘 못한다. 정말 감사합니다. 아삼 파일: currencypositions.mq4 5 kb fxbg 2009.09.28 07:13 #2069 테스터에서 작동하지 마십시오 테스터에서 이 EA를 시작합니다. 첫 번째 Stoploss 테스터 에 도달하면 중지하고 테스트를 계속하지 마십시오. 이 문제를 수정할 수 있습니까? 감사합니다. Roger. //+------------------------------------------------------------------+ //| Daydream by Cothool | //| Recommended: USD/JPY 1H | //+------------------------------------------------------------------+ #define MAGIC_NUM 48213657 //+------------------------------------------------------------------+ extern double Lots = 0.1; extern int ChannelPeriod = 25; extern int Slippage = 3; extern int TakeProfit = 0; extern int StopLoss = 15; //+------------------------------------------------------------------+ double LastOrderTime = 0; double CurrentDirection = 0; double CurrentTakeProfitPrice = 0; //+------------------------------------------------------------------+ void OpenLong() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage,Ask-StopLoss*Point, 0, "Daydream", MAGIC_NUM, 0, Blue); LastOrderTime = Time[0]; CurrentDirection = 1; } //+------------------------------------------------------------------+ void OpenShort() { if (Time[0] == LastOrderTime) return; if (CurrentDirection != 0) return; OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage,Bid+StopLoss*Point, 0, "Daydream", MAGIC_NUM, 0, Red); LastOrderTime = Time[0]; CurrentDirection = -1; } //+------------------------------------------------------------------+ void CloseLong() { int i; if (Time[0] == LastOrderTime) return; if (CurrentDirection != 1) return; for (i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_BUY) { OrderClose(OrderTicket(), OrderLots(), Bid, 3, White); LastOrderTime = Time[0]; CurrentDirection = 0; } } } //+------------------------------------------------------------------+ void CloseShort() { int i; if (Time[0] == LastOrderTime) return; if (CurrentDirection != -1) return; for (i = 0; i < OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_SELL) { OrderClose(OrderTicket(), OrderLots(), Ask, 3, White); LastOrderTime = Time[0]; CurrentDirection = 0; } } } //+------------------------------------------------------------------+ void start() { double HighestValue; double LowestValue; HighestValue = High; LowestValue = Low[Lowest(NULL, 0, MODE_LOW, ChannelPeriod, 1)]; // BUY if (Close[0] < LowestValue) { CloseShort(); OpenLong(); CurrentTakeProfitPrice = Bid + TakeProfit * Point; } // SELL if (Close[0] > HighestValue) { CloseLong(); OpenShort(); CurrentTakeProfitPrice = Ask - TakeProfit * Point; } // Trailing Profit Taking for Long Position if (CurrentDirection == 1) { if (CurrentTakeProfitPrice > Bid + TakeProfit * Point) CurrentTakeProfitPrice = Bid + TakeProfit * Point; if (Bid >= CurrentTakeProfitPrice) CloseLong(); } // Trailing Profit Taking for Short Position if (CurrentDirection == -1) { if (CurrentTakeProfitPrice < Ask - TakeProfit * Point) CurrentTakeProfitPrice = Ask - TakeProfit * Point; if (Ask <= CurrentTakeProfitPrice) CloseShort(); } } //+------------------------------------------------------------------+ How to code? Slawa How to Close Any EA's that OPEN/CLOSE nicesurf 2009.09.28 14:05 #2070 코드는 놀랍습니다, 감사합니다 1...200201202203204205206207208209210211212213214...347 새 코멘트 트레이딩 기회를 놓치고 있어요: 무료 트레이딩 앱 복사용 8,000 이상의 시그널 금융 시장 개척을 위한 경제 뉴스 등록 로그인 공백없는 라틴 문자 비밀번호가 이 이메일로 전송될 것입니다 오류 발생됨 Google으로 로그인 웹사이트 정책 및 이용약관에 동의합니다. 계정이 없으시면, 가입하십시오 MQL5.com 웹사이트에 로그인을 하기 위해 쿠키를 허용하십시오. 브라우저에서 필요한 설정을 활성화하시지 않으면, 로그인할 수 없습니다. 사용자명/비밀번호를 잊으셨습니까? Google으로 로그인
오픈 포지션 줄이기
반 위치를 닫거나 줄이는 방법을 아는 사람이 있습니까? 우리는 어떤 기능 을 호출합니까?
예: 반대 방향으로 다른 거래를 열지 않고 오픈 포지션을 10랏에서 5랏으로 줄입니까?
'부분 마감'이라고 합니다.
닫을 로트 수를 지정하기만 하면 됩니다.
안녕,
이 방법을 시도
for (int i=OrdersTotal()-1;i>=0 i--) {
if (OrderSelect(i, SELECT_BY_POS)) {
if (OrderSymbol()==Symbol()&&OrderType()==0) {
Ans=OrderClose(OrderTicket(),alLots,Bid,2);// Order closing
}
if (OrderSymbol()==Symbol()&&OrderType()==1) {
Ans=OrderClose(OrderTicket(),alLots,Ask,2);// Order closing
}
}
반 위치를 닫거나 줄이는 방법을 아는 사람이 있습니까? 우리는 어떤 기능을 호출합니까? 예: 반대 방향으로 다른 거래를 열지 않고 오픈 포지션을 10랏에서 5랏으로 줄입니까?
다음과 같이 5 랏에 대한 주문을 마감하십시오.
OrderClose(OrderTicket(),5.0,.......
안녕하세요 로저
도움을 주셔서 감사합니다. 그동안 나는 그것을 작동하도록 고쳤습니다.
OrderSend(Symbol(),OP_BUY,alLots,Ask,3,0,0,EA_Tester,Magic);
if(OrderSelect(OrdersTotal()-1, SELECT_BY_POS)==true) {
alTicker = OrderTicket();
Alert("Bought! ", alTicker);
} else Print("OrderSelect failed error code is ",GetLastError());
[/CODE]
Like that I found alTicker (after opening position) which I close later on.
But your code I will use to optimize my Closing function. Sorry for maybe "beginner's code", I am into mq4 just 2 days ... will improve - I promise
Thanks again
Try this way
[CODE]
for (int i=OrdersTotal()-1;i>=0 i--) {
if (OrderSelect(i, SELECT_BY_POS)) {
if (OrderSymbol()==Symbol()&&OrderType()==0) {
Ans=OrderClose(OrderTicket(),alLots,Bid,2);// Order closing
}
if (OrderSymbol()==Symbol()&&OrderType()==1) {
Ans=OrderClose(OrderTicket(),alLots,Ask,2);// Order closing
}
}
고정 손절매를 어떻게 배치할 수 있습니까?
안녕,
누군가 코드에 고정 StopLoss를 배치하는 방법을 알려주시겠습니까?
//| Daydream by Cothool |
//| Recommended: USD/JPY 1H |
//+------------------------------------------------------------------+
#define MAGIC_NUM 48213657
//+------------------------------------------------------------------+
extern double Lots = 0.1;
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
}
//+------------------------------------------------------------------+
void CloseLong()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_BUY)
{
OrderClose(OrderTicket(), OrderLots(), Bid, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void CloseShort()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != -1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_SELL)
{
OrderClose(OrderTicket(), OrderLots(), Ask, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void start()
{
double HighestValue;
double LowestValue;
HighestValue = High;
LowestValue = Low[Lowest(NULL, 0, MODE_LOW, ChannelPeriod, 1)];
// BUY
if (Close[0] < LowestValue)
{
CloseShort();
OpenLong();
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
}
// SELL
if (Close[0] > HighestValue)
{
CloseLong();
OpenShort();
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
}
// Trailing Profit Taking for Long Position
if (CurrentDirection == 1)
{
if (CurrentTakeProfitPrice > Bid + TakeProfit * Point)
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
if (Bid >= CurrentTakeProfitPrice)
CloseLong();
}
// Trailing Profit Taking for Short Position
if (CurrentDirection == -1)
{
if (CurrentTakeProfitPrice < Ask - TakeProfit * Point)
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
if (Ask <= CurrentTakeProfitPrice)
CloseShort();
}
}
//+------------------------------------------------------------------+
문안 인사!
안녕,
누군가 코드에 고정 StopLoss를 배치하는 방법을 알려주시겠습니까?
바꾸다
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
} [/CODE]
to
[CODE]extern double Lots = 0.1;
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 15;
extern int StopLoss = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask-StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Bid+StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
}표시기를 수정하는 데 도움이 필요합니다.
안녕하세요 프로그래머 여러분,
포럼에서 내가 거래하는 현재 위치를 보여주는 지표(통화 위치)를 찾았습니다. 이제 차트 하단에 있는 외부 창을 사용하도록 이 표시기를 만들고 글꼴과 색상도 변경할 수 있도록 도와줄 사람을 찾고 싶습니다. 나는 프로그램을 잘 못한다. 정말 감사합니다.
아삼
테스터에서 작동하지 마십시오
테스터에서 이 EA를 시작합니다. 첫 번째 Stoploss 테스터 에 도달하면 중지하고 테스트를 계속하지 마십시오. 이 문제를 수정할 수 있습니까? 감사합니다. Roger.
//| Daydream by Cothool |
//| Recommended: USD/JPY 1H |
//+------------------------------------------------------------------+
#define MAGIC_NUM 48213657
//+------------------------------------------------------------------+
extern double Lots = 0.1;
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 0;
extern int StopLoss = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage,Ask-StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage,Bid+StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
}
//+------------------------------------------------------------------+
void CloseLong()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_BUY)
{
OrderClose(OrderTicket(), OrderLots(), Bid, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void CloseShort()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != -1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_SELL)
{
OrderClose(OrderTicket(), OrderLots(), Ask, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void start()
{
double HighestValue;
double LowestValue;
HighestValue = High;
LowestValue = Low[Lowest(NULL, 0, MODE_LOW, ChannelPeriod, 1)];
// BUY
if (Close[0] < LowestValue)
{
CloseShort();
OpenLong();
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
}
// SELL
if (Close[0] > HighestValue)
{
CloseLong();
OpenShort();
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
}
// Trailing Profit Taking for Long Position
if (CurrentDirection == 1)
{
if (CurrentTakeProfitPrice > Bid + TakeProfit * Point)
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
if (Bid >= CurrentTakeProfitPrice)
CloseLong();
}
// Trailing Profit Taking for Short Position
if (CurrentDirection == -1)
{
if (CurrentTakeProfitPrice < Ask - TakeProfit * Point)
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
if (Ask <= CurrentTakeProfitPrice)
CloseShort();
}
}
//+------------------------------------------------------------------+
코드는 놀랍습니다, 감사합니다