Old and defunct Holy Graily Bob

EA's inspired by nanningbob's work here, especially those based on his 240 Moving Average trend detection filter.
Locked
4xtn
Trader
Posts: 26
Joined: Mon Aug 27, 2012 10:32 pm
Location: Dublin, Ireland

Holy Graily Bob

Post by 4xtn »

How about pending orders, but with user defined distance from PA?
BobbyT
Trader
Posts: 232
Joined: Thu Aug 21, 2014 1:34 am
Location: Seattle

Holy Graily Bob

Post by BobbyT »

I haven't looked at the code at all (so not sure if this is incorporated already) but maybe try using

Code: Select all

 MarketInfo(NULL,MODE_STOPLEVEL) 
in the calculations for where to place the first pending positions.
This way, broker specific stop levels can be autodetected and be dynamic within the code. It is also a one solution fits all brokers type situation once implemented.
I have a snippet at home that I used some time ago to ensure trades were beyond the stop level, but I'm at work at the moment. If your interested I can find it later though I'm sure you've either already thought of this or could conjure your own snippet anyway.

Cheers,
BobbyT
Procrastination provides exponentially negative returns - BobbyT
User avatar
oliverjp
Trader
Posts: 36
Joined: Mon May 06, 2013 8:39 am

Holy Graily Bob

Post by oliverjp »

Hi

I've had problems like this in the past when coding a news trader that tried to slip in orders just before news time when the prices and spreads went crazy and pending trades wouldn't take. I made my order placement code cycle through increasing stop loss values until it managed to place the order or it reached my maximum. I found half a pip extra each time and a maximum of 5 extra pips (so max 10 iterations) worked OK for that application.

Best regards

Jeff


SteveHopwood » Sun Dec 07, 2014 11:34 pm wrote:Ok, unlocking this thread.

Please do not post about failed trade sends. We know about them.

Trust me, I do not mean 'please'. You will not enjoy the result of posting another failed trade send.

Anybody here go any solutions?

:xm:
User avatar
oliverjp
Trader
Posts: 36
Joined: Mon May 06, 2013 8:39 am

Holy Graily Bob

Post by oliverjp »

Here you go, found an early variant of the code I wrote that did it. Sorry, can't find the later more polished version:

Code: Select all

//+------------------------------------------------------------------+
//| Initisl StopLoss                                             |
//+------------------------------------------------------------------+
void InitialStopLoss()
{
   int    Total, Ticket, retry;
   int    SLretries = 20;  
   double StopLoss;

   Total = OrdersTotal();

   for(int i = 0; i < Total; i++)
     {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))  
       {
       if (OrderSymbol() == ThisSymbol && OrderMagicNumber() == MagicNumber && TP1_Closed == FALSE && OrderStopLoss() == 0)
         {         
         if (OrderType() == OP_BUY)            //  Buy side processing
           {
           RefreshRates();
           StopLoss = NormalizeDouble(OrderOpenPrice() - (EntryToTP1_StopLossPips * Point * 10),Digits);                        
           if (OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,0,0,Red))
             { 
             Ticket = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);  
             Print("StopLoss set by InitialStopLoss to: ",OrderStopLoss());
             InitialSLSet = TRUE;
             }
           else  // Attempt to set SL failed - try harder half a pip further out each attempt
             {
             for (retry=1; retry<SLretries; retry++)
               {
               RefreshRates();
               StopLoss = NormalizeDouble(OrderOpenPrice() - ((EntryToTP1_StopLossPips + (0.5 * retry)) * Point * 10),Digits);                        
               if (OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,0,0,Red))
                 {
                 Ticket = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);  
                 Print("StopLoss set by InitialStopLoss DYNAMIC to: ",OrderStopLoss(), "   Needed ",retry/2," extra pips.");
                 InitialSLSet = TRUE;
                 break;
                 }
               }
             }
           
           if (InitialSLSet == FALSE)
             {           
             if (OrderClose(OrderTicket(),OrderLots(),Bid,500,Red))  Print("InitialStopLoss KILLED Buy order as Initial SL could not be set!");
             else Print(strModifyError,GetLastError(),"   WARNING! - InitialStopLoss FAILED TO KILL Buy order when SL could not be set!");
             }
           }             
                   
         else if  (OrderType() == OP_SELL)           // Sell side processing
           {
           RefreshRates();
           StopLoss = NormalizeDouble(OrderOpenPrice() + (EntryToTP1_StopLossPips * Point * 10),Digits);                        
           if (OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,0,0,Red))
             {
             Ticket = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);  
             Print("StopLoss set by InitialStopLoss to: ",OrderStopLoss());
             InitialSLSet = TRUE;
             }
           else  // Attempt to set SL failed - try harder half a pip further out each attempt
             {
             for (retry=1; retry<SLretries; retry++)
               {
               RefreshRates();
               StopLoss = NormalizeDouble(OrderOpenPrice() + ((EntryToTP1_StopLossPips + (0.5 * retry)) * Point * 10),Digits);                        
               if (OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,0,0,Red))
                 {
                 Ticket = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);  
                 Print("StopLoss set by InitialStopLoss DYNAMIC to: ",OrderStopLoss(), "   Needed ",retry/2," extra pips.");
                 InitialSLSet = TRUE;
                 break;
                 }
               }
             }
           if (InitialSLSet == FALSE)
             {           
             if (OrderClose(OrderTicket(),OrderLots(),Bid,500,Red))  Print("InitialStopLoss KILLED Sell order as Initial SL could not be set!");
             else Print(strModifyError,GetLastError(),"   WARNING! - InitialStopLoss FAILED TO KILL Sell order when SL could not be set!");
             }
           }
         }  
       }
     }
                  
