[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 591
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
Help me solve a problem
I sample all the closed items
for (int i=0; i<OrdersHistoryTotal(); i++)// For all orders
if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
then filter by magic number
if (OrderMagicNumber()==12)
filter satisfies 3 positions, but I need only the last closed one
can't figure out how to leave only the last one?
Thanks
Again, very much needed.
Help me solve the problem.
I am selecting by all closed positions
for (int i=0; i<OrdersHistoryTotal(); i++)// on all orders of the terminal
if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
afterwards filter by magic number
if (OrderMagicNumber()==12)
the filter matches 3 positions but I need only the last closed one
Can't figure out how to leave only the last one?
Thanks
Please help! I need it to open order immediately after closing the old one, at Tp or SL price.
#property copyright "Copyright © 2010, MetaQuotes Software Corp.
#property link "http://www.metaquotes.net"
#property show_confirm
extern int MaxRisk=3;
extern bool Buy=false; //for opening a Buy order
extern bool Sell=true; //to open a sell order.
extern inttern MagicNumber=7749;
extern TP=210;
extern inttern SL=420;
{
double point=MarketInfo(Symbol(),MODE_POINT);//request Point
double Free=AccountFreeMargin();
double One_Lot =MarketInfo(Symbol(),MODE_MARGINREQUIRED);
double Step =MarketInfo(Symbol(),MODE_LOTSTEP);
double Lot =MathFloor(Free*MaxRisk/100/One_Lot/Step)*Step;
int pos,total=OrdersTotal();
//----
if(Buy==true && OrdersTotal()<=1)
{
OrderSend(Symbol(),OP_BUY,Lot,Ask,3,Ask-SL*Point,Ask+TP*Point, "777"+ Symbol(), MagicNumber, 0, DarkGreen);
Buy=false;
}
if(Sell==true && OrdersTotal()<=1)
{
OrderSend(Symbol(),OP_SELL,Lot,Bid,3,Bid+SL*Point,Bid-TP*Point, "4949"+ Symbol(), MagicNumber, 0, DarkGreen);
Sell=false;
}
for (pos=0; pos<total; pos++)
if(OrderSelect(pos,SELECT_BY_POS )==true)
if(OrdersTotal()==OP_BUY)
if(PRICE_CLOSE==OrderTakeProfit()) Buy=true;
if(PRICE_CLOSE==OrderStopLoss()) Sell=true;
}
}
if(OrderSelect(pos,SELECT_BY_POS )==true)
if (OrdersTotal()==OP_SELL)
{
if(PRICE_CLOSE==OrderStopLoss()) Buy=true;
if(PRICE_CLOSE==OrderTakeProfit()) Sell=true;
}
} }
//----
return(0);
}
//+------------------------------------------------------------------+
Guys, here's a question, an EA tries to open an order, but the price changes and displays an error wrong price, how can I bypass it, so it tries to buy until it buys?
It used to be.
I added 30 because I have a 5 sign but it's useless.
Again, very much needed.
Help me solve the problem.
I'm sampling all the closed items.
Start at the end, then the first matching one is the one.
for (int i=OrdersHistoryTotal()-1;i>=0; i--)//
if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
There is still one more annoyance, there are sections where there is only a closing of a position and not a reversal, although the conditions for a stop and opening a new position are the same.
These situations can occur because the buy and sell conditions in the Expert Advisor are not mutually exclusive. Try to trace the values of the required variables in the tester according to
Guys, here's a question, an EA tries to open an order, but the price changes and displays an error wrong price, how can I bypass it, so it tries to buy until it buys?
It used to be.
I added 30 because I have a 5 sign but it's useless.
this needs to be investigated in detail, such situations can arise because the buy and sell opening conditions in the EA are not mutually exclusive. Try to trace the values of the required variables in the tester along the lines of
What is relevant to your question is underlined.