Desky. TDesk's trading drone.

Post Reply
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 »

Don't worry about this folks. Tutank contacted me about it so I looked at the code. It was bollocks - a Steve Classic. Blind chance allowed the routine to appear to work from time to time.

I shall be releasing an update over the weekend. If you want a quick DIY, do a search for "//Stop/limit orders sent when SendPendingTrades is enabled" and copy this over the top of the code:

Code: Select all

   //Stop/limit orders sent when SendPendingTrades is enabled
   if (SendPendingTrades)
      if (DeletePendingOrderWhenSignalChanges)
         if (PendingTradesTotal > 0)
         {
            //Long pendings
            if (BuyStopOpen || BuyLimitOpen)
               if (signal != LONG)
               {
                  DeletePendingOrders(symbol);
                  CountOpenTrades(symbol);         
               }//if (signal != LONG)
               
            //Short pendings
            if (SellStopOpen || SellLimitOpen)
               if (signal != SHORT)
               {
                  DeletePendingOrders(symbol);
                  CountOpenTrades(symbol);         
               }//if (signal != SHORT)
               
         }//if (PendingTradesTotal > 0)
: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 2u is in post 1. A number of bloops emerged last week so I have been gradually fixing them. The pending order removal thingy should be resolved now.

I have added a new feature to grid trading. This is the option to use the order open price of the next trade in the grid as the take profit of the one being sent to the server. The input is UseNextLevelForTP. I have added this to SPB Latest as well.

I am posting this today for the DIYers. Code phobics might want to wait until a bit later tomorrow, just in case I think of something else.

DIYers, this will not be so simple this time. Probably the only way you can find the changes is by going to a site such as https://www.diffchecker.com/ and comparing the new file with the old. This could be a time to spare yourself some effort and just download 2u.

: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 have a present for Gertje. I have extended Peaky so that users can 'flip' the signal generated by the peak hilo. From the updated Peaky user guide:
  • There will be users who will want to trade long from the lower part of the chart even though the short cycle has not completed yet and there is no new peal low. They will also want to trade short from the top of the chart even though there is no new peak high. These two inputs allow this:
    • AllowSignalFlip: this causes Peaky to 'flip' the signal it displays and sends to TDesk:
      • short signal from the top two sixths of the chart even though there is no new peak high. Peaky will be displaying a long signal without the flip.
      • long signal from the bottom two sixths of the chart even though there is no new peak low. Peaky will be displaying a short signal without the flip.
    • NoSignalInMiddleOfChart: this tells Peaky to send TDesk a flat signal if the market is in the middle two sixths of the chart.
Download the latest from either the SPB thread or from Peaky's first home at http://www.stevehopwoodforex.com/phpBB3 ... 46#p161246

: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.
ppaulius1
Posts: 5
Joined: Wed Aug 31, 2016 4:17 pm
Location: Lithuania

Desky. TDesk's trading drone.

Post by ppaulius1 »

SteveHopwood wrote:V 2u is in post 1. A number of bloops emerged last week so I have been gradually fixing them. The pending order removal thingy should be resolved now.

I have added a new feature to grid trading. This is the option to use the order open price of the next trade in the grid as the take profit of the one being sent to the server. The input is UseNextLevelForTP. I have added this to SPB Latest as well.

I am posting this today for the DIYers. Code phobics might want to wait until a bit later tomorrow, just in case I think of something else.

DIYers, this will not be so simple this time. Probably the only way you can find the changes is by going to a site such as https://www.diffchecker.com/ and comparing the new file with the old. This could be a time to spare yourself some effort and just download 2u.

:xm: :rocket:
Thank you very much for a new version, Steve. I tested it and seems mentioned bug has been solved.

Cheers,
Paulius
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 »

ppaulius1 » Mon Feb 18, 2019 6:23 pm wrote:
Thank you very much for a new version, Steve. I tested it and seems mentioned bug has been solved.

Cheers,
Paulius
Fabulous. Thanks for confirming this.

: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 2v is in post 1.

This one is for those of you hedging at > 100% and looking for a breakeven. From the updated UG:
  • Closing all of a pair's trades when a hedged position reaches breakeven: this is for those of you using a > 100% PercentageToHedge input:
    • CloseAllAtBreakeven: turns this feature on/off.
    • HedgeProfitTargetCash: close the position when the cash UPL reaches this target. The default of 0 means close the instant the cash UPL reaches break even.
    • HedgeProfitTargetPips: close the position when the pips UPL reaches this target. The default of 0 means close the instant the cash UPL reaches break even. Here are a couple of points to bear in mind. There are circumstances when:
      • The position can be pips positive but cash negative.
      • The position can be cash positive but pips negative. This happens frequently when basket trading, and it is the cash we are making that counts, not the pips.
