Holy Graily Bob 'n Grid

EA's inspired by nanningbob's work here, especially those based on his 240 Moving Average trend detection filter.
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.

Holy Graily Bob 'n Grid

Post by SteveHopwood »

Kevin wrote to me again last night with another bloop he found in the code. :clap: :clap: :clap:

V 2c is in post 1. The change is tiny but ridiculously significant for those of us relying on semafor signal closures.

To make the change yourselves, line 2116
if (OldM1SemTime != iTime(Symbol(), TradingTimeFrame, 0))

becomes
if (OldM1SemTime != iTime(Symbol(), PERIOD_M1, 0))

then replace TradingTimeFrame with PERIOD_M1 in line 2118 as well.


PERIOD_M1 is a mql4 'constant' that holds the value 1. Try typing it out instead of copy/pasting and the editor will show you a list of PERIOD constants.

: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.
k3v1n0s
Trader
Posts: 27
Joined: Mon Jan 13, 2014 8:50 pm
Location: Luxembourg

Holy Graily Bob 'n Grid

Post by k3v1n0s »

Thanks Steve for allowing me to somehow contribute.

Those are my results this week on my live account, and I was playing around (trying different settings) until tuesday evening. :smile: So mostly, from wednesday on, I left HGB'nG trading 10 pairs, OOTB, but trading the thursday candle enabled and breakeven and jumpingstop disabled.
results.PNG
Should I consider leaving my day job? Just kidding. :smile:

Let's be patient and humble.

Cheers,

Kevin
You do not have the required permissions to view the files attached to this post.
pt2004
Trader
Posts: 40
Joined: Sun Nov 27, 2011 3:12 pm
Location: Portugal

Holy Graily Bob 'n Grid

Post by pt2004 »

Hello,

Do you use any trade manager, partial close?

Cheers

PT

k3v1n0s » Sat Mar 05, 2016 2:48 pm wrote:Thanks Steve for allowing me to somehow contribute.

Those are my results this week on my live account, and I was playing around (trying different settings) until tuesday evening. :smile: So mostly, from wednesday on, I left HGB'nG trading 10 pairs, OOTB, but trading the thursday candle enabled and breakeven and jumpingstop disabled.



Should I consider leaving my day job? Just kidding. :smile:

Let's be patient and humble.

Cheers,

Kevin
k3v1n0s
Trader
Posts: 27
Joined: Mon Jan 13, 2014 8:50 pm
Location: Luxembourg

Holy Graily Bob 'n Grid

Post by k3v1n0s »

Hi PT,

