GU H1 high/low entry system?

Post Reply
guptabhk
Trader
Posts: 28
Joined: Sat Mar 03, 2012 3:29 pm

GU H1 high/low entry system?

Post by guptabhk »

Hi.
still I am getting error code 130 on few products like GBPNZD,NZDUSD,OIL,GOLD etc ,
I changed Hi Low buffer pips to 10 , then also it comes
Is there anybody who also face the same? and
any remedies please ?

thanks in advance
smpcoe
Trader
Posts: 15
Joined: Wed Jan 13, 2016 8:13 am

GU H1 high/low entry system?

Post by smpcoe »

guptabhk
Trader
Posts: 28
Joined: Sat Mar 03, 2012 3:29 pm

GU H1 high/low entry system?

Post by guptabhk »

Thanks smpcoe .
even though Steve coded 130 error solution in pip hunter, still problem persists , i think i have to enter manually at that time .
anyhow thanks for your reply and link.
User avatar
themaxx
Trader
Posts: 71
Joined: Thu May 24, 2012 9:57 am

Code my H1 high/low entry system?

Post by themaxx »

Hi, could someone please give me a steer in the right direction? I'm trying to amend the code so that the EA only opens one trade in each direction. Currently the EA opens a new trade in each direction every day, I want to change it so that if there is an long open from yesterday, it won't open a new long today. I thought I could do this by commenting the code as set out below, but I tried it this morning and I still got new trades. Am I missing something please? I stepped through the code in my head and can't see what I'm missing.
SteveHopwood » Thu May 05, 2016 5:03 pm wrote: There is a line that you will need to comment out should you wish to enable the management features, so do a search for this line of code:

Code: Select all

if (OrderOpenTime() < iTime(Symbol(), PERIOD_D1, 0)) continue;//Only interested in today's trades. This needs refining.
and comment it out with the '//' symbol:

Code: Select all

//if (OrderOpenTime() < iTime(Symbol(), PERIOD_D1, 0)) continue;//Only interested in today's trades. This needs refining.
This line of code prevents PH from including open trades from previous days being considered for any of the management functions.
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.

Code my H1 high/low entry system?

Post by SteveHopwood »

themaxx » Fri Jun 03, 2016 4:09 pm wrote:Hi, could someone please give me a steer in the right direction? I'm trying to amend the code so that the EA only opens one trade in each direction. Currently the EA opens a new trade in each direction every day, I want to change it so that if there is an long open from yesterday, it won't open a new long today. I thought I could do this by commenting the code as set out below, but I tried it this morning and I still got new trades. Am I missing something please? I stepped through the code in my head and can't see what I'm missing.
SteveHopwood » Thu May 05, 2016 5:03 pm wrote: There is a line that you will need to comment out should you wish to enable the management features, so do a search for this line of code:

Code: Select all

if (OrderOpenTime() < iTime(Symbol(), PERIOD_D1, 0)) continue;//Only interested in today's trades. This needs refining.
and comment it out with the '//' symbol:

Code: Select all

//if (OrderOpenTime() < iTime(Symbol(), PERIOD_D1, 0)) continue;//Only interested in today's trades. This needs refining.
This line of code prevents PH from including open trades from previous days being considered for any of the management functions.
I will show you what to do in time for next week.

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

GU H1 high/low entry system?

Post by SteveHopwood »

Here beginneth the lesson. Use the attached PH so we are both talking about the same line numbers.

CountOpenTrades() sets the variable BuyOpen to 'true' if there is a market buy trade and SellOpen to 'true' if there is a market sell trade open. Ditto Buy/SellStop trades - BuyStopOpen etc.

Look at lines 1633 - 1655. These lines are saying, "If there are neither a market buy or a pending buy stop trade in place, then send some sort of long trade.

Taking a buy trade as an example, line 2076 finds a market buy trade open, and so sets BuyOpen to 'true'. That takes care of line 1633. The code will abort here if there is an open market buy.

Then line 2965 detects a buy stop on the chart and sets BuyStopOpen to 'true'. So, if the filter at 1633 passed, then that at 1644 will fail and the bot will not attempt to take a trade. The code will only continue if there are no sort of buy related trades on the platform.

Suppose, as does PH, you have extra filters that only apply to trading in one specific direction. That is where the block starting at 1639 comes in. They stop any long trade that fails any of the filters that are applied to it. Here is where you can add your own. Stochastic not the correct value? Add it here. You mistakenly favourite CCA (I am sure this does not apply to you)? Add it here.

Suppose you do not want a new buy trade today after one has already closed? You define a new function, say bool HasTradeAlreadyClosedToday(int type) - where type == OP_BUY. This iterates through the History tab and returns 'true' if it finds a market buy trade that closed today and 'false' if not.

Then:

Code: Select all

if (HasTradeAlreadyClosedToday(OP_BUY) ) return; 
aborts the trading.

