Desky. TDesk's trading drone.

Post Reply
wojtek_amm
Trader
Posts: 23
Joined: Fri Jan 13, 2012 9:52 am
Location: Poland

Desky. TDesk's trading drone.

Post by wojtek_amm »

Hey Steve,

Many thanks for the hard work for the whole team. :clap: :clap: :clap:

I think that it would be a useful option to stop EA after close, for example, 8 (xx) baskets a day.

What do you think? Would this be useful?

Can you add it to Drone?

Best Regards
Wojtek
User avatar
SteveHopwood
Owner
Posts: 9904
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 3d is in post 1. I have rewritten the swap filter code. To DIY, go to this function:
void TradeDirectionBySwap(string symbol)

Replace it with this one:

Code: Select all

void TradeDirectionBySwap(string symbol)
{

   //Cancel a trade signal if the swap is negative and the user
   //does not want to trade high swap pairs in the wrong direction.
   //Also if the user does not want to trade negative swap at all.

   GetBasics(symbol);
   
   if (CadPairsPositiveOnly)
   {
      if (StringSubstrOld(symbol, 0, 3) == "CAD" || StringSubstrOld(symbol, 0, 3) == "cad" || StringSubstrOld(symbol, 3, 3) == "CAD" || StringSubstrOld(symbol, 3, 3) == "cad" )      
      {
         if (BuySignal)
            if (longSwap < 0) 
               BuySignal = false;

         if (SellSignal)
            if (shortSwap < 0) 
               SellSignal = false;
      }//if (StringSubstrOld()      
   }//if (CadPairsPositiveOnly)
   
   if (AudPairsPositiveOnly)
   {
      if (StringSubstrOld(symbol, 0, 3) == "AUD" || StringSubstrOld(symbol, 0, 3) == "aud" || StringSubstrOld(symbol, 3, 3) == "AUD" || StringSubstrOld(symbol, 3, 3) == "aud" )      
      {
         if (BuySignal)
            if (longSwap < 0) 
               BuySignal = false;

         if (SellSignal)
            if (shortSwap < 0) 
               SellSignal = false;
      }//if (StringSubstrOld()      
   }//if (AudPairsPositiveOnly)
   
   
   if (NzdPairsPositiveOnly)
   {
      if (StringSubstrOld(symbol, 0, 3) == "NZD" || StringSubstrOld(symbol, 0, 3) == "nzd" || StringSubstrOld(symbol, 3, 3) == "NZD" || StringSubstrOld(symbol, 3, 3) == "nzd" )      
      {
         if (BuySignal)
            if (longSwap < 0) 
               BuySignal = false;

         if (SellSignal)
            if (shortSwap < 0) 
               SellSignal = false;
      }//if (StringSubstrOld()      
   }//if (AudPairsPositiveOnly)
   
   //OnlyTradePositiveSwap filter
   if (OnlyTradePositiveSwap)
   {
         if (BuySignal)
            if (longSwap < 0) 
               BuySignal = false;

         if (SellSignal)
            if (shortSwap < 0) 
               SellSignal = false;
   }//if (OnlyTradePositiveSwap)
   
   //MaximumAcceptableNegativeSwap filter
   if (BuySignal)
      if (longSwap < MaximumAcceptableNegativeSwap) 
         BuySignal = false;
   
   if (SellSignal)
      if (shortSwap < MaximumAcceptableNegativeSwap) 
         SellSignal = false;      


}//void TradeDirectionBySwap()

I have removed a couple of variables. Do a search for: bool TradeLong=true;
Delete TradeLong and TradeShort. Compiling will throw up two error, so go to them and delete the lines of code that contain them.

---------------

I have added gap filling to the grid trading section. From the updated user guide:
  • FillTheGaps: imagine this scenario:
    • Desky is buying.
    • The market walls a long way below the lowest order price – it does not matter whether this is a market or a stop order.
    • The market eventually falls twice the distance between the lowest order price minus twice DistanceBetweenTradesPips.
    • Desky places a new buy stop order at the lowest order price minus DistanceBetweenTradesPips. He has filled the gap in between the market and the lowest order price.
    • The code attempts to respond to your UseIncrementalLotSizing if you are in the US.
To DIY:
Scroll down the the grid inputs section of the inputs. I have rearranged the order as well as adding the fill the gap input. so replace the entire block with this:

Code: Select all

