Holy Graily Bob's Candle Power
- tomele
- Administrator
- Posts: 1208
- Joined: Tue May 17, 2016 3:40 pm
- Location: Germany, Forest of Odes, Defending the Limes
Holy Graily Bob's Candle Power
Hi.
The immediate close might have to do with SsCloseTradesOnColourChange.
Line 2254 should be: if (SsColour == blue)
EDIT: CP is still closing trades. There must be something else.
The immediate close might have to do with SsCloseTradesOnColourChange.
Line 2254 should be: if (SsColour == blue)
EDIT: CP is still closing trades. There must be something else.
Happy pippin, Thomas 
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
- tomele
- Administrator
- Posts: 1208
- Joined: Tue May 17, 2016 3:40 pm
- Location: Germany, Forest of Odes, Defending the Limes
Holy Graily Bob's Candle Power
Hi.
Found another reason for closing: MaTrend is an empty string at that moment.
Change line 2205 to: if (MaTrend == down) and line 2260 to: if (MaTrend == up)
EDIT: Although this works, the correct solution is to add "if (UseBobMoving Average) to both blocks.
So the both blocks should be
Found another reason for closing: MaTrend is an empty string at that moment.
Change line 2205 to: if (MaTrend == down) and line 2260 to: if (MaTrend == up)
EDIT: Although this works, the correct solution is to add "if (UseBobMoving Average) to both blocks.
So the both blocks should be
Code: Select all
//Change of moving average trend
if (!CloseThisTrade)
if (UseBobMovingAverage)
if (MaCloseTradesOnTrendChange)
if (MaTrend == down)
CloseThisTrade = true;
//Change of moving average trend
if (!CloseThisTrade)
if (UseBobMovingAverage)
if (MaCloseTradesOnTrendChange)
if (MaTrend == up)
CloseThisTrade = true;Happy pippin, Thomas 
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
It ain't what you don't know that gets you into trouble.
It's what you know for sure that just ain't so. (Mark Twain)
Keep the coder going: Donate
- 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's Candle Power
Thanks Thomas.
The fix is already in post 1. Thomas led me to the bloop in one of his previous posts. The problem was me forgetting to add a check to the moving average closure block that were are using Bob's moving average.
V 1a for the hoi polloi is in post 1.
For the classy people here, easiest is simply to copy the entire function over the top of the existing one:
Those of you who already made the changes as Thomas posted them, note my changes to the moving average test so that they make more sense:
For buy trades: if (MaTrend == down)
For sell trades: if (MaTrend == up)
Thanks Thomas. You saved me some brain pain this morning.

