stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Desky. TDesk's trading drone.
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5545
Page 30 of 50
Author:  SteveHopwood [ Thu Apr 25, 2019 10:42 am ]
Post subject:  Desky. TDesk's trading drone.

An elementary coding bloop caused Desky to send short trades when the pair was in the BuyOnlyPairs list. This is fixed in post 1.

DIYers, do a search for: if (!checkBuyOnlyPairs(symbol) )

Remove the "!" so that the code is:
if (checkBuyOnlyPairs(symbol) )

:xm: :rocket:
Author:  SteveHopwood [ Thu Apr 25, 2019 1:21 pm ]
Post subject:  Desky. TDesk's trading drone.

V 3m is in post 1. You do not need this folks, if you are not using the swap filters.

Coders, I realised it is a mistake to try to operate the swap filters when SendBuy/SellGrid() is called. I have added these two variables:
bool buyGridAllowed=true, sellGridAllowed=true;

I have added this function:

Code: Select all

void gridTradeDirectionBySwap(string symbol)
{

   //There may be circumstances that I have not anticipated,  where Desky is coded to send grids without
   //checking the swap. I have added a call to this function to the top of SendBuyGrid() and SendSellGrid(),
   //so this function allows/disallows the grid to be sent. It is the code higher up the function
   buyGridAllowed = true;
   sellGridAllowed = true;

   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 (longSwap < 0) 
            buyGridAllowed = false;

         if (shortSwap < 0) 
            sellGridAllowed = 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 (longSwap < 0) 
            buyGridAllowed = false;

         if (shortSwap < 0) 
            sellGridAllowed = 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 (longSwap < 0) 
            buyGridAllowed = false;

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

      if (shortSwap < 0) 
         sellGridAllowed = false;
   }//if (OnlyTradePositiveSwap)
   
   //MaximumAcceptableNegativeSwap filter
   if (longSwap < MaximumAcceptableNegativeSwap) 
      buyGridAllowed = false;

   if (shortSwap < MaximumAcceptableNegativeSwap) 
      sellGridAllowed = false;      

   //Buy/sell only pairs.
   //Must not be in the sell only list
   if (checkSellOnlyPairs(symbol) )
      buyGridAllowed = false;

   //Must not be in the buy only list
   if (checkBuyOnlyPairs(symbol) )
      sellGridAllowed = false;


}//End void gridTradeDirectionBySwap(string symbol)
At the top of: void SendBuyGrid(string symbol, int type, double price, double lot, int gridSize)
I have added this:

Code: Select all

   //Swap check
   gridTradeDirectionBySwap(symbol);
   if (!buyGridAllowed)
      return;
At the top of: void SendSellGrid(string symbol, int type, double price, double lot, int gridSize)

Code: Select all

   //Swap check
   gridTradeDirectionBySwap(symbol);
   if (!sellGridAllowed)
      return;
:xm: :rocket:
Author:  SteveHopwood [ Thu Apr 25, 2019 3:59 pm ]
Post subject:  Desky. TDesk's trading drone.

There is a fresh update to 3m in post 1. This one is purely for the coders and DIYers; ignore it if you are not one of these. The update contains nothing new.

It has taken me a while to grasp why the more professional coders here begin variable and function definitions with a lower case letter - it makes the typing easier. I have been doing this myself for a little while so the source contained a mixture of old and new style.

I spent a couple of hours this afternoon standardising this so:
  • variables unseen by the user and function definitions begin with lower case, for example jumpingStop and void getBasics(string symbol). This makes typing easier.
  • extern inputs begin with an upper case because they will otherwise look odd to the user.
DIYers will be best off now to have a clean download of Desky.

:xm: :rocket:
Author:  kwchau [ Fri Apr 26, 2019 3:18 pm ]
Post subject:  Desky. TDesk's trading drone.

Hi Steve, I have tested the swap features of the latest version, everything seems running fine.
Thank you so much for fixing it !

cheers,
kwchau
Author:  SteveHopwood [ Fri Apr 26, 2019 5:25 pm ]
Post subject:  Desky. TDesk's trading drone.

kwchau ยป Fri Apr 26, 2019 3:18 pm wrote:Hi Steve, I have tested the swap features of the latest version, everything seems running fine.
Thank you so much for fixing it !