extern string  sep3="================================================================";
extern string  gri="---- Grid inputs ----";
extern string  ggi="-- General grid inputs --";
extern bool    UseGridTrading=false;
extern GridTypes TypeOfGrid=Stop;
extern int     GridSize=5;
extern int     DistanceBetweenTradesPips=30;
//Filling the gaps when the market has moved against the original trade
extern bool    FillTheGaps=false;
//An expiry time for grid stop orders
extern int     GridOrderExpiryMinutes=0;
extern string  strg="-- Using ATR to calculate the distance between trades --";
extern bool    UseAtrForGrid=false;
extern ENUM_TIMEFRAMES GridAtrTimeFrame=PERIOD_D1;
extern int     GridAtrPeriod=20;
extern double  GridAtrDivisor=5;
//Pending order deletion following a FLAT or opposite direction signal.
extern string  god="-- Pending order deletion inputs --";
extern bool    DeletePendingOrdersOnFlatSignal=true;
extern bool    DeletePendingOrdersOnOppositeSignal=true;
//Adding to the grid when there is a strong move in our favour and all the stop orders have filled
extern string  rgi="--Rolling grid inputs --";
extern bool    RollingGrid=false;
extern int     MaxRolledTrades=20;
//Close the grid when there are the max trades open and the market reaches the next level
extern bool    CloseGridAtMrtPlusOneLevel=false;
extern string  gtp="-- Individual grid trades take profit --";
//This tells Desky to set the take profit for each trade at the open price of the next trade in the grid.
extern bool    UseNextLevelForTP=false;
////////////////////////////////////////////////////////////////////////////////////////
double         DistanceBetweenTrades=0;
////////////////////////////////////////////////////////////////////////////////////////
Do a search for: //End void CanWeSendTrades(string symbol, int signal)
Look up a few lines until you see: }//if (!StopTrading)
Insert this immediately above:

Code: Select all

         //There is no hedge in place and trading is not stopped.
         //Is there a gap to fill
         if (FillTheGaps)
            FillTheGap(symbol);
Go a couple of lines underneath: //End void CanWeSendTrades(string symbol, int signal). Add this new function:

Code: Select all

void FillTheGap(string symbol)
{

   //Add a ned pending order if the market has moved DistanceBetweenTrades * 2 
   //against the original trade.
   
   double hiLowestPrice = 0;//Store the highest/lowest price of buy/sell trades
   double targetPrice = 0;//Hold the 'target'price at which to send the new stop order
   double price = 0;//Stop order send price
   bool sendTrade = false;
   int type = 0;
   double take = 0;
   double stop = 0;
   double sendLots = Lot;
   if (UseIncrementalLotSizing)
      if (!CloseEnough(HighestLotSoFar, 0))
         sendLots = NormalizeLots(symbol, HighestLotSoFar + LotIncrement);
   
   GetBasics(symbol);
   
   //Buys. Does not apply to limit orders
   if (BuyOpen || BuyStopOpen)
   {
      
      //Find the lowest price in the grid. This can be either a market
      //or a stop order.
      
      //Market buy only
      if (BuyOpen)
         if (!BuyStopOpen)
            hiLowestPrice = LowestBuyPrice;
            
      //Buy stops only
      if (!BuyOpen)
         if (BuyStopOpen)
            hiLowestPrice = LowestBuyStopPrice;
            
      //Both
      if (BuyOpen)
         if (BuyStopOpen)
            hiLowestPrice = MathMin(LowestBuyPrice, LowestBuyStopPrice);
      
      //Has the market reached DistanceBetweenTrades * 2 
      targetPrice = hiLowestPrice;
      targetPrice-= (DistanceBetweenTrades / factor) * 2;
      
      if (ask <= targetPrice)//It is, so set up the trade
      {
         sendTrade = true;
         type = OP_BUYSTOP;
         price = NormalizeDouble(hiLowestPrice - (DistanceBetweenTrades / factor), digits);
         take = CalculateTakeProfit(symbol, OP_BUY, price);
         if (UseNextLevelForTP)
            take = hiLowestPrice;
         stop = CalculateStopLoss(symbol, OP_BUY, price);
         
      }//if (ask <= targetPrice)
   
   }//if (BuyOpen || BuyStopOpen)

   //Sells. Does not apply to limit orders
   if (SellOpen || SellStopOpen)
   {
      
      //Find the lowest price in the grid. This can be either a market
      //or a stop order.
      
      //Market buy only
      if (SellOpen)
         if (!SellStopOpen)
            hiLowestPrice = HighestSellPrice;
            
      //Sell stops only
      if (!SellOpen)
         if (SellStopOpen)
            hiLowestPrice = HighestSellStopPrice;
            
      //Both
      if (SellOpen)
         if (SellStopOpen)
            hiLowestPrice = MathMin(HighestSellPrice, HighestSellStopPrice);
      
      //Has the market reached DistanceBetweenTrades * 2 
      targetPrice = hiLowestPrice;
      targetPrice+= (DistanceBetweenTrades / factor) * 2;
      
      if (bid >= targetPrice)//It is, so set up the trade
      {
         sendTrade = true;
         type = OP_SELLSTOP;
         price = NormalizeDouble(hiLowestPrice + (DistanceBetweenTrades / factor), digits);
         take = CalculateTakeProfit(symbol, OP_SELL, price);
         if (UseNextLevelForTP)
            take = hiLowestPrice;
         stop = CalculateStopLoss(symbol, OP_SELL, price);
         
      }//if (bid >= targetPrice)
   
   }//if (SellOpen || SellStopOpen)
   
   
   //Send an stop order
   if (sendTrade)
   {
      bool result = SendSingleTrade(symbol, type, TradeComment, sendLots, price, stop, take);
      if (!result)
      {
         int err=GetLastError();
         if (err == 132)//Market is closed
            return;
         if (type == OP_BUYSTOP)
            Alert(symbol, " Buy stop failure: Lots ", NormalizeDouble(sendLots, 2), 
                  ": Price ", NormalizeDouble(price, 2), ": TP ", take, ": SL ", stop);
         else   
            Alert(symbol, " Sell stop failure: Lots ", NormalizeDouble(sendLots, 2), 
                  ": Price ", NormalizeDouble(price, 2), ": TP ", take, ": SL ", stop);
      }//if (!result)
      
   
   }//if (sendTrade)
   

}//End void FillTheGap(string symbol)

