• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 6:37am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 6:37am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

EA to Open trade at specified time 14 replies

How to retrieve Historical Data for Global PMI and NMI? 0 replies

Retrieve indicator's value 3 replies

Can someone fill my limit order even if price doesn't hit the specified limit? 5 replies

How Do I Retrieve Ea Trade's? 4 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: How to retrieve a specified closed order using HistoryTotal() ?
Cancel

How to retrieve a specified closed order using HistoryTotal() ?

  • Post #1
  • Quote
  • First Post: Edited 3:10pm Nov 9, 2006 2:54pm | Edited 3:10pm
  •  skyline
  • Joined Apr 2006 | Status: Metatrader Programmer | 1,399 Posts
Hi All
is there a way using HistoryTotal function to be able to find a particular order (buy or sell) closed ?
I tried with this code but it seems not working :

Inserted Code
   int hstTotal=HistoryTotal();
   for(i=0; i < hstTotal ; i++)
   {
      if (OrderType()==OP_BUY && OrderComment()=="LONG") 
      {
       ..take some action...
      }
      if (OrderType()==OP_SELL && OrderComment()=="SHORT") 
      {
       ..take some action...
      }
   }

And when a buy order was in place using OrderSelect I identified this using "LONG" as comment (and "SHORT" if a sell order) :

Inserted Code
Sell :
  ..
  ..
  OrderSend(Symbol(),OP_SELL,Lots,Entry,Slippage, StopLoss ,TakeProfit,"SHORT",0,0);
  ..
  ..

Buy :
 ..
 ..
  OrderSend(Symbol(),OP_BUY,Lots,Entry,Slippage, StopLoss ,TakeProfit,"LONG",0,0);
 ..
 ..

Maybe function OrderComment is not supported using in conjuction with MODE_HISTORY mode? And if so how can I solve this issue?

thx a lot
Skyline
  • Post #2
  • Quote
  • Last Post: Nov 9, 2006 4:50pm Nov 9, 2006 4:50pm
  •  4xCoder
  • | Joined Dec 2005 | Status: Will Code for Pips | 137 Posts
Try making the following change. You have to call OrderSelect before using any of the other Order calls, except OrderSend, of course.

Inserted Code
   int hstTotal=HistoryTotal();
   for(i=0; i < hstTotal ; i++)
   {
    [color=Red]if ( OrderSelect( i, SELECT_BY_POS, MODE_HISTORY ) ) {[/color]
      if (OrderType()==OP_BUY && OrderComment()=="LONG") 
      {
       ..take some action...
      }
      if (OrderType()==OP_SELL && OrderComment()=="SHORT") 
      {
       ..take some action...
      }
[color=Red]}[/color]
   }
 
 
  • Platform Tech
  • /
  • How to retrieve a specified closed order using HistoryTotal() ?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023