cheers,
kwchau
:party: :party: :party: :party: :party: :party: :!!: :!!: :!!: :!!: :!!: :!!:
Author:  SteveHopwood [ Wed May 01, 2019 1:35 pm ]
Post subject:  Desky. TDesk's trading drone.

V 3n is in post 1. This addresses a rare situation where a pair that is normally negative swap in one direction is temporarily at zero and so the bot can send trades in a direction that will cost a lot of swap when that swap reverts to its normal negative. You do not need the update if negative swap does not bother you.

DIYers, Desky needs an additional function, so the easiest is to delete the current void tradeDirectionBySwap(string symbol) function and replace it with this:

Code: Select all

bool CloseEnough(double num1,double num2)
{
/*
   This function addresses the problem of the way in which mql4 compares doubles. It often messes up the 8th
   decimal point.
   For example, if A = 1.5 and B = 1.5, then these numbers are clearly equal. Unseen by the coder, mql4 may
   actually be giving B the value of 1.50000001, and so the variable are not equal, even though they are.
   This nice little quirk explains some of the problems I have endured in the past when comparing doubles. This
   is common to a lot of program languages, so watch out for it if you program elsewhere.
   Gary (garyfritz) offered this solution, so our thanks to him.
   */

   if(num1==0 && num2==0) return(true); //0==0
   if(MathAbs(num1 - num2) / (MathAbs(num1) + MathAbs(num2)) < 0.00000001) return(true);

//Doubles are unequal
   return(false);

}//End bool CloseEnough(double num1, double num2)

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 (CloseEnough(longSwap, 0) )
               if (longSwap <= 0) 
                  buySignal = false;

         if (sellSignal)
            if (CloseEnough(shortSwap, 0) )
               if (shortSwap <= 0) 
                  sellSignal = false;
   }//if (OnlyTradePositiveSwap)
   
   //MaximumAcceptableNegativeSwap filter
   if (buySignal)
      if (longSwap < MaximumAcceptableNegativeSwap) 
         buySignal = false;
   
   if (sellSignal)
      if (shortSwap < MaximumAcceptableNegativeSwap) 
         sellSignal = false;      

   //Buy/sell only pairs.
   //Must not be in the sell only list
   if (buySignal)
      if (checkSellOnlyPairs(symbol) )
         buySignal = false;

   //Must not be in the buy only list
   if (sellSignal)
      if (checkBuyOnlyPairs(symbol) )
         sellSignal = false;


}//void tradeDirectionBySwap()
:xm: :rocket:
Author:  SteveHopwood [ Wed May 08, 2019 6:43 pm ]
Post subject:  Desky. TDesk's trading drone.

V 3o is in post 1.

Bill suggested the option to be able to control the direction of trading for individual pairs. I describe this as trading the 'bigger picture' in the updated user guide. Details in the guide.

There are two sets of csv inputs now, so I have also added prefix and suffix inputs so that users only have to enter the chart symbols into the inputs.

Note that 3o will demand that you use TDesk 6.6 to be able to work.

:xm: :rocket:
Author:  SteveHopwood [ Sat May 25, 2019 7:14 pm ]
Post subject:  Desky. TDesk's trading drone.

V 3p is in post 1.

This contains the same fix for the Recovery trades closure that I added to SPB.

Thomas wrote to me earlier in the week to point out that Desky was not filling in gaps when the market moves against the original trade(s). This should be fixed now.

I have added a small sub-section to the 'General inputs' - 'FX Testify'. Thomas asked me to add the two new inputs. I am not entirely sure what they are for apart from being something to do with developing the database. No doubt their purpose will become clearer in the future.

:xm: :rocket:
Author:  c1borg [ Sun May 26, 2019 8:43 am ]
Post subject:  Desky. TDesk's trading drone.

I am looking for some advice I am using TDesk's Trade Advice function and one of my setups shows I could get a big improvement by using option 3) in the attached screenshot. My question is (as I dont want to get this wrong) what specific settings do I need to input into Desky to achieve

S/L and T/P as percent of ATR (D1,14) T/P=200 percent
Capture.PNG
Any help advice appreciated.
Author:  tomele [ Sun May 26, 2019 9:17 am ]
Post subject:  Desky. TDesk's trading drone.

TakeProfitValue=200
SLTPCalcMode=ATRPercent

Cheers
Thomas
All times are UTC Page 30 of 50