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

Holy Graily Bob 'n Grid

Post by Peepaws »

I will be starting 4 new demos and abandoning all previous demos this week.

1-3. Will all be Stop orders only with one at 2.5% equity close, one at 10% equity close, and the third handsfree.

4. Will be Stop and Limit orders running handsfree.

Handsfree however, to me means if I see some major profit going on I will still close all manually just as I would live.

All will be using the Offsetting feature.

I keep saying I'm almost ready to go live! :lol: Hopefully soon, I just want to be sure I'm comfortable.

Thanks again Steve for the best EA that I imagine anyone here has ever seen :) :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 »

Peepaws » Sun Apr 17, 2016 7:54 pm wrote:I will be starting 4 new demos and abandoning all previous demos this week.

1-3. Will all be Stop orders only with one at 2.5% equity close, one at 10% equity close, and the third handsfree.

4. Will be Stop and Limit orders running handsfree.

Handsfree however, to me means if I see some major profit going on I will still close all manually just as I would live.

All will be using the Offsetting feature.

I keep saying I'm almost ready to go live! :lol: Hopefully soon, I just want to be sure I'm comfortable.

Thanks again Steve for the best EA that I imagine anyone here has ever seen :) :good:
These seem like Excellent Plans to me.

Re this bit of your post:
I keep saying I'm almost ready to go live! :lol: Hopefully soon, I just want to be sure I'm comfortable.
Quite right. There is no hurry. This forum is not going away (trust me, it really isn't; there are a number of people able to take over should I die), nor is the EA, nor is Forex. Go live when you are comfortable to do so.

Generally speaking folks, be not in a hurry to go live. I am still developing this EA and there is no guarantee that everything is under control yet. I am trading HGBnG live because I understand him. Most of the rest of you would be trading him in blind hope.

When you do go live, do so with the tiniest lots sizes possible until you are completely happy with how HGBnG performs. That way, you stand a chance of enjoying yourselves trading live.

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

V 1t is in post 1.

I started on Rinse 'n Repeat again this morning. I transferred the offsetting code to him and was able to watch it in action. There were corrections to make and I have transferred these to HGBnG.

The easiest way to make these corrections yourselves is to copy the whole of this version of bool CanStopOnlyTradesBeOffset() over the top of the existing code.

Code: Select all

bool CanStopOnlyTradesBeOffset()
{

   
   //Simple offset when the latest trade falls by 1 grid size and we are no thedged
   
   double TradePipsProfit = 0;//
   bool result = false;
   
   if (!Hedged)
   {
      //Buys
      if (MarketBuysCount >= NoOfSoOpenTradesToStartOffset)//Must be at least 4 trades open
         if (BuyPipsUpl > 0)//The position must be winning
         {
            if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES))
            {
               //Is it a losing trade?
               TradePipsProfit = CalculateTradeProfitInPips(OP_BUY);
               if (TradePipsProfit < 0)
               {
                  //Is it losing by at least DistanceBetweenTrades?
                  TradePipsProfit*= -1;//Convert to a positive number for the comparison
                  if (TradePipsProfit >= DistanceBetweenTrades)
                  {
                     result = OrderCloseBy(HighestBuyTicketNo, LowestBuyTicketNo, clrBlue);
                     if (result)
                     {
                        //Replace the buy stop
                        SendSingleTrade(Symbol(), OP_BUYSTOP, TradeCommentCOT, Lot, HighestBuyPrice, 0, 0);
                        return(true);
                     }//if (result)                  
                  }//if (TradePipsProfit >= DistanceBetweenTrades)               
               }//if (TradePipsProfit < 0)           
            }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES))
         }//if (BuyPipsUpl > 0)
         
      //Sells
      if (MarketSellsCount >= NoOfSoOpenTradesToStartOffset)//Must be at least 4 trades open
         if (SellPipsUpl > 0)//The position must be winning
         {
            if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES))
            {
               //Is it a losing trade?
               TradePipsProfit = CalculateTradeProfitInPips(OP_SELL);
               if (TradePipsProfit < 0)
               {
                  //Is it losing by at least DistanceBetweenTrades?
                  TradePipsProfit*= -1;//Convert to a positive number for the comparison
                  if (TradePipsProfit >= DistanceBetweenTrades)
                  {
                     result = OrderCloseBy(LowestSellTicketNo, HighestSellTicketNo, clrBlue);
                     if (result)
                     {
                        //Replace the sell stop
                        SendSingleTrade(Symbol(), OP_SELLSTOP, TradeCommentCOT, Lot, LowestSellPrice, 0, 0);
                        return(true);
                     }//if (result)                  
                  }//if (TradePipsProfit >= DistanceBetweenTrades)               
               }//if (TradePipsProfit < 0)           
            }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES))
         }//if (SellPipsUpl > 0)
   }//if (!Hedged)
         

   
   /////////////////////////////////////////////////////////////////////////////
   //We have reached this point, so there were no simple offsets. Look for
   //the opportunity to offset some of the profitable side of the hedge
   //against the biggest loser on the other side
   
   double CashLoss = 0;
   double CashProfit = 0;
   int NoOfTrades = 0;
   bool ClosePossible = false;
   int cc = 0;
   
   if (Hedged)
   {
      //Can we offset some buy trades against the lowest losing sell trade
      if (BuyCashUpl > 0)//The buy side of the hedge must be profitable overall
         if (MarketBuysCount >= NoOfSoOpenTradesToStartOffset)//Must be sufficient trades open to start offsetting
            if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES))//Select the lowest sell
            {
               CashLoss = (OrderSwap() + OrderCommission() + OrderProfit());//Calculate its cash position
               if (CashLoss < 0)//Is it losing?
               {
                  CashLoss*= -1;//Convert to a positive for comparison with the profit on the other side
                  //Calculate the profit on the other side of the hedge
                  for (cc = MarketBuysCount; cc > 0; cc--)
                  {
                     if (OrderSelect(FifoBuyTicket[cc - 1][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )
                     {
                        CashProfit+= (OrderSwap() + OrderCommission() + OrderProfit());
                        NoOfTrades++;
                     }//if (OrderSelect(FifoBuyTicket[cc - 1][ticket], SELECT_BY_TICKET, MODE_TRADES) )
                     
                     //Is the profit big enough to close the trade on the other side of the hedge?
                     if (CashProfit >= CashLoss)
                     {
                        //Yippee
                        ClosePossible = true;
                        break;
                     }//if (CashProfit >= CashLoss)
                  }//for (int cc = MarketBuysCount; cc >= 0; cc--)
                  
                  //Are there closures to make?
                  if (ClosePossible)
                  {
                     ForceTradeClosure = true;
                     while (ForceTradeClosure)
                     {
                        ForceTradeClosure = false;
                        if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        {
                           result = CloseOrder(LowestSellTicketNo);
                           if (!result)
                              ForceTradeClosure = true;
                        }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        
                        for (cc = MarketBuysCount; cc >= (MarketBuysCount - (NoOfTrades - 1)); cc--)
                        {
                           if (OrderSelect(FifoBuyTicket[cc - 1][TradeTicket], SELECT_BY_TICKET, MODE_TRADES))
                           {
                              result = CloseOrder(FifoBuyTicket[cc - 1][TradeTicket]);
                              if (!result)
                              {
                                 ForceTradeClosure = true;
                                 cc++;
                              }//if (!result)
                           }//if (OrderSelect(FifoBuyTicket[cc - 1][TradeTicket], SELECT_BY_TICKET, MODE_TRADES))                           
                        }//for (cc = MarketBuysCount; cc >= NoOfTrades; cc--)
                     }//while (ForceTradeClosure)
                     return(true);
                  }//if (ClosePossible)
               }//if (CashLoss < 0)
            }//if (OrderSelect(LowestSellTicketNo, SELECT_BY_TICKET, MODE_TRADES))
            
      CashLoss = 0;
      CashProfit = 0;
      NoOfTrades = 0;
      ClosePossible = false;

      //Can we offset some sell trades against the highest losing buy trade
      if (SellCashUpl > 0)//The sell side of the hedge must be profitable overall
         if (MarketSellsCount >= NoOfSoOpenTradesToStartOffset)//Must be sufficient trades open to start offsetting
            if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES))//Select the highest buy
            {
               CashLoss = (OrderSwap() + OrderCommission() + OrderProfit());//Calculate its cash position
               if (CashLoss < 0)//Is it losing?
               {
                  CashLoss*= -1;//Convert to a positive for comparison with the profit on the other side
                  //Calculate the profit on the other side of the hedge
                  for (cc = 0; cc < MarketSellsCount; cc++)
                  {
                     if (OrderSelect(FifoSellTicket[cc][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )
                     {
                        CashProfit+= (OrderSwap() + OrderCommission() + OrderProfit());
                        NoOfTrades++;
                     }//if (OrderSelect(FifoSellTicket[cc1][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )
                     
                     //Is the profit big enough to close the trade on the other side of the hedge?
                     if (CashProfit >= CashLoss)
                     {
                        //Yippee
                        ClosePossible = true;
                        break;
                     }//if (CashProfit >= CashLoss)
                  }//for (cc = 0; cc < MarketSellsCount - 1; cc++)
                  
                  //Are there closures to make?
                  if (ClosePossible)
                  {
                     ForceTradeClosure = true;
                     while (ForceTradeClosure)
                     {
                        ForceTradeClosure = false;
                        if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        {
                           result = CloseOrder(HighestBuyTicketNo);
                           if (!result)
                              ForceTradeClosure = true;
                        }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES) )
                        
                        for (cc = 0; cc <= NoOfTrades; cc++)
                        {
                           if (OrderSelect(FifoSellTicket[cc][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )
                           {
                              result = CloseOrder(FifoSellTicket[cc][TradeTicket]);
                              if (!result)
                              {
                                 ForceTradeClosure = true;
                                 cc--;
                              }//if (!result)
                           }//if (OrderSelect(FifoBuyTicket[cc - 1][TradeTicket], SELECT_BY_TICKET, MODE_TRADES) )                           
                        }//for (cc = 0; cc <= NoOfTrades; cc++)
                     }//while (ForceTradeClosure)
                     return(true);
                  }//if (ClosePossible)
               }//if (CashLoss < 0)
            }//if (OrderSelect(HighestBuyTicketNo, SELECT_BY_TICKET, MODE_TRADES))
   
   }//if (Hedged)

   
   ////////////////////////////////////////////////////////////////////////////
   //Got this far, so no trades closed
   return(false);

}//bool CanStopOnlyTradesBeOffset()
I shall be reopening RnR as soon as I am sure he is working correctly.

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

