//+------------------------------------------------------------------+ //| Modifies the position selected on the ticket | //+------------------------------------------------------------------+ bool PositionModifyByTicket(const string symbol_name,const ulong magic_number,const ulong ticket,const double sl,const double tp) { //--- check stopped if(IsStopped()) return(false); //--- clean ZeroMemory(g_request); ZeroMemory(g_result); //--- setting request g_request.action =TRADE_ACTION_SLTP; g_request.position=ticket; g_request.symbol =symbol_name; g_request.magic =magic_number; g_request.sl =sl; g_request.tp =tp; //--- action and return the result return(OrderSend(g_request,g_result)); }
Superfluous.
//+------------------------------------------------------------------+ //|| Trailing function| //+------------------------------------------------------------------+ void Trailing(void) { int total=PositionsTotal(); for(int i=total; i>=0; i--) { ulong ticket=PositionGetTicket(i); if(ticket==0) continue; string symbol_name=PositionGetString(POSITION_SYMBOL); ulong magic_number=(ulong)PositionGetInteger(POSITION_MAGIC); ENUM_POSITION_TYPE type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE); if(InpPositionType>WRONG_VALUE && type!=(ENUM_POSITION_TYPE)InpPositionType) continue;
It is very expensive (especially string) to create dedicated variables before all continue checks.
Imagine a simple optimisation for 100,000 passes of 10,000,000 ticks. Then OnTick will be called one TRILLION times. Any extra action called a trillion times will take extra seconds/minutes/hours. Value your own and others' time.
It is very expensive (especially string) to create dedicated variables before all continue checks.
Imagine a simple optimisation for 100,000 passes of 10,000,000 ticks. Then OnTick will be called one TRILLION times. Any extra action called a trillion times will take extra seconds/minutes/hours. Value your time and other people's time.
This is not a trading EA. Why optimise it? It's just a trawl. And a weird one at that.
It's a migrating Trailing function for training purposes.
This is a migrating Trailing function for training purposes.
Insufficient for migrating. Only in the context of the code in question.
Migratory - when 90% of the code is borrowed.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
TrailingTakeProfit:
This non-trading Expert Advisor is designed for the simple trailing of take profit orders of open positions.
Author: Scriptor