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
problem with close position
......
double cena=0;
static int isCrossed = 0;
isCrossed = Crossed (k,d);
if(OrderSelect(ticket, SELECT_BY_POS))
{
c=OrderOpenPrice();
return(0);
}
if (isCrossed>0)
{
cena=((c-Ask)*10000);
return(0);
}
total = OrdersTotal();
if(total < 1)
{
if(isCrossed == 1)
{
ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, 1000, cena,
cena , "EMA_CROSS", 12345, 0, Green);
}
....
if(isCrossed == 2)
{
ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, 1000, cena,
cena, "EMA_CROSS", 12345, 0, Red);
......
general the EA close the position when the EMA's crossing and at the same time open the another position
the positions opened but they don't want close ;/
please help
Is it possible to close a position and to open a new one at the same tick?
(...)
if(OrdersTotal()!=0) {
(...)
OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), Slippage, Green ); }
if(OrdersTotal()==0) {
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask - SL * Point, Ask + TP * Point, NULL, Magic, 0, Green); }
(...)
In this code sample, the short position will be closed at the first tick, but the long position will not be opened instantly. It takes another tick to open the long position.
Thanks in advance :-)
Yes, it's possible. Just put the function RefreshRates() between operators.
...... please help
It looks like: I'm Pietra. What is my second name?
It's impossible to help you without the whole code. Sorry.
Need help coding
Anyone can help me about MT4 coding for knowing maximum and minimum open prices for EA? There are some openings by an EA.
I found code like this, but it is for knowing first/last transaction opening.
double GetLastBuyPrice(int Magic)
{
int total=OrdersTotal()-1;
for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUY))
{
return(OrderOpenPrice());
}
}
return(10000);
}
How to code for knowing highest/lowest transaction opening?
Code
Anyone can help me about MT4 coding for knowing maximum and minimum open prices for EA? There are some openings by an EA.
I found code like this, but it is for knowing first/last transaction opening.
Double opens[1000] = {0};
double maxopen = 0 ;
double minopen = 1000000 ;
// double GetLastBuyPrice(int Magic)
{
int total=OrdersTotal()-1;
for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUY))
{
opens[cnt] = OrderOpenPrice() ;
}
}
for ( cnt = 0 ; cnt <= total ; cnt ++ )
{
if ( opens[cnt] > maxopen ) maxopen = opens[cnt] ;
if ( opens[cnt] < minopen ) minopen = opens[cnt] ;
}
}
How to code for knowing highest/lowest transaction opening?hi,
change the code as above,
it is not a procedure for calling from other ...,
put it where you want in your EA code .
OTR
Need help to make code to open more than one order
I have been unsuccessful in adding code to open a second order.
I am trying to open 2 order based on the same signal with different TP levels.
below is my code for opening the first order:
any help is appreciated.
if(SlowSell<0 && FastSell<0 && PrevFastSell==0)
{
ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slipage,Bid+StopLoss*Point,Bid-TakeProfit*Point,"MA_Angle_Trader",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SellStop order opened : ",OrderOpenPrice());
}
else Print("Error opening SellStop order : ",GetLastError());
return(0);
ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slipage,Bid+StopLoss*Point,0,"MA_Angle_Trader",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SellStop order opened : ",OrderOpenPrice());
}
else Print("Error opening SellStop order : ",GetLastError());
return(0);
}
Hello
I need some simple coding help,
1) Hedging a trade at certain number of pips
2) Then disables/suspends any further trading..........
Making sure it doesn't hedge again as I will manually close the hedged trade.
I have been unsuccessful in adding code to open a second order.
I am trying to open 2 order based on the same signal with different TP levels.
below is my code for opening the first order:
any help is appreciated.
if(SlowSell<0 && FastSell<0 && PrevFastSell==0)
{
ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slipage,Bid+StopLoss*Point,Bid-TakeProfit*Point,"MA_Angle_Trader",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SellStop order opened : ",OrderOpenPrice());
}
else Print("Error opening SellStop order : ",GetLastError());
return(0);
ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,Slipage,Bid+StopLoss*Point,0,"MA_Angle_Trader",MagicNumber,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SellStop order opened : ",OrderOpenPrice());
}
else Print("Error opening SellStop order : ",GetLastError());
return(0);
}Replace first
return(0);
to
RefreshRates();