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
krzysiekqq2
Trader
Posts: 69
Joined: Sun Oct 11, 2015 11:59 am
Location: Gdynia, town at Baltic sea cost

Holy Graily Bob 'n Grid

Post by krzysiekqq2 »

One elf was.
Steve and Kevin, joining to express big THANK YOU for your amazing hard work.
Cheers,
Krzysiek
bazze

Holy Graily Bob 'n Grid

Post by bazze »

Thanks for this, looking sehr gut so far :) Todays trades :party:
You do not have the required permissions to view the files attached to this post.
User avatar
cyberevil
Trader
Posts: 95
Joined: Mon Oct 26, 2015 5:55 pm
Location: Vancouver, BC

Holy Graily Bob 'n Grid

Post by cyberevil »

Wow! what a amazing little project this turned into :D

Thanks kevin for joining in, I really appreciate your efforts and its just amazing how much two minds can accomplish when locked on to one common goal.

You and Steve have been busy!!! :youknow:

I'm loving where this ea is at the moment and how well of a job it's doing trapping the markets!
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 has been busy again whilst I have been out teaching. He has found a few more thingies in the trade closure function and worked out why DistanceBetweenTrades was resetting to 0. The fix for this was not quite right, so if you are one of the 4 who downloaded it before seeing this post, then you need to redownload.

V 2h in post 1.

For the smarty-pants do it yourselfers:
Go to line 4670, which should be a blank line, and insert this snippet:

Code: Select all

   if (!UseAtrForGrid)
   {
      DistanceBetweenTrades = DistanceBetweenTradesPips;
      if (CloseEnough(DistanceBetweenTrades, 0) )
         DistanceBetweenTrades=3;
   }//if (!UseAtrForGrid)

   if (UseAtrForGrid)
      if (CloseEnough(DistanceBetweenTrades, 0) )
      {
         GridAtrVal = GetAtr(Symbol(), GridAtrTimeFrame, GridAtrPeriod, 1);
         GridAtrVal*= factor;
         GridAtrVal = NormalizeDouble(GridAtrVal * GridAtrMultiplier, 0);
         DistanceBetweenTrades = NormalizeDouble(GridAtrVal / GridSize, 0);

      }//if (CloseEnough(DistanceBetweenTrades, 0) )
      
Then go to line 818 which is:
DistanceBetweenTrades = DistanceBetweenTradesPips;
Delete that line.

Copy this over the top of the existing void ShouldTradesBeClosed(), starting at c. 3812:

Code: Select all

