The Hidden Pending EA

MPTM's new home
Post Reply
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

The Hidden Pending EA

Post by milanese »

This is little helper, it sets a "hidden" pending Buy and/or Sell order at the prices you set, the advantage is, that it has a spread control (working automatic) for avoiding entries with spikes, and to you can define with MaxDiffPrice how much pips you are willing to accept as difference for executing the order to the pending price( this should be at least 1.5* the average spread).
MaxSpreadAllowedMultiplicator=1 just set this to value you want the OOTB will only allow to fill the order if the actual spread is not higher as the average spread, setting it to 2 at exp. and the EA will fill the order if the actual spread is not higher as 2 times the average spread..
RemoveEA_afterFilling if you set this to true the EA is removed after the filling of your pending order, set it to false if you will use the possibility of stacking trades

UseStacking if this is set to true the EA will in distance of the pips you set with StackingLevel set a new pending order in trade direction after a pending order is filled. With MaxOpenPositions you set the max positions the EA can open.

DeleteOppositeAfterFillif you set this true, after filling a BUY the SELL pending is deleted and viceversa. Set this to false and the EA will not delet the opposite order, if you use stacking the EA can now to follow the price in the other direction.
With SL and TP you can set SL and TP levels.
If you set UseStacking to false MaxOpenPositions is automatic set to 1 ( or to 2 if you have set DeleteOppositeAfterFill to true , so you can be sure the EA will only fill one (or two) order(s), so there is not really a need to set RemoveEA_afterFilling to true, note if you set this to true the EA set with ECN brokers no SL or TP..
UseCloseFriday, if you set this to true the EA will close all orders opened by this EA at FridayCloseHour you set (used is the broker time)
***NEVER CHANGE THE TIMEFRAME ON THE CHART YOU HAVE ATTACHED THE EA***
Enjoy and let me know if you want new functions :)
Update Aug. 22, 2014 see here http://www.stevehopwoodforex.com/phpBB3 ... 316#p98316
update oct.27, 2014
New you can set a different lotsize for stacktrades with LotForStackPositions
and see http://www.stevehopwoodforex.com/phpBB3 ... 77#p101477
New Version nov. 8,2014
with RemoveEAcode updated to work with last builds, new function CheckForOpenTrades that avoids wrong pendingprices when EA is reintialised, but you should still never change the TF on the chart the EA is set , and new MoveOppositeOrderWithPrice that moves the price from the opposite order if this is wished, use OppositeMoveLevel to set the pip value that the HiddenPendingOrder will be moved and MinDistanceForOppositeMoveToPrice for setting the min distance the new OppositePendingOrder must have to the actual price..
new version nov. 29,2014
As asket from Over60 the EA has now an new input showUserDisplay to show or not show the userDisplay, too some minor fixes in the orderhandling code given again more security for the orderhandling.
New the EA will add the actual spread to the ordercomment.
new version dic.1,2014
As from many useres wished the EA has new a jumping/trail stop function integrated.
Use_SetBEAndJumpset this to true if you want to use the function
BEProfitPips added to OpenPrice for BE
JumpStepPipis the SL will be moved with every trail step
SLMinDistanceToPricethis distance must the moved SL have to the actual price

