here.
bool IsNearPreviousTrade(string _symbol, int order_type, double price=0, double range_in_points=100) { double range = range_in_points*Point; if(price==0) price=Ask; for(int i=OrdersTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) continue; if(OrderSymbol()!=_symbol) { continue; } if(order_type==OrderType()) if(MathAbs(price-OrderOpenPrice())<range) return(true); } return(false); } // how to use it... int start() { if(_buy_condition_) if(!IsNearPreviousTrade(Symbol(), OP_BUY, Ask, 50)) OrderSend(....); .... }
How do I check through all already opened price?
I tried the following, but does not work.
if (condition).....
for(bcnt=btotal-1; bcnt >= 0; bcnt--)
{
OrderSelect(bcnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if( (Ask > OrderOpenPrice() + (Point*OrderDist)) || (Ask < OrderOpenPrice() - (Point*OrderDist)) )
{
Buy();
......
bool buyOK=true;
for(bcnt=btotal-1; bcnt >= 0; bcnt--)
{
if( OrderSelect(bcnt, SELECT_BY_POS, MODE_TRADES)
&& OrderSymbol() == Symbol()
&& OrderMagic() == Magic)
{
if( OrderType() == OP_BUY
&& Ask <= OrderOpenPrice() + Point*OrderDist
&& Ask >= OrderOpenPrice() - Point*OrderDist) )
buyOK = false;
} }
if (buyOK) Buy();
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How do I check through all already opened price?
I tried the following, but does not work.
if (condition).....
for(bcnt=btotal-1; bcnt >= 0; bcnt--)
{
OrderSelect(bcnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if( (Ask > OrderOpenPrice() + (Point*OrderDist)) || (Ask < OrderOpenPrice() - (Point*OrderDist)) )
{
Buy();
......
//------------------------------