Marco Garthi:
extern double BreakEvenProfit = 25;Hi guys!
Can I have an example of stop at breakeven?
for(int Counter = 0; Counter <= OrdersTotal()-1; Counter++)
{
OrderSelect(Counter,SELECT_BY_POS);
RefreshRates();
double PipsProfit = Bid – OrderOpenPrice();
double MinProfit = BreakEvenProfit * PipPoint(OrderSymbol()));
if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()
&& OrderType() == OP_BUY && PipsProfit >= MinProfit
&& OrderOpenPrice() != OrderStopLoss())
{
bool BreakEven = OrderModify(OrderTicket(),OrderOpenPrice(),
OrderOpenPrice(),OrderTakeProfit(),0);
if(BreakEven == false)
{
ErrorCode = GetLastError();
string ErrDesc = ErrorDescription(ErrorCode);
string ErrAlert = StringConcatenate("Buy Break Even - Error ",
ErrorCode,": ",ErrDesc);
Alert(ErrAlert);
string ErrLog = StringConcatenate("Bid: ",Bid,", Ask: ",Ask,
", Ticket: ",CloseTicket,", Stop: ",OrderStopLoss(),", Break: ",
MinProfit);
Print(ErrLog);
}
}
}
Ridwan Icus:
Please edit your post and
use the code button (Alt+S) when pasting code
Ridwan Icus:
extern double BreakEvenProfit = 25;
extern double BreakEvenProfit = 25;
for(int Counter = 0; Counter <= OrdersTotal()-1; Counter++)
{
OrderSelect(Counter,SELECT_BY_POS);
RefreshRates();
double PipsProfit = Bid – OrderOpenPrice();
double MinProfit = BreakEvenProfit * PipPoint(OrderSymbol()));
if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()
&& OrderType() == OP_BUY && PipsProfit >= MinProfit
&& OrderOpenPrice() != OrderStopLoss())
{
bool BreakEven = OrderModify(OrderTicket(),OrderOpenPrice(),
OrderOpenPrice(),OrderTakeProfit(),0);
if(BreakEven == false)
{
ErrorCode = GetLastError();
string ErrDesc = ErrorDescription(ErrorCode);
string ErrAlert = StringConcatenate("Buy Break Even - Error ",
ErrorCode,": ",ErrDesc);
Alert(ErrAlert);
string ErrLog = StringConcatenate("Bid: ",Bid,", Ask: ",Ask,
", Ticket: ",CloseTicket,", Stop: ",OrderStopLoss(),", Break: ",
MinProfit);
Print(ErrLog);
}
}
}
Please do not post code which do not work
ErrorCode : undeclared identifierCloseTicket : undeclared identifier
PipPoint(OrderSymbol() : fonction not defined
and there is a parenthesis superflu
PipsProfit = Bid - OrderOpenPrice();
the minus (-) is not recognised as a minus
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys!
Can I have an example of stop at breakeven?