new version dic.4,2014
New input MoveSLOnlyIfWin if set to true the SL will only be moved after the EA has set the BE and the position is in profit(this is OOTB and is same as prior version did use the JS). If you set it false the SL distance to actutal price will alwyas be the initial SL-distance, that is why the EA automatic sets SLMinDistanceToPrice to the SL value ( as this will make no sense if your SL is 0 the EA will set in this case the SL to 30 pips).
new version jan. 20,2015
New is partclose on BE option PartCloseEnabled, if you set this to true and Use_SetBEAndJump is true, the EA will close the % you selcted with PartClosePercent when setting the BE.
21 jan.,2015 some fixes..and partclose new to for stacking-trades working
26 jan.,2015
New version, now the EA does to work in a case of reinitializing (if ever possible avoid any reinitializing of the running EA) again better, as in case of DeleteOppositeAfterFill is seleted, the EA will recognize this.
The new HiddenPending EA has much more functionality as requested from Roger:
manageAllTradesInThisPair the EA will use the moving SL functions for all open trades in the pair you have the EA attached.
SLMinDistanceToPrice, SL, TP, StackingLevel and InitialDistance for the pendings can new be used with the ATR, all have seperat , selfexplaining inputs for this, so you can select this for all or only one, or more, of them, you can select for each one different ATR TimeFrame and Period and of course set an ATR multiplicator for each of them you like. The SLMinDistance and the StackLevel will be shown you in the user Display in pip values.
If something is not clear please ask you question here in the thread, as it could be usefull for others too.
31 jan. 2015
New is there a PartClose as First TP function. You can select this if you have PartCloseEnabled set to true and PartCloseAsFirstTP set true. PartCloseFirstTpPips set here the pips the order must be in win for the PartClose.
New is too the possibility to deactivate all ATR inputs with one input this was asked from useres for making the ATR functions more easy to handle DoNeverUseATR set this to true, and the EA will use all your manual inputs, if it is set to false, you can select which calculation you want done by ATR and for which you want to use your manual inputs.
feb. 8, 2015
NewVersion with a new option to "trail" the automatic with DistancePendingToPrice calculated Buy/Sell Stop prices. If you have at exp initial a PendingBuyPrice 1,54000 DistancePendingToPrice is selected with 50 pip (so Price by setting the initial Pending was 1,53500) the PendingBuyPrice will be moved if Price goes down to 1,53000 to 1,53500. This gives the EA again more flessibility.
The inputs for this new option are:

Code: Select all

extern string   dyn="----Dynamic Initial Pending Move Options----";
extern string   dyn1="----This is only working with AutoBuySellStop----";
extern bool    movePendingBuyDownIfPriceMovesDown=false;
extern bool    movePendingSellUpIfPriceMovesUp=false;
Analog to the APTM and all newer EA coded by me the UserDisplay is updated.
new input showDisplayBox=true if you set this to false, you see the user-display in the "old" way, without box and transperency, so tou have now three possibilities:
-NewBoxDisplay Design
-Old fashion style with transperency UserDisplay
-Display will not be shown
The display is too more informativ, to make the use of this EA a little bit easier.
This version includes too some fixes and update to property strict code.
Feb. 12, 2015
New version fixes a problem in cases order could not be filled by broker, the EA will now handle this event correct and retry to fill the order, thanks to jauhar spotting this problem! Too the MaxSpreadAllowedMultiplicator is now a double so that you can set values like 1.2 ecc

Feb. 14,2015
Some fixes, for error cases, to handle this very rare cases correct, some cosmetic updates making the UserInfo more informativ. Note the EA will run without any problems in all builds higher 745.
Feb. 18,2015
NewVersion, like Over60 asked the HPEA has now a new input RemoveEAAfterClosingLastEAPos if you set this to true (it is OOTB true) the EA will remove itself from the chart after the last open trade with magicNumber the EA uses is closed, avoiding with some settings"endless trading".
Feb. 21,2015
new version, new the HPEA as PairBasket functions embedded.
The new inputs were:

Code: Select all

extern string   pBasketSet="---PairBasket Management inputs----";
extern string   pBasketSet1="---Values are in AccountCurrency----";
extern bool   UseCloseAllOfPairInProfit=true;
extern double CloseAllOfPairInProfit=75;
extern bool   UseCloseAllOfPairInLoss=true;
extern double CloseAllOfPairInLoss=50;
Feb. 23,2015
New previous candle high/low function for the initial pending order as optional, note this function if set to ture overrides all other price input options. You should for using this set DeleteOppositeAfterFill to true (this is OOTB set to true), so after filling the opposite pending will be delted. I f you wish you can set the HPEA to move every new candle the hidden pending orders, if not filled to the next previous candle.
The new inputs for these functions are:

Code: Select all