The fix is already in post 1. Thomas led me to the bloop in one of his previous posts. The problem was me forgetting to add a check to the moving average closure block that were are using Bob's moving average.
V 1a for the hoi polloi is in post 1.
For the classy people here, easiest is simply to copy the entire function over the top of the existing one:
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 (!BetterOrderSelect(ticket, SELECT_BY_TICKET) ) return(true);
if (BetterOrderSelect(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();
//Direction hgi yellow range wave
if (HgiCloseOnYellowWavy)
if (TradeHgiStatus == hgiyellowrangewavey)
CloseThisTrade = true;
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!CloseThisTrade)
{
if (OrderType() == OP_BUY || OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT)
{
//TP
if (Bid >= take && !CloseEnough(take, 0) && !CloseEnough(take, OrderTakeProfit()) ) CloseThisTrade = true;
//SL
if (Bid <= stop && !CloseEnough(stop, 0) && !CloseEnough(stop, OrderStopLoss())) CloseThisTrade = true;
//Hidden HGI code
//Original Hgi closure
if (!CloseThisTrade)
if (CloseOnLargeArrows)
if (HgiStatus == hgidownarrowtradable)
if (!OnlyCloseWinningTrades || (OrderProfit() + OrderCommission() + OrderSwap()) > 0)
if (OrderOpenTime() < iTime(Symbol(), HgiTimeFrame, 0) )//Don't close trades opened during the current HGI candle
CloseThisTrade = true;
if (!CloseThisTrade)
if (CloseOnBlueWavy)
if (HgiStatus == hgibluewavyshort)
if (!OnlyCloseWinningTrades || (OrderProfit() + OrderCommission() + OrderSwap()) > 0)
if (OrderOpenTime() < iTime(Symbol(), HgiTimeFrame, 0) )//Don't close trades opened during the current HGI candle
CloseThisTrade = true;
//Opposite direction directional hgi
if (!CloseThisTrade)
if (UseHgiTrendFilter)
if (HgiCloseOnOppositeSignal)
if (TradeHgiStatus == hgidownarrowtradable || TradeHgiStatus == hgibluewavyshort)
CloseThisTrade = true;
//Change of SS colour
if (!CloseThisTrade)
if (UseSuperSlope)
if (SsCloseTradesOnColourChange)
if (SsColour == red)
CloseThisTrade = true;
//Change of moving average trend
if (!CloseThisTrade)
if (UseBobMovingAverage)
if (MaCloseTradesOnTrendChange)
if (MaTrend == down)
CloseThisTrade = true;
//Change of peaky direction
if (!CloseThisTrade)
if (UsePeaky)
if (PeakyCloseTradesOnDirectionChange)
if (PeakyStatus == shortdirection)
CloseThisTrade = true;
}//if (OrderType() == OP_BUY)
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if (OrderType() == OP_SELL || OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT)
{
//TP
if (Bid <= take && !CloseEnough(take, 0) && !CloseEnough(take, OrderTakeProfit()) ) CloseThisTrade = true;
//SL
if (Bid >= stop && !CloseEnough(stop, 0) && !CloseEnough(stop, OrderStopLoss())) CloseThisTrade = true;
//Original Hgi closure
if (CloseOnLargeArrows)
if (HgiStatus == hgiuparrowtradable)
if (!OnlyCloseWinningTrades || (OrderProfit() + OrderCommission() + OrderSwap()) > 0)
if (OrderOpenTime() < iTime(Symbol(), HgiTimeFrame, 0) )//Don't close trades opened during the current HGI candle
CloseThisTrade = true;
if (!CloseThisTrade)
if (CloseOnBlueWavy)
if (HgiStatus == hgibluewavylong)
if (!OnlyCloseWinningTrades || (OrderProfit() + OrderCommission() + OrderSwap()) > 0)
if (OrderOpenTime() < iTime(Symbol(), HgiTimeFrame, 0) )//Don't close trades opened during the current HGI candle
CloseThisTrade = true;
//Opposite direction directional hgi
if (!CloseThisTrade)
if (UseHgiTrendFilter)
if (HgiCloseOnOppositeSignal)
if (TradeHgiStatus == hgiuparrowtradable || TradeHgiStatus == hgibluewavylong)
CloseThisTrade = true;
//Change of SS colour
if (!CloseThisTrade)
if (UseSuperSlope)
if (SsCloseTradesOnColourChange)
if (SsColour == blue)
CloseThisTrade = true;
//Change of moving average trend
if (!CloseThisTrade)
if (UseBobMovingAverage)
if (MaCloseTradesOnTrendChange)
if (MaTrend == up)
CloseThisTrade = true;
//Change of peaky direction
if (!CloseThisTrade)
if (UsePeaky)
if (PeakyCloseTradesOnDirectionChange)
if (PeakyStatus == longdirection)
CloseThisTrade = true;
}//if (OrderType() == OP_SELL)
}//if (!CloseThisTrade)
///////////////////////////////////////////////////////////////////////////////////////////////////////////
if (CloseThisTrade)
{
bool result = false;
if (OrderType() < 2)//Market orders
result = CloseOrder(ticket);
else
result = OrderDelete(ticket, clrNONE);
//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()
For buy trades: if (MaTrend == down)
For sell trades: if (MaTrend == up)
Thanks Thomas. You saved me some brain pain this morning.
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.
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.
- 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's Candle Power
Ehu-style dashboard ea for CP and found a bloop in the Peaky code.
Classy people, do a search for "int Highest = iHigh(symbol, tf, bars);"
You will see these two lines of code:
int Highest = iHigh(symbol, tf, bars);
int Lowest = iLow(symbol, tf, bars);
They should be:
int Highest = iHighest(symbol, tf, bars);
int Lowest = iLowest(symbol, tf, bars);
iHigh() returns the high price of the selected candle. iHighest() returns the the shift of the bar with the highest price - this is what we need here.
Update for the peasants in post 1 - still V 1a.

Classy people, do a search for "int Highest = iHigh(symbol, tf, bars);"
You will see these two lines of code:
int Highest = iHigh(symbol, tf, bars);
int Lowest = iLow(symbol, tf, bars);
They should be:
int Highest = iHighest(symbol, tf, bars);
int Lowest = iLowest(symbol, tf, bars);
iHigh() returns the high price of the selected candle. iHighest() returns the the shift of the bar with the highest price - this is what we need here.
Update for the peasants in post 1 - still V 1a.
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.
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.
- 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's Candle Power
I still hadn't quite got those Peaky calls quite right - I left out the mode, which can be to the high or low or open or close prices. Classy people, the code should read:
int Highest = iHighest(symbol, tf, MODE_HIGH, bars);
int Lowest = iLowest(symbol, tf, MODE_LOW, bars);
Codaly challlenged peasants, the fix is in post 1.

int Highest = iHighest(symbol, tf, MODE_HIGH, bars);
int Lowest = iLowest(symbol, tf, MODE_LOW, bars);
Codaly challlenged peasants, the fix is in post 1.
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.
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.
-
wallywonka
- Trader
- Posts: 188
- Joined: Thu May 12, 2016 7:46 am
Holy Graily Bob's Candle Power
Seems to be a bug if you remove the HGI direction filter it will take Short/Long trades and wont look at the other filters SS/Peaky etc
-
xphoton
- Posts: 5
- Joined: Mon Mar 20, 2017 5:57 am
Holy Graily Bob's Candle Power
You can comment line 1951~1958 for quick fix.wallywonka » Tue Oct 10, 2017 8:56 am wrote:Seems to be a bug if you remove the HGI direction filter it will take Short/Long trades and wont look at the other filters SS/Peaky etc
They will be judged after. The Reserved code has not finished.
Code: Select all
//Reserved for SuperSlope
//Reserved for MA
if (!UseHgiTrendFilter)
{
BuySignal = true;
SellSignal = true;
BuyCloseSignal = false;
SellCloseSignal = false;
return;
}//if (!UseHgiTrendFilter)
-
wallywonka
- Trader
- Posts: 188
- Joined: Thu May 12, 2016 7:46 am
Holy Graily Bob's Candle Power
That did the trick!xphoton » Tue Oct 10, 2017 1:41 am wrote:You can comment line 1951~1958 for quick fix.wallywonka » Tue Oct 10, 2017 8:56 am wrote:Seems to be a bug if you remove the HGI direction filter it will take Short/Long trades and wont look at the other filters SS/Peaky etc
They will be judged after. The Reserved code has not finished.
- 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's Candle Power
Nice spot xphoton. Thanks.xphoton » Tue Oct 10, 2017 1:41 am wrote:You can comment line 1951~1958 for quick fix.wallywonka » Tue Oct 10, 2017 8:56 am wrote:Seems to be a bug if you remove the HGI direction filter it will take Short/Long trades and wont look at the other filters SS/Peaky etc
They will be judged after. The Reserved code has not finished.Code: Select all
//Reserved for SuperSlope //Reserved for MA if (!UseHgiTrendFilter) { BuySignal = true; SellSignal = true; BuyCloseSignal = false; SellCloseSignal = false; return; }//if (!UseHgiTrendFilter)
Most of us have not noticed this because we are using HGI. Classy people, you know what to do. No need to comment it out; just delete it. Slightly unkempt people, your fix is in post 1.
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.
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.