› Forums › Development › Trading made REALLY Simple
This topic has been reported for inappropriate content
Tagged: Peak EA
- This topic has 455 replies, 41 voices, and was last updated 8 years, 10 months ago by
Anti.
- AuthorPosts
- December 22, 2015 at 7:36 am #10726
My simplified Clear Method Indicator, as requested. My clear method mqh lib is included in the mq4 file for convenience.
- Buffer 0: output = 1 for bullish, else 0
- Buffer 1: output = 1 for bearish, else 0
No input parameters, so iCustom() should be rather simple:
double iCustom( string symbol, // symbol int timeframe, // timeframe string name, // path/name of the custom indicator compiled program int { 0 | 1 }, // line index: 0 for bullish buffer, 1 for bearish buffer int shift // shift );Any questions welcome! s.
Thanks a lot Simplex,
Your indicator is very good. Now we can all use the same indi
December 22, 2015 at 8:34 am #10728Trade Entry point: Currently we enter pending trade AFTER bar close. If so, why enter on the High+xx (for LONG) or Low-xx (for SHORT)? We can enter a Buy-Stop at the Close+xx (Long) or Sell-Stop at Close-xx (Short). We can also enter Buy-Limit at the Close-xx or Sell-Limit at Close+xx, to get some extra pips. (or even BOTH, as KIAD suggested…) On Trailing: If our tests confirms that 5 pips trailing produce >85% winning trades: Why not exit 50% of our Lot at 5 pips profit, move SL to BE+1, and trail the rest? G.
Hi G, Can the Candle/Bar be of any type (Bull/Bear) to enter trade @ Close+xx (Buy-Stop) / Close-xx (Sell-Stop)?
Entry is by Peak/Trough breakout signal, regardless of bar type.
G.
December 22, 2015 at 9:44 am #10729Trade Entry point: Currently we enter pending trade AFTER bar close. If so, why enter on the High+xx (for LONG) or Low-xx (for SHORT)? We can enter a Buy-Stop at the Close+xx (Long) or Sell-Stop at Close-xx (Short). We can also enter Buy-Limit at the Close-xx or Sell-Limit at Close+xx, to get some extra pips. (or even BOTH, as KIAD suggested…) On Trailing: If our tests confirms that 5 pips trailing produce >85% winning trades: Why not exit 50% of our Lot at 5 pips profit, move SL to BE+1, and trail the rest? G.
Hi G, Can the Candle/Bar be of any type (Bull/Bear) to enter trade @ Close+xx (Buy-Stop) / Close-xx (Sell-Stop)?
Entry is by Peak/Trough breakout signal, regardless of bar type. G.
Okay G. Thanks!
December 22, 2015 at 11:03 am #10734That’s correct:
As per original requirement by G, can we have one rigid output buffer (1 = Buy / -1 = Sell / 0 = No action)
You’re pointing out the same detail I discussed with G. by PM: 3-bit vs. 4-bit logic. If you refer to my code:
enum CLEAR_STATE { CLEAR_NONE, // undefined condition CLEAR_BULL, // bullish condition CLEAR_BEAR // bearish condition };you will see my ‘clear’ preference for 3-bit, just like you.
In my indicator, I turned this in a 4-bit visualization following G.’s demand in his 1st post:
Peak: returns (1) for Peak, (0) for none.
Trough: returns (1) for Trough, (0) for none.That’s all. For the final EA, I would prefer to use a 3-bit logic for P&T and for trend as well. But it’s clearly the project manager’s job, not mine, to write down a demand list. For reasons that I failed to identify a 3-bit logic was turned into 4-bit in the demand post above. I followed this twist.
And sure: it’s easy to write a simple indicator that reflects this 3-bit logic, using only one buffer.
AFAIK, we’re still working on this ‘peak & trough’ part (4-bit), not at the trend part (3-bit). But I’m not sure anymore, to be honest. The problem from my personal point of view: there’s still too much confusion regarding demand management vs. coding. The fact that we’re discussing this now, more than 4 weeks after 1st post, clearly points this issue out.
I decided to let go. That means I will continue to follow this thread with interest, but will try not to get involved emotionally when things are driven in a direction that may seem a bit ‘questionable’ from a purely professional point of view. And possibly I will continue to post occasionally. Relax, simplex! Holiday season ahead

May all contributors and visitors have a peaceful Christmas Season, especially G. and V.! Thank you for driving this bus! I will check back from time to time, but maybe not so frequently as before during the holidays ahead.
s.
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
December 22, 2015 at 11:11 am #10735Thank you, @LittleCaro:
Thanks a lot Simplex, Your indicator is very good. Now we can all use the same indi
I’ve been informed by PM about discrepancies regarding my indicator on chart vs. inside backtester, called by iCustom(). Seems to be perfect on chart, but problematic in backtester.
Everybody interested, please check this and report back.
s.
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
December 22, 2015 at 11:40 am #10736
had a look , on chart it looks like its repainting when actualising the chart.
Taken into the Strategy tester..
window 1 is the added indicator while strategy tester was running…window 2 is the integrated indicator in the simple testing ea showing up after stoping the backtest
-
This reply was modified 10 years, 5 months ago by
Bartleby.
"A dream you dream alone is only a dream. A dream you dream together is a reality." (John Lennon)
December 22, 2015 at 12:12 pm #10739
AnonymousHere is my InitCS(…) multi instance version using iCustom instead as requested by some.
It can be used together with almost any currencie strenght indicator. it will calculate ob os zones and create array with trade symbol and direction if conditions are met. It does also outputs a string with some info.
more detailed info and how to use inside the file…
December 22, 2015 at 12:15 pm #10741Thanks for testing:
had a look , on chart it looks like its repainting when actualising the chart.
I would really be surprised if this was repainting (have a look at the code). I have a test running at M1, no repainted bars so far.
Re. strategy tester: I wonder whether strategy tester can cope with static variables
static CLEAR_SAVE _save[];. Maybe this causes the problems. Any ideas anybody?s.
EDIT: now I see the issue. It’s not about repainting, it’s about refreshing at bar zero. Debugging again now.
-
This reply was modified 10 years, 5 months ago by
simplex. Reason: Addendum
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
December 22, 2015 at 12:44 pm #10743had a look , window 1 is the added indicator while strategy tester was running…window 2 is the integrated indicator in the simple testing ea showing up after stoping the backtest
thank you, I thought i was going crazy cuz no one else was seeing this :)
I wonder whether strategy tester can cope with static variables
static CLEAR_SAVE _save[];. Maybe this causes the problems. Any ideas anybody? s. EDIT: now I see the issue. It’s not about repainting, it’s about refreshing at bar zero. Debugging again now.i looked up static and ea and this popped up i don’t know if its related.
“I believe the very best money is made at the market turns. Everyone says you get killed trying to pick tops and bottoms and you make all
your money by playing the trend in the middle. Well for twelve years I have been missing the meat in the middle but I have made a lot of
money at tops and bottoms.”
– Paul Tudor JonesDecember 22, 2015 at 3:09 pm #10745That’s correct:
As per original requirement by G, can we have one rigid output buffer (1 = Buy / -1 = Sell / 0 = No action)
You’re pointing out the same detail I discussed with G. by PM: 3-bit vs. 4-bit logic. If you refer to my code:
enum CLEAR_STATE { CLEAR_NONE, // undefined condition CLEAR_BULL, // bullish condition CLEAR_BEAR // bearish condition };you will see my ‘clear’ preference for 3-bit, just like you. In my indicator, I turned this in a 4-bit visualization following G.’s demand in his 1st post:
Peak: returns (1) for Peak, (0) for none. Trough: returns (1) for Trough, (0) for none.
That’s all. For the final EA, I would prefer to use a 3-bit logic for P&T and for trend as well. But it’s clearly the project manager’s job, not mine, to write down a demand list. For reasons that I failed to identify a 3-bit logic was turned into 4-bit in the demand post above. I followed this twist. And sure: it’s easy to write a simple indicator that reflects this 3-bit logic, using only one buffer. AFAIK, we’re still working on this ‘peak & trough’ part (4-bit), not at the trend part (3-bit). But I’m not sure anymore, to be honest. The problem from my personal point of view: there’s still too much confusion regarding demand management vs. coding. The fact that we’re discussing this now, more than 4 weeks after 1st post, clearly points this issue out. I decided to let go. That means I will continue to follow this thread with interest, but will try not to get involved emotionally when things are driven in a direction that may seem a bit ‘questionable’ from a purely professional point of view. And possibly I will continue to post occasionally. Relax, simplex! Holiday season ahead
May all contributors and visitors have a peaceful Christmas Season, especially G. and V.! Thank you for driving this bus! I will check back from time to time, but maybe not so frequently as before during the holidays ahead. s.Yes, the initial requirement was TWO functions, one for PEAK and one for TROUGH. Hence the requirement for returning Peak()==1 and Trough()==1.
Now we are using (I hope…) just one function for both Peak&Trough, so the differentiation is redundant, and we can use 1, -1, 0 (or 3-bit logic…).
G.
December 22, 2015 at 3:15 pm #10746
had a look , on chart it looks like its repainting when actualising the chart. Taken into the Strategy tester.. window 1 is the added indicator while strategy tester was running…window 2 is the integrated indicator in the simple testing ea showing up after stoping the backtestWhat about testing the EA in rorward test (demo account), with iCustom call on M1 for an hour or so?
This should give an answer to the “repainting” issue AFTER bar close.
G.
December 22, 2015 at 3:19 pm #10747Oooops…
Just saw that simplex beat me in the M1 testing issue…
G.
December 22, 2015 at 3:39 pm #10748Thanks for pointing me there:
i looked up static and ea and this popped up i don’t know if its related.
Interesting discussion, but different topic. They’re mainly talking about changing timeframes or pairs. When changing timeframes, I would expect a static var to be re-initialized. That’s absolutely ok, and it’s not the point in our discussion. There must be a bug in my code. I would assume it’s too simple for anyone around including me spotting it at first sight.
I coded the function with that static having in mind that it should be able to run in an indicator and in an EA.
I’m afraid I won’t have much spare time for the rest of the day, maybe for several days (Christmas, family, friends). So if any other coder might have a closer look at my logic, I certainly wouldn’t mind. That’s what this community is for. And if anyone makes this run refreshing at bar zero correctly, even better (this is the point, no traditional repainting issue)!
I will stay close. A bug in my code is rather common, but keeps nagging nontheless.
@gg53: if you’d like this technical discussion to take place in the coders’ thread, just drop a line!s.
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
December 22, 2015 at 8:19 pm #10755Thanks for pointing me there:
i looked up static and ea and this popped up i don’t know if its related.
Interesting discussion, but different topic. They’re mainly talking about changing timeframes or pairs. When changing timeframes, I would expect a static var to be re-initialized. That’s absolutely ok, and it’s not the point in our discussion. There must be a bug in my code. I would assume it’s too simple for anyone around including me spotting it at first sight. I coded the function with that static having in mind that it should be able to run in an indicator and in an EA. I’m afraid I won’t have much spare time for the rest of the day, maybe for several days (Christmas, family, friends). So if any other coder might have a closer look at my logic, I certainly wouldn’t mind. That’s what this community is for. And if anyone makes this run refreshing at bar zero correctly, even better (this is the point, no traditional repainting issue)! I will stay close. A bug in my code is rather common, but keeps nagging nontheless. @gg53: if you’d like this technical discussion to take place in the coders’ thread, just drop a line! s.
This is our MAIN indie, so it deserve its place here, untill concluded and we can agree on stable indicator.
In the meantime, someone can finalize the other pre-trading conditions functions (FFCAL, Hours, Spread, etc…).
G.
December 22, 2015 at 8:50 pm #10756Here is my InitCS(…) multi instance version using iCustom instead as requested by some. It can be used together with almost any currencie strenght indicator. it will calculate ob os zones and create array with trade symbol and direction if conditions are met. It does also outputs a string with some info. more detailed info and how to use inside the file…
Thanks slicken,
I’ll check it out during weekend.
Thanks,
G.
December 22, 2015 at 9:07 pm #10757Wish you merry Christmas, Happy Holidays and a Happy New Year!!
G.
Attachments:
You must be logged in to view attached files.December 22, 2015 at 9:18 pm #10759This is our MAIN indie, so it deserve its place here, untill concluded and we can agree on stable indicator. In the meantime, someone can finalize the other pre-trading conditions functions (FFCAL, Hours, Spread, etc…). G.
regarding the pre-trading conditions:
FFCal -> @Emonts contacted me by PM and sent me a mqh file for this with example on how to call the functions. Now he’s fixing it so it works with prefix/postfix pairs. So this one is covered.
Max. Spread -> I’ll implement this one
Trading Hours, TradeOnMonday, TradeOnFriday, FridayClose -> @slicken had implemented an IsTradeTiime() function in one of the eas that he posted here. It used StartHour and EndHour parameters. So if someone could maybe extend it so it takes also the other input parameters into consideration and returns ‘true’ if all the time conditions are met, this would be great.
Auto TP & SL -> if TP & SL = 0 -> This one is partially done. calcSL() was part of the skeleton ea you posted. calcTP() we don’t have yet. Will it be the same as calcSL() and replacing SL_Factor with TP_Factor?
V.
December 22, 2015 at 9:43 pm #10760[quote=10755]This is our MAIN indie, so it deserve its place here, untill concluded and we can agree on stable indicator. In the meantime, someone can finalize the other pre-trading conditions functions (FFCAL, Hours, Spread, etc…). G.
regarding the pre-trading conditions: FFCal -> @Emonts contacted me by PM and sent me a mqh file for this with example on how to call the functions. Now he’s fixing it so it works with prefix/postfix pairs. So this one is covered. Max. Spread -> I’ll implement this one Trading Hours, TradeOnMonday, TradeOnFriday, FridayClose -> @slicken had implemented an IsTradeTiime() function in one of the eas that he posted here. It used StartHour and EndHour parameters. So if someone could maybe extend it so it takes also the other input parameters into consideration and returns ‘true’ if all the time conditions are met, this would be great. Auto TP & SL -> if TP & SL = 0 -> This one is partially done. calcSL() was part of the skeleton ea you posted. calcTP() we don’t have yet. Will it be the same as calcSL() and replacing SL_Factor with TP_Factor? V. [/quote]
If TP == 0
tp = TPfactor * SL()
G.
December 22, 2015 at 10:04 pm #10762FFCAL ?? take this one, it’s easy and simple to implement it inside an EA like this
in the first part of the EA, for initialisation parameters
input string News_SETTINGS=”To get news, put AvoidNews to true”;
extern bool AvoidNews = True
extern bool AvoidHigh = true;
extern bool AvoidMedium = true;
extern int MinsBeforeNews =15;
extern int MinsAfterNews =15;
//////////////////////////////////////
inside the Tick function :
if(AvoidNews == true)
{
if(Minute()!=PrevMinute)
{
MinSinceNews = iCustom(symbol,WorkingTF,”FFCal_mini”,AvoidHigh,AvoidMedium,false,true,false,0,true,5,10,true,false,false,4,true,6,DeepSkyBlue,Gray,Red,Orange,Khaki,2,false,true,1,0);
MinToNews = iCustom(symbol,WorkingTF,”FFCal_mini”,AvoidHigh,AvoidMedium,false,true,false,0,true,5,10,true,false,false,4,true,6,DeepSkyBlue,Gray,Red,Orange,Khaki,2,false,true,1,1);
PrevMinute=Minute();
if(MinToNews<=MinsBeforeNews || MinSinceNews<=MinsAfterNews) ContinueTrading=false;
}
}
Attachments:
You must be logged in to view attached files.December 23, 2015 at 3:11 am #10773Hi gg53,
Wishing you and all others on the forum Merry Christmas, Happy Holidays and a
Happy New Year.
Trader7
December 23, 2015 at 7:22 am #10778I assume that you’ve realized that VPO like other common indicators is biased by trend. Thus, if we are in a strong up or down trend, we will see more often VPO values above +40/below -40. To overcome this issue maybe we should standarize it by an EMA. And thoughts?
Apropos EMA: Took a look inside VZO code posted by GG53 here. It isn’t calculated as suggested by it’s inventor (read this article). He uses EMAs but in the code I can’t see any EMA function … Has someone tried to calculate it the way described in the article by Walid Khalil?
-
This reply was modified 10 years, 5 months ago by
Anti.
December 23, 2015 at 9:10 am #10783Hi Anti
the posted indicator is using the’mathematic method’ to implement the exponential moving average..
instead of using the MT4 build-in iMA() function..
Please refer to https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
tankhang
-
This reply was modified 10 years, 5 months ago by
tankhang.
December 23, 2015 at 9:31 am #10785December 23, 2015 at 9:35 am #10786Max. Spread -> Don’t trade if Spread >max.G.
Hi G,
What is the use of checking Spread for placing Pending orders?
Merry Christmas and a Happy New Year, fellow Penguins…
Thanks!
-
This reply was modified 10 years, 5 months ago by
bharath4x.
December 23, 2015 at 9:36 am #10787No, you’re not:
I’m an idiot.
I’ve read so many good posts of yours, I’m sure you’re not!

s.
A good trader is a realist who wants to grab a chunk from the body of a trend, leaving top- and bottom-fishing to people on an ego trip. (Dr. Alexander Elder)
- AuthorPosts
- You must be logged in to reply to this topic.