extern string   pen1="----Use previous candle High/low for initial Pending----";
extern string   pen2="----using this overrides all other initial PendingPrice settings----";
extern bool    useCandleHighLowForInitial=false;
extern int     TimeFrameForCandleHL=PERIOD_M15;
extern bool    SetNewEveryNextIfNotFilled=true;
march 3rd, 2015
Mop asked for the option to manually move / adjust the initial buy / sell line on chart.That is: double click on Buy pending line, move it, double click again to fix position, then update respective values?
This is now added if you set HPendingsPricesCanBeMovedByUser you can double click on the PendingLine on the chart move it to your wished value, again double click and voilà the HPEA uses now this value for your Pending Order..
Thanks Mop for this very good idea, makes the HPEA again more flexible and userfriendly...
march 4th,2015
the function that moves the SL if MoveSLOnlyIfWinis set to false, is recoded for avoiding with some settings strange behaviour, thanks to a spot from Over60. No this function should work under all circumstanzes perfect.
march 5th,2015
added a new function selectable by user read too this post ---> http://www.stevehopwoodforex.com/phpBB3 ... 21#p116621
Set FixedDistanceToOpposite to true if you want after filling the opposite order to a preselected distance and FixedDistanceOppositePips for setting the distance value.Note the EA will record this to if a restart should be necessary.
march 17th,2015
update fixing a problem in the FixedDistanceToOpposite option, caused by a missunderstanding, how this function should work, now this option affects only the initial oppositetrade, but not eventualy stacking trades.
march 18th,2015
update adding a CandleHighLowBuffer set this to the pips the price must supperate the candle high/low to get the order filled
New you can select if you want only use the High or the Low or both for the useCandleHighLowForInitial
function, note this functions is only for the first EA trade valid (if there is no other trade on the symbol with the EA magicnumber open) and overrides in that case your other settings.
SetNewEveryNextIfNotFilled will only move the pending prices if the last high was lower and vice versa.. see ---> http://www.stevehopwoodforex.com/phpBB3 ... 54#p117654
too some little fixes done in the code
march 20th,2015
Added new optional to move SL to BE with the PartClose as firstTP independend of the SLMinDistanceToPrice
To use this optional (OOTB ist is deactivated) set SetBEonPartCloseFirstTP to true. Note you must have enabeled PartCloseAsFirstTP and PartClose in general must be enabeled..
march 21th,2015
Added new optional PartCloseAsSecondTP, this function will reaching PartCloseSecondTpPips do again a PartClose, not it activates automatic PartCloseAsFirstTP and deactivates Use_SetBEAndJump. You can select SetSLToFirstTP to true and the price will be moved to the firstpartclose point, or if this is false the price will be moved to BE.Note you must enable partclose in general for this option.
march 24th,2015
added more flexible inputs for the PartClosePercent selections, new user can define for FirstTp-,SecondTP- or BE-PartClose different values.
march 31th,2015
UserDisplay updated showing more ATR informations, as requested from some users
apr. 8th,2015
@fullaforex asked together with other users for hiddenSL/TP functions, this is with the new version added, the new inputs are:

Code: Select all

