Thanks Steve, much appreciated!SteveHopwood » Sun May 15, 2016 3:15 pm wrote:V 1a is in post 1.
Master bloop spotter dydynamic spotted a mass of bloops![]()
![]()
![]()
that would have come to light as soon as anyone used tnavi's filter of enabled any of the others. In putting those right I spotted a few more as well that may have had some effect a little further down the line.
GU H1 high/low entry system?
- themaxx
- Trader
- Posts: 71
- Joined: Thu May 24, 2012 9:57 am
GU H1 high/low entry system?
-
sudhindragk
- Trader
- Posts: 45
- Joined: Sat Nov 23, 2013 5:31 pm
GU H1 high/low entry system?
I will send my 25 to Steve as a token of appreciation for all his hard work.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
GU H1 high/low entry system?
That is most generous of you. Thank you.sudhindragk » Mon May 16, 2016 6:03 pm wrote:I will send my 25 to Steve as a token of appreciation for all his hard work.
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.
GU H1 high/low entry system?
Please read my "Edit 16th May 2016" section 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.
- themaxx
- Trader
- Posts: 71
- Joined: Thu May 24, 2012 9:57 am
GU H1 high/low entry system?
Hi SteveSteveHopwood » Mon May 16, 2016 6:44 pm wrote:Please read my "Edit 16th May 2016" section in post 1.
Thanks for taking the time to code this, I really appreciate it. I threw the EA up on GBPUSD and USDCAD when I got home from work, and it took a few trades all according to plan. This morning however, it entered the standard 8am long/short on GBP, but on CAD it only entered the long, missing the short. I got a few pop up errors - my journal is attached in text format.
My immediate thought was that the market had moved too much between 8:00:00 and 8:00:01, but looking at the chart that was not the case. Any idea why this happened?
I was thinking, would you be able to change the EA so that if a pending is too close to trigger, it just enters a market order? Understand if it's too late to add this in as it was not part of the original spec.
Thanks
You do not have the required permissions to view the files attached to this post.
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
GU H1 high/low entry system?
The most likely cause is the market being too close to the pending price, so I have added code that tells the bot to send an immediate market trade if we get an error 130. Try this and see how it goes. Looking at the code threw up a few other thingies that needed refining if people are going to try hedging/offsetting.themaxx » Tue May 17, 2016 7:22 am wrote: Hi Steve
Thanks for taking the time to code this, I really appreciate it. I threw the EA up on GBPUSD and USDCAD when I got home from work, and it took a few trades all according to plan. This morning however, it entered the standard 8am long/short on GBP, but on CAD it only entered the long, missing the short. I got a few pop up errors - my journal is attached in text format.
My immediate thought was that the market had moved too much between 8:00:00 and 8:00:01, but looking at the chart that was not the case. Any idea why this happened?
I was thinking, would you be able to change the EA so that if a pending is too close to trigger, it just enters a market order? Understand if it's too late to add this in as it was not part of the original spec.
Thanks
V 1b of both versions are in post 2.
The easiest way to make your own changes is to copy the whole of LookForTradingOpportunities() over the top of the function, which starts at line 1606:
Code: Select all
void LookForTradingOpportunities()
{
RefreshRates();
double take, stop, price;
int type;
string stype;//For the alert
bool SendTrade = false, result = false;
int err = 0;
bool s = true;
bool SendPendingBuyGrid = false, SendPendingSellGrid = false;
double SendLots = Lot;
//Check filters
if (!IsTradingAllowed() ) return;
/////////////////////////////////////////////////////////////////////////////////////
//Trading decision.
bool SendLong = false, SendShort = false;
//Long trade
//Specific system filters
if (!BuyOpen)
if (!BuyStopOpen)
SendLong = true;
//Usual filters
if (SendLong)
{
//User choice of trade direction
if (!TradeLong) SendLong = false;
//tnavi's 4 moving averages filter
if(UseTnaviMA)
if(tMaTrend!=up)
SendLong = false;
//Bob's 240 H4 ma trend filter
if (MaPeriod > 0)
if (MaTrend != up)
SendLong = false;
//CSS.
if (UseCSS)
{
//We are buying the first in the pair ans selling the second, so ensure they are moving in the correct direction and on the right side of 0
if (CurrDirection1 == downaccelerating || CurrDirection1 == downdecelerating) SendLong = false;
if (CurrDirection2 == upaccelerating || CurrDirection2 == updecelerating) SendLong = false;
}//if (UseCSS)
//Other filters
//Slope must be in the buy area
if (HtfTimeFrame > 0 && HtfSlopeVal < HtfBuyOnlyLevel) SendLong = false;
if (LtfTimeFrame > 0 && LtfSlopeVal < LtfBuyOnlyLevel) SendLong = false;
if (UseZeljko && !BalancedPair(OP_BUY) ) SendLong = false;
if (SendLong)
{
type=OP_BUYSTOP;
stype = " Buy stop ";
price = NormalizeDouble(iHigh(Symbol(), TradingTimeFrame, 1) + (HiLoBuffer / factor), Digits);
stop = CalculateStopLoss(OP_BUY, price);
take = CalculateTakeProfit(OP_BUY, price);
//Lot size calculated by risk
if (RiskPercent > 0) SendLots = CalculateLotSize(price, NormalizeDouble(stop + (HiddenPips / factor), Digits) );
result = SendSingleTrade(Symbol(), type, TradeComment, SendLots, price, stop, take);
if (result)
{
s = OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES);
CheckTpSlAreCorrect(type);
SendTrade = true;//In case of snapshots, or grid trading
SendPendingBuyGrid = true;//Willo not operate unles user has UseGrid enabled
}//if (result)
if (!result)
{
err=GetLastError();
if (err == 130)
{
price = Ask;
stop = CalculateStopLoss(OP_BUY, price);
take = CalculateTakeProfit(OP_BUY, price);
result = SendSingleTrade(Symbol(), OP_BUY, TradeComment, SendLots, price, stop, take);
if (result)
SendTrade = true;//In case of snapshots, or grid trading
}//if (err == 130)
else
OldBarsTime = 0;
}//if (!result)
}//if (SendLong)
}//if (SendLong)
/////////////////////////////////////////////////////////////////////////////////////
//Short trade
//Specific system filters
if (!SellOpen)
if (!SellStopOpen)
SendShort = true;
if (SendShort)
{
//tnavi's 4 moving averages filter
if(UseTnaviMA)
if(tMaTrend!=down)
SendShort = false;
//User choice of trade direction
if (!TradeShort) SendShort = false;
//Other filters
//Bob's 240 H4 ma trend filter
if (MaPeriod > 0)
if (MaTrend != down)
SendShort = false;
//CSS.
if (UseCSS)
{
//We are selling the first in the pair ans buying the second, so ensure they are moving in the correct direction and on the right side of 0
if (CurrDirection1 == upaccelerating || CurrDirection1 == updecelerating) SendShort = false;
if (CurrDirection2 == downaccelerating || CurrDirection2 == downdecelerating) SendShort = false;
}//if (UseCSS)
//Slope must be in the sell area
if (HtfTimeFrame > 0 && HtfSlopeVal > HtfSellOnlyLevel) SendShort = false;
if (LtfTimeFrame > 0 && LtfSlopeVal > LtfSellOnlyLevel) SendShort = false;
if (UseZeljko && !BalancedPair(OP_SELL) ) SendShort = false;
if (SendShort)
{
type=OP_SELLSTOP;
stype = " Sell stop ";
price = NormalizeDouble(iLow(Symbol(), TradingTimeFrame, 1) - (HiLoBuffer / factor), Digits);
stop = CalculateStopLoss(OP_SELL, price);
take = CalculateTakeProfit(OP_SELL, price);
//Lot size calculated by risk
if (RiskPercent > 0) SendLots = CalculateLotSize(price, NormalizeDouble(stop - (HiddenPips / factor), Digits) );
result = SendSingleTrade(Symbol(), type, TradeComment, SendLots, price, stop, take);
if (result)
{
s = OrderSelect(TicketNo, SELECT_BY_TICKET, MODE_TRADES);
CheckTpSlAreCorrect(type);
SendTrade = true;//In case of snapshots, or grid trading
SendPendingSellGrid = true;//Willo not operate unles user has UseGrid enabled
}//if (result)
if (!result)
{
err=GetLastError();
if (err == 130)
{
price = Ask;
stop = CalculateStopLoss(OP_BUY, price);
take = CalculateTakeProfit(OP_BUY, price);
result = SendSingleTrade(Symbol(), OP_BUY, TradeComment, SendLots, price, stop, take);
if (result)
SendTrade = true;//In case of snapshots, or grid trading
}//if (err == 130)
else
OldBarsTime = 0;
}//if (!result)
}//if (SendShort)
}//if (SendShort)
////////////////////////////////////////////////////////////////////////////////////////
if (SendTrade)
{
if (TakeSnapshots)
{
DisplayUserFeedback();
TakeChartSnapshot(TicketNo, " open");
}//if (TakeSnapshots)
//Are we grid trading?
if (UseGrid)
{
if (SendPendingBuyGrid)
{
SendBuyGrid(Symbol(), OP_BUYSTOP, NormalizeDouble(Ask + (DistanceBetweenTrades / factor), Digits), Lot);
if (UseHedgingWithGrid)
SendSellGrid(Symbol(), OP_SELLSTOP, NormalizeDouble(Bid - (DistanceBetweenTrades / factor), Digits), Lot);
}//if (SendPendingBuyGrid)
if (SendPendingSellGrid)
{
SendSellGrid(Symbol(), OP_SELLSTOP, NormalizeDouble(Bid - (DistanceBetweenTrades / factor), Digits), Lot);
if (UseHedgingWithGrid)
SendBuyGrid(Symbol(), OP_BUYSTOP, NormalizeDouble(Ask + (DistanceBetweenTrades / factor), Digits), Lot);
}//if (SendPendingSellGrid)
}//if (UseGrid)
}//if (SendTrade)
//Actions when trade send fails
if (SendTrade && !result)
{
OldBarsTime = 0;
}//if (!result)
}//void LookForTradingOpportunities()
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.
- themaxx
- Trader
- Posts: 71
- Joined: Thu May 24, 2012 9:57 am
GU H1 high/low entry system?
You're a super star Steve!SteveHopwood » Tue May 17, 2016 11:31 am wrote: The most likely cause is the market being too close to the pending price, so I have added code that tells the bot to send an immediate market trade if we get an error 130. Try this and see how it goes. Looking at the code threw up a few other thingies that needed refining if people are going to try hedging/offsetting.
V 1b of both versions are in post 2.