Mind, you then get into the pain of what is 'today' to you and 'today' to your broker. Your OrderCloseTime() is 'today' or 'yesterday' etc to your broker; it may well have fuck all to do with 'today' or 'yesterday' etc to you. Global Prime, for example, starts a new D1 candle at 22.00 London time; this is still 'today' to me. Good luck sorting that little lot out; all you can do is the best you can for yourself.

Define new functions where ever possible rather than contain the code within another function as this makes it easier to port code over to new applications. I am not great at this, but am getting better. The 'proper coders' here probably bang their heads on the table every time I post some code. I Try my best. :lol:


That takes care of the immediates.

-----------------------------------------------------------------------------------------

Go back to line 1622:
if (!IsTradingAllowed() ) return;

bool IsTradingAllowed() starts at line 1319 and is a catch-all function that disables trading altogether under a variety of different circumstances. There you see how I add anything that will stop trading altogether.

----------------------------------------------------------------------------------------

I hope this helps. Sing out if you need any extra info. Feel free to post your code here - one of us will confirm or correct it for you; we all want to encourage people to learn this stuff for themselves.

:xm:
You do not have the required permissions to view the files attached to this post.
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
themaxx
Trader
Posts: 71
Joined: Thu May 24, 2012 9:57 am

GU H1 high/low entry system?

Post by themaxx »

OK, I followed all your line references (I even spotted a reference to 2076 which should have been 2876 - I am paying attention ;) ).

As you said - 1633 - 1655 - lines are saying, "If there are neither a market buy or a pending buy stop trade in place, then send some sort of long trade.

So that's how I want the new robot to work, only take new long if there's no existing open long or pending long.

But I know I requested that the robot ignore previous days trades. So there must be a check somewhere in the code where previous day's trades are filtered out for the purposes of checking if there is an open buy/sell.

So 1633 checks "BuyOpen" - I need to be look at where the code switches this variable from true to false.

At 2733 CountOpenTrades() sets BuyOpen to false, then iterates through the open trades.

I can see this:
2818 if (OrderOpenTime() < iTime(Symbol(), PERIOD_D1, 0)) continue;//Only interested in today's trades. This needs refining.

Then I looked at:
https://book.mql4.com/operators/continue

So I converted the above code in my head as:
if the time of the trade being checked is earlier than today's day, then skip that trade and continue
ie 3 Jun 2016 < 4 June 2016, skip 3 Jun trade

So that seems to be the line filtering out previous day's trades from the is there an open trade check. So I should be able to delete that line, and the robot will iterate through all trades when it does an open trade check. But I tried that, and it didn't work for me. Am I missing something?
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.

GU H1 high/low entry system?

Post by SteveHopwood »

If you comment out line 2818, then BuyOpen is set to 'true' at 2876 so the EA cannot send a fresh trade.

You would need to add an extra conditional, so the snippet at 2876 would become:

Code: Select all

if (OrderOpenTime > iTime(Symbol(), PERIOD_D1, 0) )
        BuyOpen = true;
Here is where it gets messy: iTime(Symbol(), PERIOD_D1, 0) ) returns the start of the broker's D1 candle. That may or may not be 'today' so far as you are concerned.

My EA's do not hve broker and local times shown on the charts because I think people do not have clocks. The have two functions:
  • show users the ea is still working.
  • enable people to work out the time difference between local and broker time - not at the weekend though, only when the broker is open.
To be absolutely certain that an open trade belongs to yesterday and your broker and local times are different calls for a bit of coding. Something like this:

Code: Select all

   int TimeDifference = TimeCurrent() - TimeLocal();//Time difference in seconds
   TimeDifference/= 3600;//Convert to hours
   int day = TimeDayOfWeek(OrderOpenTime());
   int hour = TimeHour(OrderOpenTime());
   hour+= TimeDifference;//Doesn't matter whether +ve or -ve
   if (hour < 0)
      day-= 1;
   if (hour > 23)
      day+= 1;
      
   if (day == TimeDayOfWeek(TimeLocal()))
      BuyOpen = true; //Trade opened today
  
Don't know if the above will work, but it gives you a starting point.

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

GU H1 high/low entry system?

Post by SteveHopwood »

I have added DMI timeframe inputs to the indi and EA in post 3.

: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
themaxx
Trader
Posts: 71
Joined: Thu May 24, 2012 9:57 am

GU H1 high/low entry system?

Post by themaxx »

I've just realised that I've been extremely unclear in what I'm trying to achieve.
SteveHopwood » Sat Jun 04, 2016 3:50 pm wrote:If you comment out line 2818, then BuyOpen is set to 'true' at 2876 so the EA cannot send a fresh trade.
Yes, this is exactly what I want. I want to simplify the robot so it only takes 1 buy trade and 1 sell trade. I want it to include previous days trades when it runs its checks to see if there are open trades, and then stop entering fresh trades.

I commented out 2818, there was an open buy yesterday, and it entered an open buy today - I don't understand why that would happen? Maybe I made a mistake, I will try this again. Please don't waste any more time on this I'm sure I'll work it out on my own.
Post Reply

Return to “Automated trading systems”