Desky. TDesk's trading drone.

Post Reply
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Desky. TDesk's trading drone.

Post by SteveHopwood »

thomas1386 » Fri Mar 06, 2020 3:25 pm wrote:Hello Steve,
maybe I am doing something wrong - but it seems to me that deskys "maximum trading pairs safety feature" at version 4 does not work properly. The last version I have used is 3x and it worked as it should. Then I updated to version 4 and noticed that desky opened much more positions than allowed. I have updated to version 4f to use the latest version but it is the same problem - desky opens more orders than allowed.
I am using grid trading with only one grid stop order atr calculated.
Ii is no great problem because I can still use V3x. I just wanted to let you know about this.
I will attach my desky setfile.
Thomas
I had a look through the code and cannot find anything wrong.

The only function that ultimately sends a trade that does not include a max pairs check before sending, is the CT function. Yours is disabled, so the problem is not there.

No idea what is causing your problem.

:xm: :rocket:
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. [email protected] 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.
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Desky. TDesk's trading drone.

Post by SteveHopwood »

V 4f is in post 1. This gives us the ability to limit the number of gap filling and rolling grid trades. There are two new inputs in the grid inputs section.

MaxTradesPerPair is the limit for individual pairs. A zero value turns this off.
MaxTradesOverall is the limit for all trades owned by Desky. A zero value turns this off.

Bloop spotters and DIYers, do a search for:
//Max trades filter

to see what I have added.

:xm: :rocket:
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. [email protected] 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.
User avatar
WorldsEnd
Trader
Posts: 95
Joined: Fri Aug 29, 2014 7:36 pm

Desky. TDesk's trading drone.

Post by WorldsEnd »

Good morning Steve,
I am trying to combine the concept of your moving day ea with Baluda‘s SS and Peak Hi/Low with TDesk and Desky. Conditions as following:

• buy: price closed above the 480 MA on H1, SS D1 is positive (or above the 1.0 threshold i.e.), price is not in the upper peak range (upper 20% i.e.)
• sell: vice versa

If conditions are met, we place a stop order 10 (15 or 20) pips above last candle close (for a sell below of course).

We delete the stop order when price closes below the 480 MA again (possible reversal situation)

Exit condition: tbd ... my thoughts: stop orders are placed with a 300 pips emergency SL but without a fixed TP. We use an opposite MA cross as well as an opposite Peak to close running as well as stop orders. Furthermore I‘d suggest a jumping stop every 100 pips so that we are break even after the first 100 pips. Thereafter we bank 100 pips after every jump.

I worked out a TDesk setup which gives the necessary signals and I got Desky placing the orders as supposed. However, there‘s one essential condition I wasn‘t able to get managed by Desky thus far. The closure of pending trades when price closed below the 480 MA is not working as I thought it would. It is working for running orders though. I‘ve read the manual of TDesk and Desky a couple of times and went through the many setting of Desky but I can‘t find a possible solution for this problem.

I can post my .set files if this is of any help for you. Just let me know.
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Desky. TDesk's trading drone.

Post by SteveHopwood »

WorldsEnd » Sat Mar 28, 2020 9:05 am wrote:Good morning Steve,
I am trying to combine the concept of your moving day ea with Baluda‘s SS and Peak Hi/Low with TDesk and Desky. Conditions as following:

• buy: price closed above the 480 MA on H1, SS D1 is positive (or above the 1.0 threshold i.e.), price is not in the upper peak range (upper 20% i.e.)
• sell: vice versa

If conditions are met, we place a stop order 10 (15 or 20) pips above last candle close (for a sell below of course).

We delete the stop order when price closes below the 480 MA again (possible reversal situation)

Exit condition: tbd ... my thoughts: stop orders are placed with a 300 pips emergency SL but without a fixed TP. We use an opposite MA cross as well as an opposite Peak to close running as well as stop orders. Furthermore I‘d suggest a jumping stop every 100 pips so that we are break even after the first 100 pips. Thereafter we bank 100 pips after every jump.

I worked out a TDesk setup which gives the necessary signals and I got Desky placing the orders as supposed. However, there‘s one essential condition I wasn‘t able to get managed by Desky thus far. The closure of pending trades when price closed below the 480 MA is not working as I thought it would. It is working for running orders though. I‘ve read the manual of TDesk and Desky a couple of times and went through the many setting of Desky but I can‘t find a possible solution for this problem.

I can post my .set files if this is of any help for you. Just let me know.
This is one of those circumstances that I did not forsee. I know what the problem is.