I have included thorough error reporting, so post a pic if anything goes wrong.

: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. 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.
JockTrader
Posts: 2
Joined: Sat Mar 02, 2019 4:11 pm

Desky. TDesk's trading drone.

Post by JockTrader »

Hi Steve i think i might have found an issue with new gap feature, when you go Short, it seams to add orders until your account cant take no more, it does not do this every time, i'm sure its only when the first grid has not been hit, Long seams fine, i have uploaded 2 video of Long and Short - please note i had to shoehorn your code into my dashboard so that i can test it out but i'm sure ive not f8cked any thing up in the new code.

Seems the videos wont upload, is 6MB to big.
User avatar
SteveHopwood
Owner
Posts: 9904
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 »

JockTrader » Thu Mar 14, 2019 7:46 pm wrote:Hi Steve i think i might have found an issue with new gap feature, when you go Short, it seams to add orders until your account cant take no more, it does not do this every time, i'm sure its only when the first grid has not been hit, Long seams fine, i have uploaded 2 video of Long and Short - please note i had to shoehorn your code into my dashboard so that i can test it out but i'm sure ive not f8cked any thing up in the new code.

Seems the videos wont upload, is 6MB to big.
Thanks. I found the bloop within seconds of starting to look. Fix is in post 1.

This is one of my usual copy/paste/forgot-to-edit thingies. The DIY fix makes it obvious. Do a search for:
hiLowestPrice = MathMin(HighestSellPrice, HighestSellStopPrice);

You folks probably don't need to read any further but just in case, replace it with:
hiLowestPrice = MathMax(HighestSellPrice, HighestSellStopPrice);

: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. 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.
User avatar
SteveHopwood
Owner
Posts: 9904
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 3e is in post 1.

The next version of TDesk will include the facility to generate an EXIT signal, so 3e includes the option to act on this. The new input is in the trade exits section - CloseOnEXITSignal. This has no effect at the moment; it will start to work as soon as Thomas releases his next version.

Some folks like to be alerted when Desky does anything major, so I have added a mass of alerts options. You will find these right at the end of the inputs. There is a section in the user guide about them but their use should be obvious from their names. You can have a screen alert and a smart phone 'push' alert:
  • Input names beginning with, "Show" sends an alert to your screen.
  • Input names beginning with, "Send" sends an alert to your smart phone.
The easiest way to DIY is to load 3f into your editor. Start with a search for:
extern bool CloseOnEXITSignal=false;

Copy the input into your file. Searching for, "CloseOnEXITSignal" will take you to the code in OnTimer() that calls the void DoExitSignalClosure(string symbol, int pairIndex, int signal) to do the work. Copy it all into your file.