extern string   hiddenSet="---Hidden SL/TP-Management inputs----";
extern string   hiddenSet1="---Note if you use HiddenTM PCSecondTP will be auto deactivated----";
extern string   hiddenSet2="---Note if you use HiddenTM PartCloseWithBE will be auto deactivated----";
extern bool    useHiddenTM=false;
extern color SLColor = clrRed;
extern color TPColor = clrLime;
extern bool  DoTrail=true;
extern bool  ShowInfoAlerts=true;
The hiddenSL/TP functions are OOTB deactivated, you must set useHiddenTM to true if you want use them.
As this functions will automatic any SL/TP shown in the platform set to 0 please do not use this setting together with the APTM.
Note you can manual always enter a new SL/TP for your open HPEA trades in the platform the hiddenfunctions will automatic take your new values and reset the platform SL/TP to 0.
apr.13,2015
update for the hidden SL/TP function as asked from some users you can now let the HPEA set an emergency SL/TP set useEmergencySLTP to true and enter with emergencySL and emergencyTP your wished values in pips.
Too the hidden SL/TP lines will be in the new version in case of manual closes correct updated (there where some cases in the 177 build the HPEA did not update them correct (was only a cosmetic not a functional problem)
apr.14,2015
update to have the possibility, to get push- or email alerts when a pending order is filled, use the new inputs for selecting this:

Code: Select all

extern string Al1="--- FilledPending-Alerts ---";
extern bool   PopAlerts=true;
extern bool   PushAlerts=true;
extern bool   EmailAlerts=true;
apr.26,2015
update indtroducing one click buttons to set a hidden BUY or SELL pending anytime, or to change the actual present pendings.
USDCADH4.png
The pendings will use the actual price +/- DistancePendingToPrice value, this can be your manual set value or the ATR based automatic value depending on your setting. For the new function OOTB set to true we have the following new inputs:

Code: Select all

extern string   button="----Button-Order inputs----";
extern bool    UseButtonsForSettingPendings=true;
extern bool    SetButtonStopOrder=true;
extern bool    SetButtonLimitOrder=false;
So you can decide wether your orders will be stop or limit orders. Note you can not set both to true.
apr.30,2015
Little update presenting a possibilty for the user to decide if she/he wants the EA to reinitialize after the last HPEA trade is closed or to stay with the stack pending order so far not filled. OOTB the HPEA is set to reinitialize in this case if you set ReInitializeIfAllEaTradesClose=false the EA will not touch eventually existing pending orders after the last HPEA trade is closed.
may 10,2015
update, presenting a one click input box for entering the DistanceToPrice for the one click BUY and SELL buttons. Just click on the blue box, enter your wished value in pips, hit RETURN and the HPEA will use this value for setting the Pending orders. Note this deactivates automatic the ATR calculation of this value, if you had this before selected. Too in the new version has some minor fixes making the HPEA more stable.
HPEA_1.png
***AVOID CHANGING THE TIMEFRAME ON THE CHART YOU HAVE ATTACHED THE EA***
may 28,2015
update, new the HPEA can use for all trades of a pair one TP for all SELL trades and one TP for all BUY trades, set for this useONE_TP_forALL=true and enter with TP_allBUY and TP_allSELL your TP prices, note the EA has a security function avoiding impossible TP the minDistance for the collective TP must be 10 pips to the actual price.
june 5,2015
update thanks to an obervation of in many cases unwished behviour so far by the HPEA, if user selected to allow stack-trades in both directions.. by @Over60:
you will find a new user input AvoidInRetracingDoubleOrders=true if this is true the HPEA will , if you had allowed trades in both directions, or only in one, avoid to enter in price retracing phases at simil levels the EA has already trades open.
june 30,2015
update adding a deleteALLPendingorders Button..
AUDNZDM30.png
aug 16,2015
update adding a new function showing the pairBE-line, it is the skyblueline you see in the exampel picture
USDCHFH4.png
jan 21,2016 v1.96
update alerting if wished if a trade was not filled because of too high spread...
the new setting is:
AlertIfTradeNotFilled=true setting this to false will disable these alerts

feb 9,2016 v1.98
fixes some glitch in the AvoidInRetracingDoubleOrders function, too screen-snappies are added files are stored in the MQL4/Files folder of the platform.

feb 19,2016 v1.99
New Trailing is more flessible as you have the possibility for different SLMinDistance inputs for the BE setting and the JumpingStop function, as always you can let HPEA let this calculate with the ATR.
These are the modified inputs:
SLMinDistanceToPriceBE pips NewSL at BE must have distance to price
SLMinDistanceToPriceJS pips NewSL after moving SL must have distance to price
atrMultiplicatorForSLMinDistanceToPriceBE
atrMultiplicatorForSLMinDistanceToPriceJs these are used if you let the HPEA automatic second ATR calculate.
Note: It is not allowed to publish this EA outside of this SHF board!!
TheHiddenPendingEA_199.mq4
TheHiddenPendingEA_199.ex4
Usefull ATR indicator from Mopthehop, helping you to understand better the ATR settings
ATR in Pips+MA.mq4
ATR in Pips+MA.ex4
As always ask, if you have problems to understand all functions..
A good read is over60's post, to understand how to use the EA---> http://www.stevehopwoodforex.com/phpBB3 ... 46#p109446

Cheers :)