If you want to check my code, or DIY:
Search for, "extern double PercentageToHedge" and add the inputs:

Code: Select all

//Some breakeven closure options for those hedging at > 100%
extern bool    CloseAllAtBreakeven=false;
extern int     HedgeProfitTargetCash=0;
extern int     HedgeProfitTargetPips=0;
I noticed something I missed from the void CanWeRemoveTheHedge(string symbol, int pairIndex) function. Desky needs to know what trade type failed when closing an individual hedge trade. Scroll down to the if (result) code block and add this underneath that block:

Code: Select all

      //Tell Desky which trade to close on a retry
      if (!result)
      {
         if (hedgeIsBuy)
            BuyClosureFailure = true;
         else
            SellClosureFailure = true;
      }//if (!result)

Go to void DoHedging(string symbol, int pairIndex) and scroll down a few lines to, "CanWeRemoveTheHedge(symbol, pairIndex);". Insert this directly underneath:

Code: Select all

         if (CloseAllAtBreakeven)
         {
            IsHedgedPositionAtBreakeven(symbol);
         }//if (CloseAllAtBreakeven)
Add this function somewhere convenient:

Code: Select all

void IsHedgedPositionAtBreakeven(string symbol)
{

   bool TradesCanClose = false;
   
   //Test for cash BE
   if (CashUpl >= HedgeProfitTargetCash)
      TradesCanClose = true;
      
   //Test for pips BE
   if (!TradesCanClose)
      if (PipsUpl >= HedgeProfitTargetPips)
         TradesCanClose = true;
   
   
   if (TradesCanClose)
   {
      CloseAllTrades(symbol, AllTrades);
      if (ForceTradeClosure)//An order closure failed, so force a retry at the next timer event
      {
         //Set both closure flags
         BuyClosureFailure = true;
         SellClosureFailure = true;
      }//if (ForceTradeClosure)
      
   
   }//if (TradesCanClose)
   
   

}//void IsHedgedPositionAtBreakeven(string symbol)
Go to void OnTimer() and search for, "//Deal with a closure failure". Copy this over the top of the existing block:

Code: Select all

      //Deal with a closure failure
      if (ForceTradeClosure)
      {
         //Rebuild a picture of the position
         CountOpenTrades(symbol);
         
         //A failed hedge breakeven failure
         if(BuyClosureFailure && SellClosureFailure)
         {
            CloseAllTrades(symbol, AllTrades);
         }//if(BuyClosureFailure && SellClosureFailure)
         else
         {
         
            if (BuyClosureFailure)
               CloseAllTrades(symbol, OP_BUY);
            
            if (SellClosureFailure)
               CloseAllTrades(symbol, OP_SELL);
         
         }//else
            
         if (ForceTradeClosure)
         {
            pairIndex--;
            continue;
         }//if (ForceTradeClosure)
         
         //Got here, so all closures succeeded
         BuyClosureFailure = false;
         SellClosureFailure = false;
         
      }//if (ForceTradeClosure)

: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
Gertje
Trader
Posts: 1936
Joined: Mon Dec 12, 2011 1:17 pm
Location: Middle of the Netherlands

Desky. TDesk's trading drone.

Post by Gertje »

SteveHopwood » Sun Feb 17, 2019 5:29 pm wrote:I have a present for Gertje. I have extended Peaky so that users can 'flip' the signal generated by the peak hilo. From the updated Peaky user guide:
  • There will be users who will want to trade long from the lower part of the chart even though the short cycle has not completed yet and there is no new peal low. They will also want to trade short from the top of the chart even though there is no new peak high. These two inputs allow this:
    • AllowSignalFlip: this causes Peaky to 'flip' the signal it displays and sends to TDesk:
      • short signal from the top two sixths of the chart even though there is no new peak high. Peaky will be displaying a long signal without the flip.
      • long signal from the bottom two sixths of the chart even though there is no new peak low. Peaky will be displaying a short signal without the flip.
    • NoSignalInMiddleOfChart: this tells Peaky to send TDesk a flat signal if the market is in the middle two sixths of the chart.
Download the latest from either the SPB thread or from Peaky's first home at http://www.stevehopwoodforex.com/phpBB3 ... 46#p161246

:xm: :rocket:
Thanks Steve,

Now it is up to me to get it to work..... :smile:
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.

Bloop alert

Post by SteveHopwood »

tutank just sent me another of my copy/paste/forgot-to-edit bloops. Fixed in post 1. Thanks tutank. :clap: :clap: :clap: :clap: :clap:

Easy DIY. Do a search for, "targetNoOfPendingTrades = GridSize - MarketBuysCount;//Not sure if this will give the correct figure." This will take you straight to the line of code that needs editing:
targetNoOfPendingTrades = GridSize - MarketBuysCount;