void ShouldTradesBeClosed()
{
       
   if (OpenTrades == 0)
      return;//Nothing to do
 
   int tries = 0;
   
   
   //Semaforsignals
   //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);
                     if (BuyStopOpen)
                        CloseAllTrades(OP_BUYSTOP);
                     if (BuyLimitOpen)
                        CloseAllTrades(OP_BUYLIMIT);
                     if (GridType == Stop_Orders_Only && (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 || SellPipsUpl > 0))
               {
                  ForceTradeClosure = true;
                  while (ForceTradeClosure)
                  {
                     CloseAllTrades(OP_SELL);
                     if (SellStopOpen)
                        CloseAllTrades(OP_SELLSTOP);
                     if (SellLimitOpen)
                        CloseAllTrades(OP_SELLLIMIT);
                     if (GridType == Stop_Orders_Only && (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) )
  
     
   //OppositeSignals
   //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;
            //Close sells
            if (SellOpen && (!OnlyCloseProfitableOppositePositions || SellPipsUpl > 0))
            {
               ForceTradeClosure = true;
               while(ForceTradeClosure)
               {
                  CloseAllTrades(OP_SELL);
                  if (SellStopOpen)
                     CloseAllTrades(OP_SELLSTOP);
                  if (SellLimitOpen)
                     CloseAllTrades(OP_SELLLIMIT);
                  if(GridType == Stop_Orders_Only && (DeleteAndReplaceOppositeSignalLosersGrid || !BuyOpen))
                     CloseAllTrades(OP_BUYSTOP);
                  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 (ReplaceOppositeSignalWinnersGrid)
                     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 (DeleteAndReplaceOppositeSignalLosersGrid)
                     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 (OriginalSignal != OP_SELL)
         
      //Sell signal
      if (SellSignal)
         if (OriginalSignal != OP_BUY)
         {
            tries = 0;
            //Close buys
            if (BuyOpen && (!OnlyCloseProfitableOppositePositions || BuyPipsUpl > 0))
            {
               ForceTradeClosure = true;
               while(ForceTradeClosure)
               {
                  CloseAllTrades(OP_BUY);
                  if (BuyStopOpen)
                     CloseAllTrades(OP_BUYSTOP);
                  if (BuyLimitOpen)
                     CloseAllTrades(OP_BUYLIMIT);
                  if (GridType == Stop_Orders_Only && (DeleteAndReplaceOppositeSignalLosersGrid || !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 (ReplaceOppositeSignalWinnersGrid)
                     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 (DeleteAndReplaceOppositeSignalLosersGrid)
                     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 (OriginalSignal != OP_BUY)
           
   }//if (LatestTradeTime < iTime(Symbol(), TradingTimeFrame, 0) )
   
   
   //Yellow wavy range signal
   //We only want trades closing if the trades are based on a previous candle's signal
   if (LatestTradeTime < iTime(Symbol(), TradingTimeFrame, 0) )
   {
      if (CloseOnYellowRangeWave)
      {
         if (WaveStatus == Waverange)
         {
            tries = 0;
            //Close buys
            if (BuyOpen && (!OnlyCloseProfitablePositions || BuyPipsUpl > 0))
            {
               ForceTradeClosure = true;
               while(ForceTradeClosure)
               {
                  CloseAllTrades(OP_BUY);
                  if (BuyStopOpen)
                     CloseAllTrades(OP_BUYSTOP);
                  if (BuyLimitOpen)
                     CloseAllTrades(OP_BUYLIMIT);
                  if(GridType == Stop_Orders_Only && (DeleteAndReplaceWavyLosersGrid || !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 (ReplaceWavyWinnersGrid)
                     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 (DeleteAndReplaceWavyLosersGrid)
                        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)
     
            //Close sells
            if (SellOpen && (!OnlyCloseProfitablePositions || SellPipsUpl > 0))
            {
               ForceTradeClosure = true;
               while(ForceTradeClosure)
               {
                  ForceTradeClosure = false;
                  CloseAllTrades(OP_SELL);
                  if (SellStopOpen)
                     CloseAllTrades(OP_SELLSTOP);
                  if (SellLimitOpen)
                     CloseAllTrades(OP_SELLLIMIT);
                  if (GridType == Stop_Orders_Only && (DeleteAndReplaceWavyLosersGrid || !BuyOpen))
                     CloseAllTrades(OP_BUYSTOP);  
                  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 (ReplaceWavyWinnersGrid)
                     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 (DeleteAndReplaceWavyLosersGrid)
                        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 (WaveStatus == Waverange)
         
      }//if (CloseOnYellowRangeWave)
   } //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)
         
   }//if (Hedged)
     
     
   //No trade signal. Delete existing pendings if none of them have filled.
   if (LatestTradeTime >= iTime(Symbol(), TradingTimeFrame, 0) )
      if (HgiSignalStatus == hginosignal)
         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()
Then to line 8. Change
#define version "Version 2g"
to
#define version "Version 2h"

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

Holy Graily Bob 'n Grid

Post by k3v1n0s »

Hi guys,

We can now change timeframes, change the settings of HGB'nG without having to reload the whole thing again. ;) ;)

HGB'nG is turning into a monster! :yahoo:

Thank you Steve. :clap:

Cheers,

Kevin
Last edited by k3v1n0s on Wed Mar 09, 2016 5:07 pm, edited 1 time in total.
traderandy
Posts: 9
Joined: Sun Sep 13, 2015 5:13 am

Holy Graily Bob 'n Grid

Post by traderandy »

Hi All.

I Just wanted to say a huge thank you to Steve & Kevin.
Exciting times ahead.. :yahoo: :clap: :yahoo: :clap:

Best Regards,

Andy
zaguy
Trader
Posts: 43
Joined: Wed Feb 03, 2016 7:42 am

Holy Graily Bob 'n Grid

Post by zaguy »

Again a great thanks guys!!

Trades for the last 22 hrs, Broker: GP, Demo :yahoo: :yahoo:
You do not have the required permissions to view the files attached to this post.
User avatar
tonyharmony
Trader
Posts: 148
Joined: Sat Dec 20, 2014 10:54 pm
Location: Ipswich, Queensland Australia

Holy Graily Bob 'n Grid

Post by tonyharmony »

OMG! Guess what all? We have actually found the Holy Grail... :clap:
I can't believe how well V2g has performed in the last 24 hours. :shock:
Just finished loading V2h to my charts... So looking forward to the outcome :yahoo: ...

Thanks again gents for the collaboration, simply brilliant. :hi:

Cheers
You do not have the required permissions to view the files attached to this post.
One can't learn from one's success, but one can learn an enormous amount from one's failures! Determination to succeed is the only goal....
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 »

Most of have Rene's fabulous TradeReport. Don't forget his TradeChart2 at http://www.stevehopwoodforex.com/phpBB3 ... 70#p126170. I had forgotten it until Gertje asked for something and Tomasso pointed him to it.

Rene explains what it is all about in his first post.

: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.
Peepaws
Trader
Posts: 121
Joined: Thu Nov 27, 2014 11:19 pm

Holy Graily Bob 'n Grid

Post by Peepaws »

SteveHopwood » Wed Mar 09, 2016 7:38 pm wrote:Most of have Rene's fabulous TradeReport. Don't forget his TradeChart2 at http://www.stevehopwoodforex.com/phpBB3 ... 70#p126170. I had forgotten it until Gertje asked for something and Tomasso pointed him to it.

Rene explains what it is all about in his first post.

:xm:

Thanks for pointing this out Steve, I was not aware of it and will be downloading and using it right away!!!
Post Reply

Return to “Thingy Bob EA's”