return;
}

oliverjp » Mon Dec 08, 2014 7:56 am wrote:Hi

I've had problems like this in the past when coding a news trader that tried to slip in orders just before news time when the prices and spreads went crazy and pending trades wouldn't take. I made my order placement code cycle through increasing stop loss values until it managed to place the order or it reached my maximum. I found half a pip extra each time and a maximum of 5 extra pips (so max 10 iterations) worked OK for that application.

Best regards

Jeff


SteveHopwood » Sun Dec 07, 2014 11:34 pm wrote:Ok, unlocking this thread.

Please do not post about failed trade sends. We know about them.

Trust me, I do not mean 'please'. You will not enjoy the result of posting another failed trade send.

Anybody here go any solutions?

:xm:
User avatar
BritShrtHair
Trader
Posts: 13
Joined: Mon Apr 16, 2012 6:37 am

Holy Graily Bob

Post by BritShrtHair »

SteveHopwood » Sun Dec 07, 2014 11:34 pm wrote:Ok, unlocking this thread.
Anybody here go any solutions?
in HGB, when replacing line 1878 (void LookForTradingOpportunities())

Code: Select all

double SendLots = 0;
with

Code: Select all

double SendLots = MarketInfo(Symbol(),MODE_MINLOT);
HGB seems to start taking trades again.
Thats seems to be (one of the?) culprits.
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.

Holy Graily Bob

Post by SteveHopwood »

V 1l is in post 1.

Thanks guys. You put me on the right track.

You know how these problems are usually copy/paste/fail-to-edit bloops? This time they were copy-but-didn't-quite-copy-enough/paste/edit bloops.

HGB is taking the pending trades now.

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

Holy Graily Bob

Post by SteveHopwood »

Don't bother downloading 1L folks. Still isn't right.

:xm:
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.
BobbyT
Trader
Posts: 232
Joined: Thu Aug 21, 2014 1:34 am
Location: Seattle

Holy Graily Bob

Post by BobbyT »

Lucky I decided to have dinner before upating :smile:
Procrastination provides exponentially negative returns - BobbyT
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.

Holy Graily Bob

Post by SteveHopwood »

V 1m is in post 1. We appear to be fully functional now, but take nothing for granted. :arrrg:

:xm:
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.
Lee
Trader
Posts: 27
Joined: Mon Sep 30, 2013 8:33 am

Holy Graily Bob

Post by Lee »

SteveHopwood » Mon Dec 08, 2014 10:33 am wrote:V 1m is in post 1. We appear to be fully functional now, but take nothing for granted. :arrrg:

:xm:
Steve,

Thanks for your brilliant work. The highlighted line I believe should read 'RAD trade multiple positions' instead of 'Trend'? Just to avoid confusion.

Lee
You do not have the required permissions to view the files attached to this post.
Locked

Return to “Thingy Bob EA's”