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

Desky. TDesk's trading drone.
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5545
Page 19 of 50
Author:  SteveHopwood [ Sun Jan 20, 2019 3:00 pm ]
Post subject:  Desky. TDesk's trading drone.

Version 2p is in post 1, with implementations of simple and complex single-sided offsetting.

Attached is an extract from the updated user guide, describing the functionality I have added.

:xm: :rocket:
Author:  c1borg [ Tue Jan 22, 2019 4:30 pm ]
Post subject:  Desky. TDesk's trading drone.

I am having issues with version p removing itself when initialising, anyone else had any issues or is it something stupid I may be doing? Version o loads and runs perfectly.
Capture.PNG
Author:  Alexfirst [ Tue Jan 22, 2019 4:35 pm ]
Post subject:  Desky. TDesk's trading drone.

I have this issue too.
Author:  SteveHopwood [ Tue Jan 22, 2019 4:55 pm ]
Post subject:  Desky. TDesk's trading drone.

I knew what I had done straight away - fixed in post 1. This problem would arise immediately the bot took a trade or was loaded with open trades.

Easy DIY vix: Do a search for
return(BetterOrderSelect(index,select,pool));

Replace it with:
return(OrderSelect(index,select,pool));

I originally lifted the offsetting code from HGBnD, an EA I wrote before Thomas provided the BetterOrderSelect() function. The bloop causes a stack overflow and causes the bot to resign in protest.

All your unsupervised VPS demos will have this problem.

:xm: :rocket:
Author:  Alexfirst [ Tue Jan 22, 2019 5:03 pm ]
Post subject:  Desky. TDesk's trading drone.

Thanks for a fast fix, Steve. And for offsetting feature!
Author:  c1borg [ Tue Jan 22, 2019 5:13 pm ]
Post subject:  Desky. TDesk's trading drone.

:yahoo: :yahoo:
Author:  luipogifx [ Fri Jan 25, 2019 8:41 am ]
Post subject:  Desky. TDesk's trading drone.

Hello Steve,

I'm currently testing 2p. It keeps on opening and closing pending trades.

My active settings are:
Grid trading
Useoffsetting simple mode
Hedge on opposite signal
Delete pending trades on opposite signal

The affected currency pair is EURCAD, and it currently has a sell hedge trade.

I'm currently traveling and I only use phone to access my VPS.

Seems like it will keep on opening and closing pending trades when the super signal is in the direction of the hedge trade. It will stop closing and pending trades when the signal is flat.

I will observe more.
Author:  SteveHopwood [ Mon Jan 28, 2019 8:54 pm ]
Post subject:  Desky. TDesk's trading drone.

V 2q is in post 1, with the fix for the pending orders stuff that c1borg posted in the 'Confused' thread - http://www.stevehopwoodforex.com/phpBB3 ... 29#p165929

I could not believe the bollocks I had coded when I looked at it in response to c1borg's thread.

I do have an excuse. Any of us who have developed as self-taught coders will find the same thingy here. How to code something does not tend to be difficult - CrapQl4 is a very simple language. It is the what to code that can be a bit of a bugger to work out.

It is quite some time since I last worked out the what to code quite as badly as this little lot.

There was no need to update the user guide. The new inputs should be self-explanatory.

DIYers, do this:
Do a search for: "enum PendingTradeTypes". It is only a few lines down. Copy this over the top of the existing code block:

Code: Select all

enum PendingTradeTypes
{
   Stop_order_only,
   Limit_order_only,
   Stop_and_Limit_orders,
};
Then do a search for: "extern PendingTradeTypes TypeOfPendingTrade=". I cannot remember what the original default was, so change it to:
extern PendingTradeTypes TypeOfPendingTrade=Stop_order_only;


Then search for, "void CanWeSendTrades(string symbol, int pairIndex, int signal)" to navigate to the relevant function. Easiest is to simply copy this over the top of the existing function:

Code: Select all

