V 3c is in post 1. This has the option to send an expiry time with pending orders both when responding to a TDesk initial signal and when sending a grid of stop orders. Your inputs are the number of minutes you will allow an unfilled pending to remain: PendingOrderExpiryMinutes and GridOrderExpiryMinutes.
I noticed that the order of inputs in the, "Trading styles" section was confusing, so I have rearranged them. It should be clearer now which inputs apply to immediate market trades and which to pending orders.
DIY:
Do a search for: extern string tst="---- Trading styles ----";
Copy this over the existing block:
Code: Select all
extern string tst="---- Trading styles ----";
//Send a market trade as soon as there is a signal
extern bool SendImmediateMarketTrade=true;
extern string mtr="-- Multiple market trades --";
//This allows the user to send trades following each new signal, up to a selected maximum
extern int MaxOpenTradesAllowed=5;
extern int MinDistanceBetweenTradesPips=30;
extern string pen="---- Pending trades ----";
extern bool SendPendingTrades=false;
extern PendingTradeTypes TypeOfPendingTrade=Stop_order_only;
extern int DistanceFromMarketPips=20;
//An expiry time for the stop order
extern int PendingOrderExpiryMinutes=0;
extern bool DeletePendingOrderWhenSignalChanges=false;
////////////////////////////////////////////////////////////////////////////////////////
double DistanceFromMarket=0;
double MinimumDistanceBetweenTrades=0;
////////////////////////////////////////////////////////////////////////////////////////
That will rearrange the inputs and add the new one.
Do a search for: extern int DistanceBetweenTradesPips
Insert this immediately below:
Code: Select all
//An expiry time for grid stop orders
extern int GridOrderExpiryMinutes=0;
Do a search for this comment: //if (SendPendingTrades) expiry = TimeCurrent() + (PendingExpiryMinutes * 60);
Delete the comment and replace it with this code block:
Code: Select all
/*Pending orders can be sent with an expiry time. Desky knows that
the trade is triggered by a fresh TDesk signal if grid trading
is disabled. He will send the appropriate expiry if grid trading
is enabled.
*/
//Is this a stop/limit order
if (type > 1)
{
//Responding to an original signal
if (!UseGridTrading)
{
if (PendingOrderExpiryMinutes > 0)
expiry = TimeCurrent() + (PendingOrderExpiryMinutes * 60);
}//if (!UseGridTrading)
//Grid orders
if (UseGridTrading)
{
if (GridOrderExpiryMinutes > 0)
expiry = TimeCurrent() + (GridOrderExpiryMinutes * 60);
}//if (UseGridTrading)
}//if (type > 1)
This is nearly at the top of the bool SendSingleTrade(string symbol,int type,string comment,double lotsize,double price,double stop,double take) function. I have also added an extra call to GetBasics() right at the top, merely as an extra precaution:

Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed
Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.