Tip for VPS users. Run task manager and see how the cpu use drops if you run HGBnG minimised. It will be something to do with not having to update the screen.

: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
patmontes
Trader
Posts: 367
Joined: Wed Apr 23, 2014 10:42 pm

Holy Graily Bob 'n Grid

Post by patmontes »

SteveHopwood » Tue Apr 19, 2016 12:10 am wrote:Tip for VPS users. Run task manager and see how the cpu use drops if you run HGBnG minimised. It will be something to do with not having to update the screen.

:xm:
Youre right Steve! Noticeable difference!! :good:
t3ch
Posts: 5
Joined: Mon Mar 21, 2016 3:35 pm

Holy Graily Bob 'n Grid

Post by t3ch »

SteveHopwood » Mon Apr 18, 2016 4:10 pm wrote:Tip for VPS users. Run task manager and see how the cpu use drops if you run HGBnG minimised. It will be something to do with not having to update the screen.

:xm:
Confirmed lower CPU usage when Empty4 runs minimized. :good:
User avatar
TonkaTuff
Trader
Posts: 74
Joined: Wed May 01, 2013 6:30 am
Location: Sydney, AUSTRALIA

Holy Graily Bob 'n Grid

Post by TonkaTuff »

Good tip, thanks Steve..
In theory, there is no difference between theory and practice. In practice, there is.
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 »