Assuming such behaviour is desired, then Desky will close all buy and sell market trades following an EXIT or FLAT signal. I have looked at the code. He is not currently programmed to delete outstanding pending orders. I just need to think about how to solve this without inviting LUC around for coffee.

More tomorrow. I am not short of time to think at the mo. :lol:

:xm: :rocket:
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. [email protected] 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.
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Desky. TDesk's trading drone.

Post by SteveHopwood »

V 4h is in post 1. The solution to the non-deletion of pending trades appears simple, so 4h should fix this.

There is a simple DIY. Go to these two functions:
void doFlatSignalClosure(string symbol, int pairIndex, int signal)
void doExitSignalClosure(string symbol, int pairIndex, int signal)

You will find these lines of code in each function:
closeAllTrades(symbol, OP_BUY);
closeAllTrades(symbol, OP_SELL);

OP_BUY and OP_SELL both need changing to allTrades so all four lines of code across the two functions should become:
closeAllTrades(symbol, allTrades);

Sing out if the fix fails.

:xm: :rocket:
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. [email protected] 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.
User avatar
WorldsEnd
Trader
Posts: 95
Joined: Fri Aug 29, 2014 7:36 pm

Desky. TDesk's trading drone.

Post by WorldsEnd »

SteveHopwood » 29 Mar 2020, 12:42 wrote:V 4h is in post 1. The solution to the non-deletion of pending trades appears simple, so 4h should fix this.

There is a simple DIY. Go to these two functions:
void doFlatSignalClosure(string symbol, int pairIndex, int signal)
void doExitSignalClosure(string symbol, int pairIndex, int signal)

You will find these lines of code in each function:
closeAllTrades(symbol, OP_BUY);
closeAllTrades(symbol, OP_SELL);

OP_BUY and OP_SELL both need changing to allTrades so all four lines of code across the two functions should become:
closeAllTrades(symbol, allTrades);

Sing out if the fix fails.

:xm: :rocket:
Thx for pointing this out. Will do the change and try it out tomorrow when we enter the european trading times :good:
User avatar
WorldsEnd
Trader
Posts: 95
Joined: Fri Aug 29, 2014 7:36 pm

Desky. TDesk's trading drone.

Post by WorldsEnd »

SteveHopwood » 29 Mar 2020, 12:42 wrote:
Sing out if the fix fails.

:xm: :rocket:
:|

Sorry to say but it looks like the fix failed. The exit condition is defined for TDesk and Desky is working properly for market trades but not for pending ones. Those get placed correctly but not deleted when price closed opposite to the pending trade.
User avatar
SteveHopwood
Owner
Posts: 9754
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Desky. TDesk's trading drone.

Post by SteveHopwood »

WorldsEnd » Mon Mar 30, 2020 8:13 am wrote:
:|

Sorry to say but it looks like the fix failed. The exit condition is defined for TDesk and Desky is working properly for market trades but not for pending ones. Those get placed correctly but not deleted when price closed opposite to the pending trade.
Try 4i in post 1.

I have re-coded void closeAllTrades(string symbol, int type), so DIYers, copy this over the top of the existing function:

Code: Select all

void closeAllTrades(string symbol, int type)
{
   forceTradeClosure= false;
  
   
   //Just in case
   if (OrdersTotal() == 0) return;
   if (openTrades == 0) return;
   
   bool result = false;

   for (int cc = ArraySize(fifoTicket) - 1; cc >= 0; cc--)
   {
      if (!betterOrderSelect(fifoTicket[cc], SELECT_BY_TICKET, MODE_TRADES) ) continue;
      if (OrderMagicNumber() != MagicNumber) continue;
      if (OrderSymbol() != symbol) 
         if (symbol != allSymbols)
            continue;
      if (OrderType() != type) 
         if (type != allTrades)
            continue;
      
      while(IsTradeContextBusy()) Sleep(100);
      
      //Market orders
      if (OrderType() < 2)
      {
         result = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1000, CLR_NONE);
         if (result) 
         {
            cc++;
            openTrades--;
         }//(result) 
         
         if (!result)
         {
            reportError(" closeOrder()", ocm);
            forceTradeClosure= true;
         }//if (!result)

      }//if (OrderType() < 2)
      
      //Pending orders
      if (OrderType() > 1)
         if (OrderType() < 6)
         {
            while(IsTradeContextBusy()) Sleep(100);
            
            
            result = OrderDelete(OrderTicket(), clrNONE);
            if (result) 
            {
               cc++;
               openTrades--;
            }//(result) 
      
            if (!result)
            {
               reportError(" Delete Order()", odm);
               forceTradeClosure= true;
            }//if (!result)
         
         }//if (OrderType() < 6)
      
   }//for (int cc = ArraySize(fifoTicket) - 1; cc >= 0; cc--)
   
  
}//End void closeAllTrades(string symbol, int type)
I have added a function to delete orphaned pending orders, so insert this above OnTimer():