Tommaso
You do not have the required permissions to view the files attached to this post.
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

[Bugfix]TheHiddenPendingEA

Post by milanese »

milanese » Tue Apr 22, 2014 11:15 am wrote:This is little helper, it sets a "hidden" pending Buy and/or Sell order at the prices you set, the advantage is, that it has a spread control (working automatic) for avoiding entries with spikes, and to you can define with MaxDiffPrice how much pips you are willing to accept as difference for executing the order to the pending price( this should be at least 1.5* the average spread). You can set a SL and a TP for your pending trade.
The internal pending order is deleted after execution. Please test it first out on a demo account!
If you want additional functions let me know :)

Cheers :)

Tommaso
there was a problem in the logic now fixed in first post, please redownload all..

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
putusernamehere
Trader
Posts: 107
Joined: Fri Nov 15, 2013 8:56 pm

TheHiddenPendingEA

Post by putusernamehere »

Hi Tomasso :hi:

Code: Select all

 if(SignalSell==true)
           {
           

               tp=Bid-TP*Point;
               sl=Bid+SL*Point;

               Alert("Attempting to buy ",lotForOrder," of ",Symbol());
               Print("Attempting to buy ",lotForOrder," of ",Symbol());
there is an error, must be Attempting to sell :)

Cheers Gunter :hi:
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

TheHiddenPendingEA

Post by milanese »

putusernamehere » Tue Apr 22, 2014 5:51 pm wrote:Hi Tomasso :hi:

Code: Select all

 if(SignalSell==true)
           {
           

               tp=Bid-TP*Point;
               sl=Bid+SL*Point;

               Alert("Attempting to buy ",lotForOrder," of ",Symbol());
               Print("Attempting to buy ",lotForOrder," of ",Symbol());
there is an error, must be Attempting to sell :)

Cheers Gunter :hi:
Good spot :good:

fixed version in post 1...

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
putusernamehere
Trader
Posts: 107
Joined: Fri Nov 15, 2013 8:56 pm

TheHiddenPendingEA

Post by putusernamehere »

Hi; Tommaso :hi:

i have on my demo test the EA and he open a lot of trades when i change the timeframe,
could it unload itself from the chart, after a pending order is filled?


Thank you :hi:
Cheers Gunter
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

TheHiddenPendingEA

Post by milanese »

putusernamehere » Thu Apr 24, 2014 6:46 pm wrote:Hi; Tommaso :hi:

i have on my demo test the EA and he open a lot of trades when i change the timeframe,
could it unload itself from the chart, after a pending order is filled?


Thank you :hi:
Cheers Gunter
This is a good idea :good: I will later post an update..

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

[UPDATE]TheHiddenPendingEA

Post by milanese »

I updated the EA in the first post, new the EA is removed from the chart after a pending order is filled..

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
User avatar
putusernamehere
Trader
Posts: 107
Joined: Fri Nov 15, 2013 8:56 pm

TheHiddenPendingEA

Post by putusernamehere »

Hi; :hi:
Thank you Tommaso :yahoo: you are a hero :good: you are so fast

Cheers Gunter :hi:
ace81
Trader
Posts: 44
Joined: Thu Dec 26, 2013 6:31 pm

TheHiddenPendingEA

Post by ace81 »

Hi Tommaso

Is that anyway we can put multi level?
Like that we can use it on .xxx and .050 level, so the profit can be secure on the run :smile:
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

TheHiddenPendingEA

Post by milanese »

ace81 » Fri Apr 25, 2014 5:25 am wrote:Hi Tommaso

Is that anyway we can put multi level?
Like that we can use it on .xxx and .050 level, so the profit can be secure on the run :smile:
You would like to have a kind of stacking function ?
So if you entered a pending, than you want if price goes in your direction open every xx pips for a user defiened max new positions?

Cheers :)

Tommaso
Global Prime is the official SHF broker :yahoo:
Searching for Servers and Workstations with individual configuration?
Just PM
:smile: Click here to go to the BoardKnowledgeBase
NOTE: Cookies and JavaScript are required for the using the board, with full functionality
Post Reply

Return to “Utilities Indicators and Scripts”