Copy this little lot to the end of your inputs:
//Alerts
extern string sep18="================================================================";
extern string ale="---- Alerts ----";
extern bool ShowFlatClosureAlert=false;
extern bool SendFlatClosureAlertPush=false;
extern bool ShowOppositeSignalClosureAlert=false;
extern bool SendOppositeSignalClosureAlertPush=false;
extern bool ShowEXITSignalClosureAlert=false;
extern bool SendEXITSignalClosureAlertPush=false;
extern bool ShowMarginLevelClosureAlert=false;
extern bool SendMarginLevelClosureAlertPush=false;
extern bool ShowPendingDeltionAlert=false;
extern bool SendPendingDeltionAlertPush=false;
extern bool ShowRolledTradesSentAlert=false;
extern bool SendRolledTradesSentAlertPush=false;
extern bool ShowCloseGridAtMrtPlusOneLevelAlert=false;
extern bool SendCloseGridAtMrtPlusOneLevelAlertPush=false;
extern bool ShowIndividualBasketCloseAlert=false;
extern bool SendIndividualBasketCloseAlertPush=false;
extern bool ShowGlobalBasketCloseAlert=false;
extern bool SendGlobalBasketCloseAlertPush=false;
extern bool ShowRecoveryCloseAlert=false;
extern bool SendRecoveryCloseAlertPush=false;
extern bool ShowHedgeSendAlert=false;
extern bool SendHedgeSentAlertPush=false;
extern bool ShowHedgeClosedAlert=false;
extern bool SendHedgeClosedAlertPush=false;
extern bool ShowShirtProtectionAlert=false;
extern bool SendShirtProtectionAlertPush=false;

Then go to 3f and search for each of the inputs in turn to find the code to copy and where to copy it.

A DIY here is going to be a bit of a faff. It might be quicker to make your own changes to 3f rather than try to edit your own file.

: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. 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.
User avatar
SteveHopwood
Owner
Posts: 9904
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 »

Thomas has released TDesk 6 viewtopic.php?p=166863#p166863 :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

Desky 3g is in post 1 here. Amongst other stuff, 3g will respond to EXIT signals by closing your position.

3g and future releases will have the over-trading filters enabled by default, so you will need to turn them off if you do not want them. Noobs, leave them alone.

This is not a version to DIY folks. It will be easier to download 3g and make your own changes to the inputs etc than to try to add the changes.

Plus, I cannot be arsed to describe them.

: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. 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.
vinayakshanbhag
Posts: 1
Joined: Wed Mar 13, 2019 3:45 pm

Desky. TDesk's trading drone.

Post by vinayakshanbhag »

can't load the TDesk trading partner ea on the chart, that is downloaded from post 1
of TDesk trading Drone.
Can you help me with this matter please and let me know if i am on the right page
Regards :
User avatar
SteveHopwood
Owner
Posts: 9904
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 »

Most of you will have read this post: viewtopic.php?p=166881#p166881

I checked and have not made the same mistake in Desky's code.

: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. 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.
User avatar
SteveHopwood
Owner
Posts: 9904
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 »

I just received this PM from Bob, so I am posting it in all the most active threads:
nanningbob wrote:I’m going to be in New Zealand April 13-22. Auckland 13-16 and the rest of the time traveling the South Island. If any kiwis want to meet be glad to say hi. I also will be in Fiji islands 4/10-13

Don’t know how to send out a message like this??

Bob
The best way to get in touch will be by PM.

: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. 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.
User avatar
SteveHopwood
Owner
Posts: 9904
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 3h is in post 1. It incorporates an exit strategy based on an idea linked by LittleCaro at http://www.stevehopwoodforex.com/phpBB3 ... 66#p166966

From the updated user guide trade exit strategies section:
  • Ratio of winning cash to losing cash closure: LittleCaro posted about this at http://www.stevehopwoodforex.com/phpBB3 ... 66#p166966. I followed the link and what I read there gave me this idea:
    • You have a bunch of trades open:
      • Imagine the cash total of the losers is -US16.
      • Imagine the total cash of the winners is +US64.
      • You have in mind to close all trades on the platform as soon as the winning cash outstrips the losing cash by a ratio of 4:1
      • In this example, your target has been hit and so Desky closes all his trades. Happy days.
    • The inputs:
      • UseWinToLossRatioClosure: turns this on/off.
      • WinLossRatio: your target ratio of winning cash to losing cash.
      • MinimumLosingTrades: the number of losing trades you need before Desky starts to look for a successful global trades closure.
    • IMPORTANT NOTE: Desky will not care about your trading style if you enable this feature. He will invoke this closure method regardless of single, multiple, grid or basket trading.
This is not an implementation of Braintheboss' method. It is an idea inspired by his early posts. Thanks for bringing it to our attention, LittleCaro.

: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. 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.
Post Reply

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