- themaxx
- Trader
- Posts: 71
- Joined: Thu May 24, 2012 9:57 am
GU H1 high/low entry system?
Can someone (not Steve as he's probably too busy) help me modify the code of this EA? I've given it a bash as I'm eager to learn, but it's not working...
I've realised that contrary to my spec, 9/10 I'll close my pendings at the end of the day. And the 1/10 isn't that important to the system - it's more important not to have random pending orders at different levels on the chart. I would like to automate it so after trading finishes (10pm) all pendings are deleted, as I plan to run this EA on as many pairs as possible for diversification purposes.
The first thing I did was modify the existing function "ShouldPendingTradesBeMoved()" to a new function that indiscriminately deletes all pendings:
Then, in "LookForTradingOpportunities()", I replaced the existing line:
with:
But it doesn't seem to work. Could someone point me in the right direction please? My bad code is attached.
Thanks!
I've realised that contrary to my spec, 9/10 I'll close my pendings at the end of the day. And the 1/10 isn't that important to the system - it's more important not to have random pending orders at different levels on the chart. I would like to automate it so after trading finishes (10pm) all pendings are deleted, as I plan to run this EA on as many pairs as possible for diversification purposes.
The first thing I did was modify the existing function "ShouldPendingTradesBeMoved()" to a new function that indiscriminately deletes all pendings:
Code: Select all
void PendingTradesShouldBeDeleted()
{
bool result = false;
//Buy stop
if (BuyStopOpen)
{
result = OrderDelete(BuyStopTicketNo);
}//if (result)
//Sell stop
if (SellStopOpen)
{
result = OrderDelete(SellStopTicketNo);
}//if (result)
}//End //void PendingTradesShouldBeDeleted() Code: Select all
if (!IsTradingAllowed() ) return;Code: Select all
if (!IsTradingAllowed() )
{
PendingTradesShouldBeDeleted();
return;
}Thanks!
You do not have the required permissions to view the files attached to this post.
- pips400
- Trader
- Posts: 279
- Joined: Tue Jan 01, 2013 9:03 pm
GU H1 high/low entry system?
Hi themaxx
I haven't looked under the hood of Steve's code, but typically you want to set up a loop to go through all the trades something like this
I haven't tested it, but it may give you some ideas. 
I haven't looked under the hood of Steve's code, but typically you want to set up a loop to go through all the trades something like this
Code: Select all
void PendingTradesShouldBeDeleted() {
int TradeIndex;
int TotalNumberOfOrders = OrdersTotal();
for(TradeIndex = TotalNumberOfOrders - 1; TradeIndex >= 0 ; TradeIndex --)
{
if( ! OrderSelect(TradeIndex, SELECT_BY_POS, MODE_TRADES) ) continue; // <-- if the OrderSelect fails advance the loop to the next TradeIndex
if( OrderSymbol() != Symbol()) continue; // <-- select only those on the current symbol
if ( ! OrderDelete( OrderTicket())) // <-- try to delete the pending order
Print("Failed to close: ", OrderTicket(), " Error: ", GetLastError() ); // <-- if the Order Delete failed print the error
else
{
Print(StringConcatenate(Symbol()," ", OrderTicket(), " Closed"));
}
} // end of For loop
}Trade the edge not the moment
Dragons Lair Trading - My Personal Trading Journal and Strategy
Dragons Lair Trading - My Personal Trading Journal and Strategy
- themaxx
- Trader
- Posts: 71
- Joined: Thu May 24, 2012 9:57 am
GU H1 high/low entry system?
Thanks! Does the way I call the call the function work?pips400 » Fri May 20, 2016 7:19 am wrote:Hi themaxx
I haven't looked under the hood of Steve's code, but typically you want to set up a loop to go through all the trades something like this
I haven't tested it, but it may give you some ideas.Code: Select all
void PendingTradesShouldBeDeleted() { int TradeIndex; int TotalNumberOfOrders = OrdersTotal(); for(TradeIndex = TotalNumberOfOrders - 1; TradeIndex >= 0 ; TradeIndex --) { if( ! OrderSelect(TradeIndex, SELECT_BY_POS, MODE_TRADES) ) continue; // <-- if the OrderSelect fails advance the loop to the next TradeIndex if( OrderSymbol() != Symbol()) continue; // <-- select only those on the current symbol if ( ! OrderDelete( OrderTicket())) // <-- try to delete the pending order Print("Failed to close: ", OrderTicket(), " Error: ", GetLastError() ); // <-- if the Order Delete failed print the error else { Print(StringConcatenate(Symbol()," ", OrderTicket(), " Closed")); } } // end of For loop }