Ticket number as a GlobalVariable

 

Hi,

I'm not sure if this will work

GlobalVariableSet(_ticketshort,OrderSend("XAUUSD",OP_SELL,PositionVolume,Bid,0,0,0,"",0,0,clrNONE));

and later,

if(OrderSelect(GlobalVariableGet(_ticketshort),SELECT_BY_TICKET))

{

etc..

}


Can I make the ticket number a GlobalVariable?

 

Sorry, please ignore that garbage

Oops, what a dummy. the ticket number won't disappear in the event of a system crash, and will always be available.

Six demerits to me :(

 
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3. You'll have to cast the Get to an int.
  4. It's not persistent storage unless you flush the GV.
  5. It's unnecessary. Remember it in a global/static variable. On restart, recover it.
    Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
              MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
 
whroeder1:
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3. You'll have to cast the Get to an int.
  4. It's not persistent storage unless you flush the GV.
  5. It's unnecessary. Remember it in a global/static variable. On restart, recover it.
Thanks for the advice. Sorry about posting in the wrong place, I'll be more careful next time. Looks like I have some reading to do :)