SteveHopwood » April 18th, 2016, 7:09 am wrote:V 1t is in post 1.



I shall be reopening RnR as soon as I am sure he is working correctly.

:xm:

This will be great and will give us the ability to let the runners run and not be in fear of loser taking our profits away from our balance.
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 1v is in post 1.

Some of the offsetting code was faulty, so 1v attempts a fix.

Do not use this feature on your live accounts just yet.

: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
cyberevil
Trader
Posts: 95
Joined: Mon Oct 26, 2015 5:55 pm
Location: Vancouver, BC

Holy Graily Bob 'n Grid

Post by cyberevil »

SteveHopwood » April 19th, 2016, 7:26 am wrote:V 1v is in post 1.

Some of the offsetting code was faulty, so 1v attempts a fix.

Do not use this feature on your live accounts just yet.

:xm:
Just did a quick shutdown of Empty4 and compiled the new version into it... seems to have closed some offsetting trades in profit. saw the balance jump up... so seems to be working... :)

quick question to anyone who may know this. Gut feeling says it's not possible but just in case it is.

Is it possible to grab variables from a set file and plug them into the code before compiling. she keeps yelling at me when I forget to change the hgi version :roll: this one alone is easy to do but I'm curious to see if Empty4 has the ability to do rest of the variable from a set file..

thanks in advance.
Post Reply

Return to “Thingy Bob EA's”