should be:
targetNoOfPendingTrades = GridSize - MarketSellsCount;

: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 have written a do it yourself for beginners guide. http://www.stevehopwoodforex.com/phpBB3 ... 92#p166292

: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 2w is in post 1.

Here are the details For you DIYers.

Remember to F7 at every step if you are new to this, to make sure you have not introduced a fault.

Go to the top of the file and do a search for, "GridTypes". There is an option in the list that is nonsense - Market_Orders. Delete this so the code looks like this:

Code: Select all

enum GridTypes
{
   Stop,
   Limit,
   Both,
};



Go to void SendBuyGrid(string symbol, int type, double price, double lot, int gridSize)
I noticed that a previous fix has gone missing, so this is something for you to check. Scroll down to:

Code: Select all

if (UseNextLevelForTP)//Set the tp at the open price of the next trade
If the next line is:
take = price;
It needs replacing with:
take = NormalizeDouble(price + (DistanceBetweenTrades / factor), digits);

I have added some more info to the order failure alert. Scroll down to the block of code starting with this comment:

Code: Select all

//Each trade in the grid must be sent, so deal with failures
Copy this over the top of the existing block:

Code: Select all

//Each trade in the grid must be sent, so deal with failures
      if (!result)
      {
         int err=GetLastError();
         if (err == 132)//Market is closed
            return;
         if (type == OP_BUYSTOP)
            Alert(symbol, " Buy stop failure: Lots ", lot, ": Price ", price, ": Ask ", ask, ": TP ", take, ": SL ", stop);
         else   
            Alert(symbol, " Buy limit failure: Lots ", lot, ": Price ", price, ": Ask ", ask, ": TP ", take, ": SL ", stop);
         Sleep(5000);
         cc--;
         continue;//Do not want price incrementing
      }//if (!result)
The next function down is void SendSellGrid(string symbol, int type, double price, double lot, int gridSize).
Again, if there is a "take = price" then it needs replacing with:
take = NormalizeDouble(price - (DistanceBetweenTrades / factor), digits);

Copy this over the top of the existing error reporting block:

Code: Select all

      //Each trade in the grid must be sent, so deal with failures
      if (!result)
      {
         int err=GetLastError();
         if (err == 132)//Market is closed
            return;
         if (type == OP_SELLSTOP)
            Alert("Sell stop: Lots ", lot, ": Price ", price, ": Bid ", bid, ": TP ", take, ": SL ", stop);
         else
            Alert("Sell limit: Lots ", lot, ": Price ", price, ": Bid ", bid, ": TP ", take, ": SL ", stop);
         Sleep(5000);
         cc--;
         continue;//Do not want price incrementing
      }//if (!result)
Go to void DoPendingOrdersDeletionAndReplacement(string symbol, int signal)
I was looking for other possible causes of the invalid stops thingy reported http://www.stevehopwoodforex.com/phpBB3 ... 95#p166295 and noticed that only stop order grids were replaced.

Scroll down to this comment:

Code: Select all

//Replace a pending order grid following a return to a trading signal.
This is the start of the code block that replaces pending trades following a return to LONG or SHORT after being FLAT. You will see this a few lines further down: "if (targetNoOfPendingTrades > 0)". You can see that only OP_BUYSTOP orders are sent. Copy this over the top of the existing block:

Code: Select all

            if (targetNoOfPendingTrades > 0)
            {
               //Stop orders
               if (TypeOfGrid == Stop || TypeOfGrid == Both)
                  SendBuyGrid(symbol, OP_BUYSTOP, HighestBuyPrice, Lot, targetNoOfPendingTrades); 
                  
               //Limit orders
               if (TypeOfGrid == Limit || TypeOfGrid == Both)
                  SendBuyGrid(symbol, OP_BUYLIMIT, LowestBuyPrice, Lot, targetNoOfPendingTrades); 
                                
            }//if (targetNoOfPendingTrades > 0)
Scroll down to the next "if (targetNoOfPendingTrades > 0)". Here you will see that only OP_SELLSTOP orders are sent. Replace the code block with:

Code: Select all

            if (targetNoOfPendingTrades > 0)
            {
               //Stop orders
               if (TypeOfGrid == Stop || TypeOfGrid == Both)
                  SendSellGrid(symbol, OP_SELLSTOP, LowestSellPrice, Lot, targetNoOfPendingTrades);               
            
               //Limit orders
               if (TypeOfGrid == Limit || TypeOfGrid == Both)
                  SendSellGrid(symbol, OP_SELLLIMIT, HighestSellLimitPrice, Lot, targetNoOfPendingTrades);               
            
            }//if (targetNoOfPendingTrades > 0)
Shrug your shoulders philosophically if you totally bugger things up, and download the fix from post 1.

: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.”