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 »

V 2x is in post 1, in response to a PM from Thomas about this scenario:
GBPJPYH1.png
It would have been great if Desky had added to the grid as the market rose, so 2x facilitates this. From the updated UG:
  • 'Rolling' grid inputs: imagine this scenario. All your buy stop orders have filled and the market has screamed to the stars. This feature tells Desky to add a new stop order grid to take advantage of the market moving so strongly in your favour:
    • RollingGrid: turns this feature on/off.
    • MaxRolledTrades: this limits the number of trades to open market trades + GridSize.
DIYers, scroll down to/search for "extern string gri="---- Grid inputs ----";" The new inputs are:

Code: Select all

//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;
I have rearranged the order of some of the inputs and added some headings, so copy this over the whole of the grid inputs if you want yours to look like mine:

Code: Select all

extern string  sep3="================================================================";
extern string  gri="---- Grid inputs ----";
extern string  ggi="-- General grid inputs --";
extern bool    UseGridTrading=false;
extern GridTypes TypeOfGrid=Both;
extern int     GridSize=5;
extern int     DistanceBetweenTradesPips=30;
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;
extern string  gtp="-- 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;
////////////////////////////////////////////////////////////////////////////////////////
Go to the void DoPendingOrdersDeletionAndReplacement(string symbol, int signal) function. Add ", pairIndex" to the list of parameters inside the brackets, so it looks like this:
void DoPendingOrdersDeletionAndReplacement(string symbol, int signal, int pairIndex)

Press F7 and double click the resulting error message to take you to this line of code:
DoPendingOrdersDeletionAndReplacement(symbol, signal);

Add the same parameter so the code looks like this:
DoPendingOrdersDeletionAndReplacement(symbol, signal, pairIndex);

Go back to void DoPendingOrdersDeletionAndReplacement(string symbol, int signal, int pairIndex). Scroll down to this comment: "//if (UseGridTrading)" - comments are preceded by // and are in grey text. Insert this code above the comment:

Code: Select all

      //Rolling grid. I have applied this to stop orders only - limit orders would not make sense.
      if (RollingGrid)//Are we using this feature?
         if (IsTradingAllowed(symbol, pairIndex) )//Make sure there is nothing to stop us trading eg spread
            if (MarketTradesTotal > 0)//There are open trades
               if (MarketTradesTotal + GridSize <= MaxRolledTrades)//A new grid will not exceed our maximum allowed
               {   
                  //Buy grid
                  if (BuyOpen)//There are market buy trades
                  {
                     //Buy grid
                     if (BuyStopsCount == 0)
                     {
                        SendBuyGrid(symbol, OP_BUYSTOP, HighestBuyPrice, Lot, GridSize); 
                     }//if (BuyStopsCount == 0)
                  }//if (BuyOpen)
                  
                  //Sell grid
                  if (SellOpen)//There are market sell trades
                  {
                     //Sell grid
                     if (SellStopsCount == 0)
                     {
                        SendSellGrid(symbol, OP_SELLSTOP, LowestSellPrice, Lot, GridSize); 
                     }//if (SellStopsCount == 0)
                  }//if (SellOpen)
                  
               }//if (MarketTradesTotal + GridSize <= MaxRolledTrades)//A new grid will not exceed our maximum allowed
:rocket:
You do not have the required permissions to view the files attached to this post.
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.

Bloop alert

Post by SteveHopwood »

tutank again. Thanks tutank. :clap: :clap: :clap:

I have added the fix to 2x.

The DIY could not be simpler. Search for this line of code:
SendSellGrid(symbol, OP_SELLLIMIT, HighestSellLimitPrice, Lot, targetNoOfPendingTrades);

Remove "Limit" from the variable highlighted in blue.

Your code should look like this now:
SendSellGrid(symbol, OP_SELLLIMIT, HighestSellPrice, Lot, targetNoOfPendingTrades);

: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 »

littlereddot just emailed with an error created by the RollingGrid feature. Thanks. Fixed in post 1.

To DIY, search for "if (RollingGrid)//Are we using this feature?"


Scroll down a few lines until you reach this line of code:
SendBuyGrid(symbol, OP_BUYSTOP, HighestBuyPrice, Lot, GridSize);

This needs changing to:
SendBuyGrid(symbol, OP_BUYSTOP, ask, Lot, GridSize);

Scroll down a few more lines to reach:
SendSellGrid(symbol, OP_SELLSTOP, LowestSellPrice, Lot, GridSize);

This needs changing to:
SendSellGrid(symbol, OP_SELLSTOP, bid, Lot, GridSize);

: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 »

A little bit of DIY housekeeping folks, that I will include in the next release coming soon. This is something I noticed whilst adding offsetting to something I am coding for pipcruiser.

Go to void OnDeinit(const int reason) and add these two lines of code:

Code: Select all

   ArrayFree(BuyTickets);
   ArrayFree(SellTickets);
That makes sure the memory is released when you shut down the platform.

Then go to void CountOpenTrades(string symbol) and add this somewhere at the top:

Code: Select all

   //Offsetting
   ArrayFree(BuyTickets);
   ArrayFree(SellTickets);
   ArrayResize(BuyTickets, 0);
   ArrayResize(SellTickets, 0);
