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
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 1e is in post 1.

I could not see why HGB closed some of my Range/RAD trades so I had a look at the code. Usual thingy: copy/paste/forget to edit. Hey ho.

Easiest if you want to make the changes yourselves is to copy this over the top of the existing function:

Code: Select all

bool LookForTradeClosure(int ticket)
{
   //Close the trade if the close conditions are met.
   //Called from within CountOpenTrades(). Returns true if a close is needed and succeeds, so that COT can increment cc,
   //else returns false

   if(!OrderSelect(ticket, SELECT_BY_TICKET) ) return(true);
   if(OrderSelect(ticket, SELECT_BY_TICKET) && OrderCloseTime() > 0) return(true);

   bool CloseThisTrade=false;

   string LineName=TpPrefix+DoubleToStr(ticket,0);
   //Work with the lines on the chart that represent the hidden tp/sl
   double take=ObjectGet(LineName,OBJPROP_PRICE1);
   if(CloseEnough(take,0)) take=OrderTakeProfit();
   LineName=SlPrefix+DoubleToStr(ticket,0);
   double stop=ObjectGet(LineName,OBJPROP_PRICE1);
   if(CloseEnough(stop,0)) stop=OrderStopLoss();

   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
   if(OrderType()==OP_BUY)
   {
      //TP
      if(Bid>=take && !CloseEnough(take,0) && !CloseEnough(take,OrderTakeProfit())) CloseThisTrade=true;
      //SL
      if(Bid<=stop && !CloseEnough(stop,0) && !CloseEnough(stop,OrderStopLoss())) CloseThisTrade=true;

      //Trend opposite signal
      if (OrderComment() == TrendTradeComment)
      {
         //Opposite Trend arrow
         if (TrendCloseOnOppositeTrendArrow)
            if (TrendArrowStatus == Trenddownarrow)
               CloseThisTrade = true;
         
         //TMA high
         if (TrendCloseOnOppositeTMA)
            if (TmaStatus == Tmahighsignal)
               CloseThisTrade = true;
         
                  
      }//if (OrderComment() == TrendTradeComment)
      
      //Range opposite signal
      if (OrderComment() == RangeTradeComment)
      {
         //Opposite Range arrow
         if (RangeCloseOnOppositeRangeArrow)
            if (RangeArrowStatus == Rangedownarrow)
               CloseThisTrade = true;
         
         //TMA high
         if (RangeCloseOnOppositeTMA)
            if (TmaStatus == Tmahighsignal)
               CloseThisTrade = true;
         
                  
      }//if (OrderComment() == RangeTradeComment)
      
      //Rad opposite signal
      if (OrderComment() == RadTradeComment)
      {
         //Opposite Rad arrow
         if (RadCloseOnOppositeRadArrow)
            if (RadArrowStatus == Raddownarrow)
               CloseThisTrade = true;
         
         //TMA high
         if (RadCloseOnOppositeTMA)
            if (TmaStatus == Tmahighsignal)
               CloseThisTrade = true;
         
                  
      }//if (OrderComment() == RadTradeComment)
      
      
   }//if (OrderType() == OP_BUY)

   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
   if(OrderType()==OP_SELL)
   {
      //TP
      if(Bid<=take && !CloseEnough(take,0) && !CloseEnough(take,OrderTakeProfit())) CloseThisTrade=true;
      //SL
      if(Bid>=stop && !CloseEnough(stop,0) && !CloseEnough(stop,OrderStopLoss())) CloseThisTrade=true;

      //Trend opposite signal      
      if (OrderComment() == TrendTradeComment)
      {
         //Opposite trend arrow
         if (TrendCloseOnOppositeTrendArrow)
            if (TrendArrowStatus == Trenduparrow)
               CloseThisTrade = true;

         //TMA low
         if (TrendCloseOnOppositeTMA)
            if (TmaStatus == Tmalowsignal)
               CloseThisTrade = true;
         
               
      }//if (OrderComment() == TrendTradeComment)
      
      //Range opposite signal      
      if (OrderComment() == RangeTradeComment)
      {
         //Opposite trend arrow
         if (RangeCloseOnOppositeRangeArrow)
            if (RangeArrowStatus == Rangeuparrow)
               CloseThisTrade = true;

         //TMA low
         if (RangeCloseOnOppositeTMA)
            if (TmaStatus == Tmalowsignal)
               CloseThisTrade = true;
         
         
      }//if (OrderComment() == RngeTradeComment)
      
      //Rad opposite signal      
      if (OrderComment() == RadTradeComment)
      {
         //Opposite trend arrow
         if (RadCloseOnOppositeRadArrow)
            if (RadArrowStatus == Raduparrow)
               CloseThisTrade = true;

         //TMA low
         if (RadCloseOnOppositeTMA)
            if (TmaStatus == Tmalowsignal)
               CloseThisTrade = true;
         
         
      }//if (OrderComment() == RngeTradeComment)
         
   }//if (OrderType() == OP_SELL)

   ///////////////////////////////////////////////////////////////////////////////////////////////////////////
   
   if (CloseThisTrade)
   {
         bool result = CloseOrder(ticket);
      //Actions when trade close succeeds
      if (result)
      {
         DeletePendingPriceLines();
         TicketNo = -1;//TicketNo is the most recently trade opened, so this might need editing in a multi-trade EA
         OpenTrades--;//Rather than OpenTrades = 0 to cater for multi-trade EA's
         return(true);//Makes CountOpenTrades increment cc to avoid missing out ccounting a trade
      }//if (result)
   
      //Actions when trade close fails
      if (!result)
      {
         return(false);//Do not increment cc
      }//if (!result)
   }//if (CloseThisTrade)
   
   //Got this far, so no trade closure
   return(false);//Do not increment cc

}//End bool LookForTradeClosure()
1e also has some changes to DisplayUserFeedback() to display the tp/sl of all three trading styles, but this is cosmetic and you can always make these changes for yourselves.