void CanWeSendTrades(string symbol, int pairIndex, int signal)
{

   bool result = false;
   
   if (!hedged)
      if (!StopTrading)
      {
         if (TimeCurrent() >= TimeToStartTrading[pairIndex])
         {
            if (OpenTrades < MaxTradesAllowed)
            {
               if (BuySignal || SellSignal)
               {
                 if (BuySignal)
                 {
                     //Immediate market trade
                     if (SendImmediateMarketTrade)
                        result = LookForTradingOpportunities(symbol, pairIndex, OP_BUY);
                     
                     //Pending orders
                     if (SendPendingTrades)
                     {
                        if (TypeOfPendingTrade == Stop_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYSTOP);
                           
                        if (TypeOfPendingTrade == Limit_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYLIMIT);
                           
                        if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        {
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYSTOP);
                           
                           Sleep(5000);//Give the platform time to catch up
                           
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYLIMIT);
                        }//if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        
                           
                     }//if (SendPendingTrades)
                     
                     
                     if (UseGridTrading && (SendImmediateMarketTrade || SendPendingTrades))
                        if (result)
                        {
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYSTOP, ask, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                           
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYLIMIT, ask, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                           
                        }//if (result)
                     
                  }//if (BuySignal)

                     
                  if (SellSignal)
                  {
                     
                     //Immediate market trade
                     if (SendImmediateMarketTrade)   
                        result = LookForTradingOpportunities(symbol, pairIndex, OP_SELL);
                     
                     //Pending orders
                     if (SendPendingTrades)
                     {
                        if (TypeOfPendingTrade == Stop_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLSTOP);
                           
                        if (TypeOfPendingTrade == Limit_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLLIMIT);
                           
                        if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        {
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLSTOP);
                           
                           Sleep(5000);//Give the platform time to catch up
                           
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLLIMIT);
                        }//if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        
                           
                     }//if (SendPendingTrades)

                     if (UseGridTrading && (SendImmediateMarketTrade || SendPendingTrades))
                        if (result)
                        {
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLSTOP, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_SELLSTOP || TypeOfGrid == Both)
                           
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLLIMIT, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                           
                        }//if (result)
                     
                  }//if (SellSignal)
                  
                     
                  //This takes care of grid trading only.
                  if (!SendImmediateMarketTrade && !SendPendingTrades)
                     if (UseGridTrading)
                     {
                        if (BuySignal)
                        {
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYSTOP, ask, Lot, GridSize );
                           }//if (TypeOfGrid == Stop || TypeOfGrid == Both)
                                 
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYLIMIT, ask, Lot, GridSize );
                           }//if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           
                        }//if (BuySignal)
                        
                        if (SellSignal)
                        {  
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLSTOP, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_SELLSTOP || TypeOfGrid == Both)
                           
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLLIMIT, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                        }//if (SellSignal)
                        
                     }//if (UseGridTrading)
                       
                     
               }//if (BuySignal || SellSignal)
               
            }//if (OpenTrades < MaxTradesAllowed)
            
         }//if (TimeCurrent() >= TimeToStartTrading[PairIndex])
      }//if (!StopTrading)
     



}//End void CanWeSendTrades(string symbol, int signal)

Thanks for your persistence c1borg. :clap: :clap: :clap: I cannot test every permutation available to Desky, or consider every moment of personal lunacy. I rely on the likes of you to point them out.

:xm: :rocket:
Author:  c1borg [ Tue Jan 29, 2019 5:13 am ]
Post subject:  Desky. TDesk's trading drone.

SteveHopwood ยป Mon Jan 28, 2019 8:54 pm wrote:V 2q is in post 1, with the fix for the pending orders stuff that c1borg posted in the 'Confused' thread - http://www.stevehopwoodforex.com/phpBB3 ... 29#p165929

I could not believe the bollocks I had coded when I looked at it in response to c1borg's thread.

I do have an excuse. Any of us who have developed as self-taught coders will find the same thingy here. How to code something does not tend to be difficult - CrapQl4 is a very simple language. It is the what to code that can be a bit of a bugger to work out.

It is quite some time since I last worked out the what to code quite as badly as this little lot.

There was no need to update the user guide. The new inputs should be self-explanatory.

DIYers, do this:
Do a search for: "enum PendingTradeTypes". It is only a few lines down. Copy this over the top of the existing code block:

Code: Select all

enum PendingTradeTypes
{
   Stop_order_only,
   Limit_order_only,
   Stop_and_Limit_orders,
};
Then do a search for: "extern PendingTradeTypes TypeOfPendingTrade=". I cannot remember what the original default was, so change it to:
extern PendingTradeTypes TypeOfPendingTrade=Stop_order_only;

Then search for, "void CanWeSendTrades(string symbol, int pairIndex, int signal)" to navigate to the relevant function. Easiest is to simply copy this over the top of the existing function:

Code: Select all

void CanWeSendTrades(string symbol, int pairIndex, int signal)
{

   bool result = false;
   
   if (!hedged)
      if (!StopTrading)
      {
         if (TimeCurrent() >= TimeToStartTrading[pairIndex])
         {
            if (OpenTrades < MaxTradesAllowed)
            {
               if (BuySignal || SellSignal)
               {
                 if (BuySignal)
                 {
                     //Immediate market trade
                     if (SendImmediateMarketTrade)
                        result = LookForTradingOpportunities(symbol, pairIndex, OP_BUY);
                     
                     //Pending orders
                     if (SendPendingTrades)
                     {
                        if (TypeOfPendingTrade == Stop_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYSTOP);
                           
                        if (TypeOfPendingTrade == Limit_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYLIMIT);
                           
                        if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        {
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYSTOP);
                           
                           Sleep(5000);//Give the platform time to catch up
                           
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_BUYLIMIT);
                        }//if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        
                           
                     }//if (SendPendingTrades)
                     
                     
                     if (UseGridTrading && (SendImmediateMarketTrade || SendPendingTrades))
                        if (result)
                        {
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYSTOP, ask, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                           
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYLIMIT, ask, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                           
                        }//if (result)
                     
                  }//if (BuySignal)

                     
                  if (SellSignal)
                  {
                     
                     //Immediate market trade
                     if (SendImmediateMarketTrade)   
                        result = LookForTradingOpportunities(symbol, pairIndex, OP_SELL);
                     
                     //Pending orders
                     if (SendPendingTrades)
                     {
                        if (TypeOfPendingTrade == Stop_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLSTOP);
                           
                        if (TypeOfPendingTrade == Limit_order_only)
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLLIMIT);
                           
                        if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        {
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLSTOP);
                           
                           Sleep(5000);//Give the platform time to catch up
                           
                           result = LookForTradingOpportunities(symbol, pairIndex, OP_SELLLIMIT);
                        }//if (TypeOfPendingTrade == Stop_and_Limit_orders)
                        
                           
                     }//if (SendPendingTrades)

                     if (UseGridTrading && (SendImmediateMarketTrade || SendPendingTrades))
                        if (result)
                        {
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLSTOP, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_SELLSTOP || TypeOfGrid == Both)
                           
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLLIMIT, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                           
                        }//if (result)
                     
                  }//if (SellSignal)
                  
                     
                  //This takes care of grid trading only.
                  if (!SendImmediateMarketTrade && !SendPendingTrades)
                     if (UseGridTrading)
                     {
                        if (BuySignal)
                        {
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYSTOP, ask, Lot, GridSize );
                           }//if (TypeOfGrid == Stop || TypeOfGrid == Both)
                                 
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendBuyGrid(symbol, OP_BUYLIMIT, ask, Lot, GridSize );
                           }//if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           
                        }//if (BuySignal)
                        
                        if (SellSignal)
                        {  
                           if (TypeOfGrid == Stop || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLSTOP, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_SELLSTOP || TypeOfGrid == Both)
                           
                           if (TypeOfGrid == Limit || TypeOfGrid == Both)
                           {
                              SendSellGrid(symbol, OP_SELLLIMIT, bid, Lot, GridSize );
                           }//if (TypeOfGrid == OP_BUYSTOP || TypeOfGrid == Both)
                        }//if (SellSignal)
                        
                     }//if (UseGridTrading)
                       
                     
               }//if (BuySignal || SellSignal)
               
            }//if (OpenTrades < MaxTradesAllowed)
            
         }//if (TimeCurrent() >= TimeToStartTrading[PairIndex])
      }//if (!StopTrading)
     

}//End void CanWeSendTrades(string symbol, int signal)
Thanks for your persistence c1borg. :clap: :clap: :clap: I cannot test every permutation available to Desky, or consider every moment of personal lunacy. I rely on the likes of you to point them out.

:xm: :rocket:
As usual you come up with the goods :clap: thats more than enough for me thanks yet again. I am actually starting to look into the code because of this :shock: so hopefully will learn something.
Author:  c1borg [ Tue Jan 29, 2019 6:27 am ]
Post subject:  Desky. TDesk's trading drone.

Early days as regards to testing ver q but so far only getting Buy side trades and orders, no Sell? Will report back later.

Update..... Sell trades working :hi:
All times are UTC Page 19 of 50