Nope, after tuesday evening (and that's when almost all the action of this week happened) I left HGB'nG handsfree, closing out trades by himself. Before that, I was closing manually and trying different settings.

Cheers,

Kevin
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 'n Grid

Post by SteveHopwood »

Live, lost pips but gained cash:
Lost pips gained cash.png
---------------------------------------------------------------------

I know some of you are interested in my multi-pairs un-interfered with demo:
Full on.png
This is one week of trading.

HGB is loaded onto all the pairs offered by the 'Open Charts in Alphabetical Order Indicator'. Start balance $5,000 so lots 0.05. Current balance $6,160 but the open position takes the equity down to $5915. There are some 0.06 lot trades in there, so the equity has also been over £6,000 at some point.

Amazing to see the pips generated by just 5 trades across the three best performers. Time to expand the pairs on my live account, methinks. :yahoo:

I am beginning to hope that we might attain the holy grail of an EA that can be left mostly to its own devices. Would that be a triumph, or what?

:xm:
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.
pt2004
Trader
Posts: 40
Joined: Sun Nov 27, 2011 3:12 pm
Location: Portugal

Holy Graily Bob 'n Grid

Post by pt2004 »

Ok,

Thank you.

Will try this next week.

Cheers

PT
k3v1n0s » Sat Mar 05, 2016 3:08 pm wrote:Hi PT,

Nope, after tuesday evening (and that's when almost all the action of this week happened) I left HGB'nG handsfree, closing out trades by himself. Before that, I was closing manually and trying different settings.

Cheers,

Kevin
Peepaws
Trader
Posts: 121
Joined: Thu Nov 27, 2014 11:19 pm

Holy Graily Bob 'n Grid

Post by Peepaws »

SteveHopwood » Sat Mar 05, 2016 2:30 pm wrote:Live, lost pips but gained cash:


---------------------------------------------------------------------

I know some of you are interested in my multi-pairs un-interfered with demo:


This is one week of trading.

HGB is loaded onto all the pairs offered by the 'Open Charts in Alphabetical Order Indicator'. Start balance $5,000 so lots 0.05. Current balance $6,160 but the open position takes the equity down to $5915. There are some 0.06 lot trades in there, so the equity has also been over £6,000 at some point.

Amazing to see the pips generated by just 5 trades across the three best performers. Time to expand the pairs on my live account, methinks. :yahoo:

I am beginning to hope that we might attain the holy grail of an EA that can be left mostly to its own devices. Would that be a triumph, or what?

:xm:

I am so impressed by everyone's results with HGBnG and so thankful to Steve, Bob, Cyber, and everyone else involved in making HGI and the HGB bots to trade it. I will soon be able to fund a GP account which is what I've been waiting for, for the last year. Anyone using a broker other than Global Prime I would urge you to switch if at all possible. I've been trading with another broker and paying far more for the fixed spreads they offer, which basically kills the profits of any EA I try, while the profits pour in on my GP demo.

Steve I think this EA is a Triumph already and I am very grateful for all the hard work that has gone in to it.

I can't wait to be able to give back to you monitarily but in the meantime you will have to accept my thanks!

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

Holy Graily Bob 'n Grid

Post by SteveHopwood »

V 2d is in post 1.

Kevin is rapidly developing star status so far as I am concerned. :clap: :clap: :clap: I had noticed that replacement grids were not always being sent as required, and had used the grid-send/remove the ea feature a couple of times on Friday to replace them. I assumed I had something wrong in my own settings and was going to investigate this weekend.

Kevin noticed the same and went digging. He saw that the replacements were in fact being sent, but then instantly deleted. He did some more digging and found some flaws in the program logic that were causing the problems. 2d contains his fixes. They make total sense to me.

Go to void ShouldTradesBeClosed() at line 3840 if you want to make your own changes, and copy this replacement over the top of the entire function:

Code: Select all

void ShouldTradesBeClosed()
{
       
   if (OpenTrades == 0)
      return;//Nothing to do

   int tries = 0;
   //We only want trades closing if the trades are based on a previous candle's signal
   if (LatestTradeTime < iTime(Symbol(), TradingTimeFrame, 0) )
   {
      
      //Opposite direction semafor
      //Close buys
      if (CloseTradesOnRelevantSemafor || CloseImmediatelySemaforAppears)//semafor
      {
            //SemStatus will only == highsemafor or highsemafornow if CloseImmediatelySemaforAppears is enabled
            if (SemStatus == highsemafor || SemStatus == highsemafornow)
            {
               tries = 0;
               //Close buys
               if (BuyOpen && (!CloseOnlyInPositivePips || BuyPipsUpl > 0))
               {
                  ForceTradeClosure = true;
                  while (ForceTradeClosure)
                  {
                     CloseAllTrades(OP_BUY);
                     CloseAllTrades(OP_BUYSTOP);
                     if (DeleteAndReplaceLosersGrid || !SellOpen)
                        CloseAllTrades(OP_SELLSTOP);
                     if (ForceTradeClosure)
                        Sleep(1000);
                     tries++;
                     if (tries >= 100)
                     {
                        ForceTradeClosure = false;
                        break;
                     }//if (tries >= 100)
                  }//while (ForceTradeClosure)
               
                  //Replace the grids for the stop orders method
                  if (GridType == Stop_Orders_Only)
                  {
                     if (ReplaceWinnersGrid)
                        if (SellOpen)//open sells means the cycle has not ended and we want new buy stop orders ready in case market resumes its upward move
                           SendBuyGrid(Symbol(), OP_BUYSTOP, NormalizeDouble(Ask + (DistanceBetweenTrades / factor), Digits), Lot);
                     if (DeleteAndReplaceLosersGrid)
                        if (SellOpen)//open sells means the cycle has not ended and we want new sell stop orders much closer to the market
                           SendSellGrid(Symbol(), OP_SELLSTOP, NormalizeDouble(Bid - (DistanceBetweenTrades / factor), Digits), Lot);
                  }//if (GridType == Stop_Orders_Only)
                  
                  return;//Nothing more for this function to do
               }//if (BuyOpen)
            }//if (SemStatus == highsemafor || SemStatus == highsemafornow)
            
            //SemStatus will only == lowsemafor or lowsemafornow if CloseImmediatelySemaforAppears is enabled
            if (SemStatus == lowsemafor || SemStatus == lowsemafornow)
            {        
               tries = 0;
               //Close sells
               if (SellOpen && (!CloseOnlyInPositivePips || BuyPipsUpl > 0))
               {
                  ForceTradeClosure = true;
                  while (ForceTradeClosure)
                  {
                     CloseAllTrades(OP_SELL);
                     CloseAllTrades(OP_SELLSTOP);
                     if (DeleteAndReplaceLosersGrid || !BuyOpen)
                        CloseAllTrades(OP_BUYSTOP);
                     if (ForceTradeClosure)
                        Sleep(1000);
                     tries++;
                     if (tries >= 100)
                     {
                        ForceTradeClosure = false;
                        break;
                     }//if (tries >= 100)
                  }//while (ForceTradeClosure)
                  
                  //Replace the sell grid for the stop orders method
                  if (GridType == Stop_Orders_Only)
                  {
                      if (ReplaceWinnersGrid)
                        if (BuyOpen)//open buys means the cycle has not ended and we want new sell stop orders ready in case market resumes its downward move
                           SendSellGrid(Symbol(), OP_SELLSTOP, NormalizeDouble(Bid - (DistanceBetweenTrades / factor), Digits), Lot);
                      if (DeleteAndReplaceLosersGrid)
                        if (BuyOpen)//open buys means the cycle has not ended and we want new buy stop orders much closer to the market
                           SendBuyGrid(Symbol(), OP_BUYSTOP, NormalizeDouble(Ask + (DistanceBetweenTrades / factor), Digits), Lot);
                  }//if (GridType == Stop_Orders_Only)
   
                  return;//Nothing more for this function to do
                     
               }//if (SellOpen)              
            }//if (SemStatus == lowsemafor || SemStatus == lowsemafornow)         
        
      }//if (CloseTradesOnRelevantSemafor || CloseImmediatelySemaforAppears)//semafor
   }//if (LatestTradeTime < iTime(Symbol(), TradingTimeFrame, 0) )
           
   
   //Hedged position. Has it hit tp?
   if (Hedged)
   {
      bool ClosePosition = false;
      
      //Have we hit pips upl
      if (HedgeProfitPips > 0)
         if (PipsUpl >= HedgeProfitPips)
            ClosePosition = true;
            
      //Have we hit cash upl
      if (!ClosePosition)   
         if (HedgeProfitCash > 0)
            if (CashUpl >= HedgeProfitCash)
               ClosePosition = true;
               
      if (ClosePosition)
      {
         tries = 0;
         ForceTradeClosure = true;
         while(ForceTradeClosure)
         {
            ForceTradeClosure = false;
            if (BuyOpen)
               CloseAllTrades(OP_BUY);
            if (SellOpen)
               CloseAllTrades(OP_SELL);   
            if (SellStopOpen)
               CloseAllTrades(OP_SELLSTOP);
            if (SellLimitOpen)
               CloseAllTrades(OP_SELLLIMIT);
            if (BuyStopOpen)
               CloseAllTrades(OP_BUYSTOP);
            if (BuyLimitOpen)
               CloseAllTrades(OP_BUYLIMIT);   
               
               tries++;
               if (tries >= 100)
               {
                  ForceTradeClosure = false;
                  break;
               }//if (tries >= 100)
         }//while(ForceTradeClosure)
         
            
      }//if (ClosePosition)
      
      //Close the profitable bit of the hedge following a yellow wavy line
      if (CloseProfitableSideOnYellowWavy)
         if (WaveStatus == Waverange)
         {
            //Is the buy side in a cash profit
            if (BuyCashUpl >= 0)
            {
               tries = 0;
               ForceTradeClosure = true;
               while(ForceTradeClosure)
               {
                  ForceTradeClosure = false;
                  if (BuyOpen)
                     CloseAllTrades(OP_BUY);
                  if (BuyStopOpen)
                     CloseAllTrades(OP_BUYSTOP);
                  if (BuyLimitOpen)
                     CloseAllTrades(OP_BUYLIMIT);   
                     
                     tries++;
                     if (tries >= 100)
                     {
                        ForceTradeClosure = false;
                        break;
                     }//if (tries >= 100)
               }//while(ForceTradeClosure)

               //Grid replacement
               if (!ForceTradeClosure)
               {
                  //Replace the buy grid in case the market continues to rise
                  SendBuyGrid(Symbol(), OP_BUYSTOP, NormalizeDouble(Ask + (DistanceBetweenTrades / factor), Digits), Lot);
                  //Replace the sell grid in the hope that the market will fall
                  SendSellGrid(Symbol(), OP_SELLSTOP, NormalizeDouble(Bid - (DistanceBetweenTrades / factor), Digits), Lot);
               }//if (!ForceTradeClosure)
               
               if (!ForceTradeClosure)
                  return;//Everything worked. Makes a bloody change.            
            }//if (BuyCashUpl >= 0)
            
            //Is the sell side in a cash profit
            if (SellCashUpl >= 0)
            {
               tries = 0;
               ForceTradeClosure = true;
               while(ForceTradeClosure)
               {
                  ForceTradeClosure = false;
                  if (SellOpen)
                     CloseAllTrades(OP_SELL);
                  if (SellStopOpen)
                     CloseAllTrades(OP_SELLSTOP);
                  if (SellLimitOpen)
                     CloseAllTrades(OP_SELLLIMIT);   
                     
                     tries++;
                     if (tries >= 100)
                     {
                        ForceTradeClosure = false;
                        break;
                     }//if (tries >= 100)
               }//while(ForceTradeClosure)

               //Grid replacement
               if (!ForceTradeClosure)
               {
                  //Replace the sell grid in the hope that the market continues to fall
                  SendSellGrid(Symbol(), OP_SELLSTOP, NormalizeDouble(Bid - (DistanceBetweenTrades / factor), Digits), Lot);
                  //Replace the buy grid in case it rises instead
                  SendBuyGrid(Symbol(), OP_BUYSTOP, NormalizeDouble(Ask + (DistanceBetweenTrades / factor), Digits), Lot);
               }//if (!ForceTradeClosure)
               
               if (!ForceTradeClosure)
                  return;//Everything worked. Makes a bloody change.            
            }//if (SellCashUpl >= 0)
            
         
         }//if (WaveStatus == Waverange)
         
        
      //A hedged position overrides all else, so no need to continue with this function.
      return;
         
   }//if (Hedged)
      
   
   //We only want trades closing if the trades are based on a previous candle's signal
   if (LatestTradeTime < iTime(Symbol(), TradingTimeFrame, 0) )
   {
      //Buy signal
      if (BuySignal)
         if (OriginalSignal != OP_SELL)
         {
            tries = 0;
            ForceTradeClosure = true;
            while(ForceTradeClosure)
            {
               if (SellOpen)
                  CloseAllTrades(OP_SELL);
               if (SellStopOpen)
                  CloseAllTrades(OP_SELLSTOP);
               if (SellLimitOpen)
                  CloseAllTrades(OP_SELLLIMIT);
                  tries++;
                  if (tries >= 100)
                  {
                     ForceTradeClosure = false;
                     break;
                  }//if (tries >= 100)
           }//while(ForceTradeClosure)
           if (!ForceTradeClosure)
               if(BuyOpen) //)//open buys means the cycle has not ended and we want new sell stop orders ready in case market resumes its downward move
                  //Replace the sell grid in the case that the market continues to fall
                  SendSellGrid(Symbol(), OP_SELLSTOP, NormalizeDouble(Bid - (DistanceBetweenTrades / factor), Digits), Lot);   
         }//if (OriginalSignal != OP_SELL)
         
      //Sell signal
      if (SellSignal)
         if (OriginalSignal != OP_BUY)
         {
            tries = 0;
            ForceTradeClosure = true;
            while(ForceTradeClosure)
            {
               if (BuyOpen)
                  CloseAllTrades(OP_BUY);
               if (BuyStopOpen)
                  CloseAllTrades(OP_BUYSTOP);
               if (BuyLimitOpen)
                  CloseAllTrades(OP_BUYLIMIT);
                  tries++;
                  if (tries >= 100)
                  {
                     ForceTradeClosure = false;
                     break;
                  }//if (tries >= 100)
           }//while(ForceTradeClosure)
           if (!ForceTradeClosure)
               if(SellOpen)//open sells means the cycle has not ended and we want new buy stop orders ready in case market resumes its upward move
                  //Replace the buy grid in the case that the market continues to rise
                  SendBuyGrid(Symbol(), OP_BUYSTOP, NormalizeDouble(Ask + (DistanceBetweenTrades / factor), Digits), Lot);      
         }//if (OriginalSignal != OP_BUY)
            
   }//if (LatestTradeTime < iTime(Symbol(), TradingTimeFrame, 0) )
      
   
   
   //No trade signal. Delete existing pendings if none of them have filled.
   if (LatestTradeTime >= iTime(Symbol(), TradingTimeFrame, 0) )
      if (HgiSignalStatus == hginosignal && WaveStatus == Wavenone && SemStatus == nosemafor)
         if (!BuyOpen)
            if (!SellOpen)
            {
               tries = 0;
               ForceTradeClosure = true;
               while(ForceTradeClosure)
               {
                  ForceTradeClosure = false;
                  if (SellStopOpen)
                     CloseAllTrades(OP_SELLSTOP);
                  if (SellLimitOpen)
                     CloseAllTrades(OP_SELLLIMIT);
                  if (BuyStopOpen)
                     CloseAllTrades(OP_BUYSTOP);
                  if (BuyLimitOpen)
                     CloseAllTrades(OP_BUYLIMIT);   
                  tries++;
                  if (tries >= 100)
                  {
                     ForceTradeClosure = false;
                     break;
                  }//if (tries >= 100)
              }//while(ForceTradeClosure) 
            }//if (!SellOpen)
   //All market trades have hit tp
   if (PendingTradesTotal <= GridSize)//There should be up to GridSize * 2
      if (MarketTradesTotal == 0)//And all the market trades have hit tp or sl
      {
         ForceTradeClosure = true;
         while(ForceTradeClosure)
         {
            tries = 0;
            ForceTradeClosure = false;
            if (SellStopOpen)
               CloseAllTrades(OP_SELLSTOP);
            if (SellLimitOpen)
               CloseAllTrades(OP_SELLLIMIT);
            if (BuyStopOpen)
               CloseAllTrades(OP_BUYSTOP);
            if (BuyLimitOpen)
               CloseAllTrades(OP_BUYLIMIT);   
                  tries++;
                  if (tries >= 100)
                  {
                     ForceTradeClosure = false;
                     break;
                  }//if (tries >= 100)
        }//while(ForceTradeClosure) 
      }//if (MarketTradesTotal == 0)//And all the market trades have hit tp or sl
   
}//End void ShouldTradesBeClosed()

Thanks on all our behalves Kevin.

: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 'n Grid

Post by SteveHopwood »

Peepaws » Sat Mar 05, 2016 4:02 pm wrote:
II will soon be able to fund a GP account which is what I've been waiting for, for the last year. Anyone using a broker other than Global Prime I would urge you to switch if at all possible.
I second that.

I third, fourth and fifth it as well. GP are a breath of fresh air in the stinking pit occupied by most of the other firms.

: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 'n Grid

Post by SteveHopwood »

Kevin's fixes are working beautifully in 2d. The successful side of my GU hedge was just closed after the semafor signal appeared, and HGB has sent the protective buy stop grid.

Thanks Kevin. :clap: :clap: :clap: :clap: :clap:

: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.
Post Reply

Return to “Thingy Bob EA's”