1e is an essential download if you are unable to make changes for yourselves. Previous versions are bug-laden drivel.

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

Read Elix's post at http://www.stevehopwoodforex.com/phpBB3 ... 06#p105306.

The wavy line code in HGB is inaccurate and so unusable. I will fix this later.

: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.
fullaforex
Trader
Posts: 120
Joined: Sat Mar 29, 2014 6:25 am

Holy Graily Bob

Post by fullaforex »

Why do I keep getting these messages in the pop up box??

Holy Graily Bob 59750150TrailingStopLoss stop loss modification failed with error 130: invalid stops

Thanks :shock:
There are 10 types of people in the world. Those who understand Binary and those who don't.
johnsund
Trader
Posts: 19
Joined: Tue Nov 15, 2011 10:23 pm

Holy Graily Bob

Post by johnsund »

Even though all 3 inputs in the EA regarding email notices are set to false, still getting them. Anyone else getting the same???
User avatar
Gertje
Trader
Posts: 1936
Joined: Mon Dec 12, 2011 1:17 pm
Location: Middle of the Netherlands

Holy Graily Bob

Post by Gertje »

fullaforex » Tue Dec 02, 2014 11:31 am wrote:Why do I keep getting these messages in the pop up box??

Holy Graily Bob 59750150TrailingStopLoss stop loss modification failed with error 130: invalid stops

Thanks :shock:
What broker are you using? Does the broker allow the distance you're trying to set??
fullaforex
Trader
Posts: 120
Joined: Sat Mar 29, 2014 6:25 am

Holy Graily Bob

Post by fullaforex »

Gertje » Tue Dec 02, 2014 8:36 pm wrote:
fullaforex » Tue Dec 02, 2014 11:31 am wrote:Why do I keep getting these messages in the pop up box??

Holy Graily Bob 59750150TrailingStopLoss stop loss modification failed with error 130: invalid stops

Thanks :shock:
What broker are you using? Does the broker allow the distance you're trying to set??

Yes. I've used this Broker for a long time with another EA with the same TStop settings, 20pips.
Mmm Oh..the Other EA uses a stealth TStop
There are 10 types of people in the world. Those who understand Binary and those who don't.
User avatar
Gertje
Trader
Posts: 1936
Joined: Mon Dec 12, 2011 1:17 pm
Location: Middle of the Netherlands

Holy Graily Bob

Post by Gertje »

I already have fallen in love with HGB!
Trades in both directions at the same time, hedging itself, range, rad and trend trades.
Always in the market, unless the conditions tell not to.

:clap:

Made an initial 10% loss due to some mis-match-logic, but since this morning recovered with style;
1000 pips floating!!!

Can't wait till all the errors are out of the way, and set this thing loose.

:!!:
FXPIG Empty4 4.png
You do not have the required permissions to view the files attached to this post.
PipPoppy
Trader
Posts: 33
Joined: Mon Dec 09, 2013 9:58 am

Holy Graily Bob

Post by PipPoppy »

johnsund » 02 Dec 2014, 22:11 wrote:Even though all 3 inputs in the EA regarding email notices are set to false, still getting them. Anyone else getting the same???
Go to Tools/Options/Email and turn off (uncheck) Enable
Radar
Trader
Posts: 437
Joined: Fri Mar 23, 2012 5:39 pm
Location: Round the bend ;)

Holy Graily Bob

Post by Radar »

Hey Wapen,
Wapen » Tue Dec 02, 2014 1:20 am wrote:Hi Steve,
What can we say, Wow, wow, wow.

One thing I have noted is that the Trailing Stop is not functioning correct. The BE works!

Thanks
Wapen

If you're getting Error 130, it's most likely caused by your br0ker's StopLevel... From the looks of it, Steve's br0ker has a StopLevel of 0, and so he doesn't get bombarded with the error message.

To fix it, go to line 3369, and change it from this...

Code: Select all

if (Bid >= sl + (TrailingStopPips / factor) )//George
...to this...

Code: Select all

if ((Bid - MarketInfo(OrderSymbol(), MODE_STOPLEVEL)) >= sl + (TrailingStopPips / factor) )//George
Then go to line 3385, and change this...

Code: Select all

if (Bid <= sl  - (TrailingStopPips / factor))//George
...to this...

Code: Select all

if ((Bid + MarketInfo(OrderSymbol(), MODE_STOPLEVEL)) <= sl  - (TrailingStopPips / factor))//George
No more "BINGBINGBINGBING!" :D

Have fun!

Radar =8^)
Check out my new, (well, old now), manual trade & automatic scale-in manager,
StackManV2
User avatar
Gertje
Trader
Posts: 1936
Joined: Mon Dec 12, 2011 1:17 pm
Location: Middle of the Netherlands

Holy Graily Bob

Post by Gertje »

Radar » Tue Dec 02, 2014 12:35 pm wrote:Hey Wapen,


No more "BINGBINGBINGBING!" :D

Have fun!

Radar =8^)
I would suggest change broker, 20 pips stoplevel is ridiculous.
Locked

Return to “Thingy Bob EA's”