The array will get bigger and bigger with every call to COT, which is why freeing it is necessary. I am not sure if the resize is needed; I include it because I do not fully understand how Empty4 deals with arrays.

: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 »

Another fabulous spot by tutank. I will release the fix in the next version but it is an easy fix for a quick DIY. There are two lines of code that are in the wrong place.

Do a search for: "MarketSellsCount++;"
This is too high, so remove it then look down about 5 lines for this comment:
"//In case the position needs Recovery" and insert MarketSellsCount++; immediately above, like this:

Code: Select all

            MarketBuysCount++;
            //In case the position needs Recovery
Then do a search for, "MarketSellsCount++;" and repeat the process. Your code will look like this:

Code: Select all

            MarketSellsCount++;
            //In case the position needs Recovery
Thanks very much tutank. You are a huge help. :clap: :clap: :clap: :clap: :clap:

: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 »

Another quick DIY bloop fix. This one is in the rolling grid code that I noticed whilst adding another feature. The bloop allows Desky to exceed the maximum of trades by the size of the original grid.

Do a search for,"if (MarketTradesTotal + GridSize <= MaxRolledTrades)//A new grid will not exceed our maximum allowed". Make sure it is not the greyed out comment that marks the end of the block.

The code bit is:
if (MarketTradesTotal + GridSize <= MaxRolledTrades)

It needs to be:
if (MarketTradesTotal + GridSize <= (MaxRolledTrades - GridSize) )

This fix will be included in the next release.

: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 2y is in post 1. This includes those little fixes that emerged last week.

Thomas had a great idea, so there is a new input in the rolling grid section. From the updated UG:
  • CloseGridAtMrtPlusOneLevel: this tells Desky to close all the trades on the chart when MaxRolledTrades have filled and the market has progressed one level further. The idea is to bank the profits before the inevitable retrace as the market has moved a long way in our favour.
: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
c1borg
Trader
Posts: 456
Joined: Sun Aug 14, 2016 5:09 pm

Desky. TDesk's trading drone.

Post by c1borg »

SteveHopwood » Sun Mar 03, 2019 11:40 am wrote:V 2y is in post 1. This includes those little fixes that emerged last week.

Thomas had a great idea, so there is a new input in the rolling grid section. From the updated UG:
  • CloseGridAtMrtPlusOneLevel: this tells Desky to close all the trades on the chart when MaxRolledTrades have filled and the market has progressed one level further. The idea is to bank the profits before the inevitable retrace as the market has moved a long way in our favour.
:xm: :rocket:
That's a great idea and has happened to me more than once :good:
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.

Oops

Post by SteveHopwood »

Folks, tutank just spotted a howler. We are talking bog-standard basic balls up here. :arrrg: :arrrg: :arrrg: :arrrg: :arrrg: :arrrg: :arrrg: Fixed in 2z in post 1.

Easiest DIY ever.

Do a search for:
SendBuyGrid(symbol, OP_BUYSTOP, Ask, Lot, GridSize);

Replace it with:
SendBuyGrid(symbol, OP_BUYSTOP, ask, Lot, GridSize);

You have probably guessed the next bit. Do search for:
SendSellGrid(symbol, OP_SELLSTOP, Bid, Lot, GridSize);

Replace it with:
SendSellGrid(symbol, OP_SELLSTOP, bid, Lot, GridSize);

Folks, it is often easier to do a quick DIY than it is to download and replace the fixed version. No idea how to? I have written a guide and you can find it at http://www.stevehopwoodforex.com/phpBB3 ... 92#p166292.

I am going to start writing an, "Understanding what you are Doing For Yourselves" guide. It will take a while but will eventually add to your understanding of all this stuff.

Thanks again tutank. I am deeply grateful for your attention to detail. :clap: :clap: :clap: :clap: :clap: :clap: :clap:

: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
c1borg
Trader
Posts: 456
Joined: Sun Aug 14, 2016 5:09 pm

Desky. TDesk's trading drone.

Post by c1borg »

I have this repeating error no idea if its a bug.
2019.03.05 09:19:18.332 TDesk Trading Partner EAz XAUUSD,H1: Alert: Sell stop: Lots 0.01: Price 0.6802: Bid 0.6795600000000001: TP 0.0: SL 0.0
2019.03.05 09:19:18.320 TDesk Trading Partner EAz XAUUSD,H1: NZDUSD TDesk Trading Partner EAz OP_SELLSTOP order send failed with error(130): invalid stops
Could be my mistake and im certainly not proficient enough as a coder to spot this yet, however I will attempt to figure it out.

Analysis so far, I have 1 NZDUSD trade active and no pending trades. I am also using the new Rolling Grid feature set to enabled and so I tried to disable that feature but it still happens. Im also using the feature on another demo with no issues. My observation is It seems to be attempting to place the trade above the current one, is that a clue.
Capture.PNG
Capture1.png
Edit......

Ok tracked it down to the setting UseAtrForGrid which I have set to true with the default settings seems to be causing the problem.
  • UseGridTrading=true
    TypeOfGrid=0
    GridSize=3
    DistanceBetweenTradesPips=125
    UseAtrForGrid=true
    GridAtrTimeFrame=1440
    GridAtrPeriod=20
    GridAtrDivisor=5.0
I need to adjust my ATR settings any recommendations?
You do not have the required permissions to view the files attached to this post.
Post Reply

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