Code: Select all

void deleteOrphanedPendingOrders(string symbol, int signal)
{

   //Deleting pending orders on a signal change was proving
   //a problem, so this is an extra function to delete orphaned
   //stop and limit orders.
   
   //Make sure there is work to do.
   if (OrdersTotal() == 0)
      return;
   countOpenTrades(symbol);
   if (openTrades == 0)
      return;

   if (signal == FLAT)
      if (closeTradesOnFlatSignal)
         if (buyStopOpen || buyLimitOpen || sellStopOpen || sellLimitOpen)
         {
            deletePendingOrders(symbol);
            return;
         }//if (buyStopOpen || buyLimitOpen || sellStopOpen || sellLimitOpen)
         
   if (signal == EXIT)
      if (closeOpenOnEXITSignal)
         if (buyStopOpen || buyLimitOpen || sellStopOpen || sellLimitOpen)
         {
            deletePendingOrders(symbol);
            return;
         }//if (buyStopOpen || buyLimitOpen || sellStopOpen || sellLimitOpen)
         
   
   if (signal == LONG)
      if (closeOnOppositeSignal)
         if (sellStopOpen || sellLimitOpen)
         {
            deletePendingOrders(symbol);
            return;
         }//if (sellStopOpen || sellLimitOpen)
         
   if (signal == SHORT)
      if (closeOnOppositeSignal)
         if (buyStopOpen || buyLimitOpen)
         {
            deletePendingOrders(symbol);
            return;
         }//if (buyStopOpen || buyLimitOpen || sellStopOpen || sellLimitOpen)
         


}//void deleteOrphanedPendingOrders(string symbol, int signal)

To add the call to the new function, search for:
}//if (closeOpenOnEXITSignal)

Add the call underneath:

Code: Select all

      //Deleting pending orders on a signal change was proving
      //a problem, so this is an extra function to delete orphaned
      //stop and limit orders.
      deleteOrphanedPendingOrders(symbol, signal);
      if (forceTradeClosure)
      {
         pairIndex--;
         continue;
      }//if (forceTradeClosure)               
Then hope for the best, as the messenger occasionally gets shot.

:xm: :rocket:
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. [email protected] 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.
User avatar
WorldsEnd
Trader
Posts: 95
Joined: Fri Aug 29, 2014 7:36 pm

Desky. TDesk's trading drone.

Post by WorldsEnd »

Thx Steve for all your effort in solving my issue. I studied my screen all day long in order to see if your new fix worked out. I am not a 100% sure but as far as I can tell it does not. But, at the end of the day I am pretty sure that this has nothing to do with your work or desky.
I read this post by Thomas again and stumbled about one sentence.

“This list and logic input let you define which signals will force the trading EA to exit from all positions if the signals are opposite to the net lot size of all open positions.“

Might TDesk be the problem in the end? Am I right to assume that TDesk does not recognize pending trades? Does it need a market trade (a net lot size) to produce an exit signal? So for my case ... as long as there‘s just a pending trade, TDesk does not produce an exit signal and therefore Desky is unable to close the pending order? Does this sound reasonable?

Would love to read a statement from Thomas. He should be able to tell if there‘s something I can do. Or provide a coding solution, a fix or whatsoever.
User avatar
tomele
Administrator
Posts: 1166
Joined: Tue May 17, 2016 3:40 pm
Location: Germany, Forest of Odes, Defending the Limes

Desky. TDesk's trading drone.

Post by tomele »

SteveHopwood wrote:Might TDesk be the problem in the end? Am I right to assume that TDesk does not recognize pending trades? Does it need a market trade (a net lot size) to produce an exit signal? So for my case ... as long as there‘s just a pending trade, TDesk does not produce an exit signal and therefore Desky is unable to close the pending order? Does this sound reasonable?

Would love to read a statement from Thomas. He should be able to tell if there‘s something I can do. Or provide a coding solution, a fix or whatsoever.
You can very easily check whether it is a TDesk or Desky issue. Just observe the SuperSignal column. Does it show an EXIT signal or not?

Cheers
Thomas
Happy pippin, Thomas :-BD

It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so.
(Mark Twain)

Keep the coder going: Donate
Post Reply

Return to “TDesk: A Thomas Special. The greatest trading tool ever.”