stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Old and defunct Holy Graily Bob
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3966
Page 8 of 129
Author:  SteveHopwood [ Tue Dec 02, 2014 10:10 am ]
Post subject:  Holy Graily Bob

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:
Author:  SteveHopwood [ Tue Dec 02, 2014 10:14 am ]
Post subject:  Holy Graily Bob

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:
Author:  fullaforex [ Tue Dec 02, 2014 11:31 am ]
Post subject:  Holy Graily Bob

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:
Author:  johnsund [ Tue Dec 02, 2014 11:41 am ]
Post subject:  Holy Graily Bob

Even though all 3 inputs in the EA regarding email notices are set to false, still getting them. Anyone else getting the same???
Author:  Gertje [ Tue Dec 02, 2014 11:51 am ]
Post subject:  Holy Graily Bob

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??
Author:  fullaforex [ Tue Dec 02, 2014 11:55 am ]
Post subject:  Holy Graily Bob

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
Author:  Gertje [ Tue Dec 02, 2014 12:00 pm ]
Post subject:  Holy Graily Bob

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
Author:  PipPoppy [ Tue Dec 02, 2014 12:01 pm ]
Post subject:  Holy Graily Bob

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
Author:  Radar [ Tue Dec 02, 2014 12:35 pm ]
Post subject:  Holy Graily Bob

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^)
Author:  Gertje [ Tue Dec 02, 2014 12:39 pm ]
Post subject:  Holy Graily Bob

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.
All times are UTC Page 8 of 129