Hello Experts
I dare to bother you since I found on this forum what I was looking for: an EA that allow me to manage an open trade taking partial profits.
I tried latest version I found on this long thread, MTP_1.9.mq4, with the intention to close 50% of a 4 miniLots trade when price reach desired TP level and move remaining 50% to BrakeEven.
These are parameters I defined:
extern string PreSet_Name = "Default";
extern int First_TP = 100;
extern int Second_TP = 0;
extern int Third_TP = 0;
extern int TP_Increment =0;
extern double Close_Lots = 0.02;
extern int Close_Method = 1;
extern int First_Stop_Target = 100;
extern int First_Stop = 0;
extern int Second_Stop_Target = 0;
extern int Second_Stop = 0;
extern int Third_Stop_Target = 0;
extern int Third_Stop = 0;
extern int Trail_Stop_By = 0;
extern int Max_Loss = 40;
extern bool Alert_Sound = true;
extern bool Alert_Email = false;
extern int Magic_Number=0;
BUT problem is that EA is immediately closing whole trade as soon as I enable EA. I tried to understand code to see if I could fine something to adjust but, since I am not mql4 coder, I could not find anything.
I would appreciate any help/support on this matter... thank you
MPTM's new home
-
dudest
- Trader
- Posts: 1847
- Joined: Tue May 08, 2012 2:37 pm
Re: MPTM's new home
Hallo,rafo05 wrote:Hello Experts
I dare to bother you since I found on this forum what I was looking for: an EA that allow me to manage an open trade taking partial profits.
I tried latest version I found on this long thread, MTP_1.9.mq4, with the intention to close 50% of a 4 miniLots trade when price reach desired TP level and move remaining 50% to BrakeEven.
These are parameters I defined:
extern string PreSet_Name = "Default";
extern int First_TP = 100;
extern int Second_TP = 0;
extern int Third_TP = 0;
extern int TP_Increment =0;
extern double Close_Lots = 0.02;
extern int Close_Method = 1;
extern int First_Stop_Target = 100;
extern int First_Stop = 0;
extern int Second_Stop_Target = 0;
extern int Second_Stop = 0;
extern int Third_Stop_Target = 0;
extern int Third_Stop = 0;
extern int Trail_Stop_By = 0;
extern int Max_Loss = 40;
extern bool Alert_Sound = true;
extern bool Alert_Email = false;
extern int Magic_Number=0;
BUT problem is that EA is immediately closing whole trade as soon as I enable EA. I tried to understand code to see if I could fine something to adjust but, since I am not mql4 coder, I could not find anything.
I would appreciate any help/support on this matter... thank you
I could be wrong, but those settings are not MPTM's...
Are you sure you are using MPTM? (see first post of this thread)
If yes, please post your full set file
CHeers
-
Leofitz
- Posts: 2
- Joined: Mon May 27, 2013 3:58 am
Re: MPTM's -Settings for Percentage Profit Trail
Could someone take a look at my settings and suggest what alterations in the settings I should make to accomplish the closure of all open trades using a profit percentage trailing stop? I read the MPTM directions and have tested this a couple times but can't get the right combination of settings.
I selected the Basket trade settings group=true and selected 'Manage by Comments' to enable this. I left the Comments line blank, as all comments in my manually set trades had no comment.
My choice of settings was intended to begin a trailing profit stop on all open trades at $400 with a 75% profit trail. The terminal close basket profit level was $900.
I also turned on Global Order Closure at $1000 as a backup, and Shirt Loss Protections to -$300
The set file settings are below. Any suggestions will be appreciated. Thanks!
ManagementStyle=You can select more than one option
ManageByMagicNumber=0
MagicNumber=0
ManageByTradeComment=1
TradeComment=
ManageByTickeNumber=0
TicketNumber=0
OverRide=ManageThisPairOnly will override all previous
OverRide2=or can be used in combination with 1 of above
ManageThisPairOnly=0
OverRide1=ManageAllTrades will override all others
ManageAllTrades=1
bl1=---------------------------------------------------------------------
ManagementFacilities=Select the management facilities you want
slf=----Stop Loss & Take Profit Manipulation----
BE=Break even settings
BreakEven=0
BreakEvenPips=30
BreakEvenProfit=2
JSL=Jumping stop loss settings
JumpingStop=0
JumpingStopPips=30
AddBEP=1
JumpAfterBreakevenOnly=0
pcbe=PartClose settings can be used in
pcbe1=conjunction with Breakeven settings
PartCloseEnabled=0
Close_Lots=0.02000000
Preserve_Lots=0.02000000
TSL=Trailing stop loss settings
TrailingStop=0
TrailingStopPips=5
StopTrailAtPipsProfit=0
StopTrailPips=0
ITSL=Instant trailing stop loss settings
InstantTrailingStop=0
InstantTrailingStopPips=30
StopInstantTrailAfterBreakEven=0
StopInstantTrailAtPipsProfit=0
StopInstantTrailPips=0
MSLA=Add a missing Stop Loss
AddMissingStopLoss=0
MissingStopLossPips=200
MTPA=Add a missing Take Profit
AddMissingTakeProfit=1
MissingTakeProfitPips=200
bl2=---------------------------------------------------------------------
GOC=----Global order closure settings----
GlobalOrderClosureEnabled=1
IncludePendingOrdersInClosure=0
ProfitInDollars=1
DollarProfit=1000.00000000
ProfitAsPercentageOfBalance=0
PercentageProfit=10000.00000000
bl9=---------------------------------------------------------------------
bin1=----Basket trade settings----
bin2=Set ManageByMagicNumber or
bin3=ManageByTradeComment to true
bin4= to use these features
ManageBasketTrades=1
bin5=Basket take profit settings
BasketClosureTP=1
BasketTPinDollars=1
BasketDollarTP=900.00000000
BasketTPasPercent=0
BasketTpPercentage=1.00000000
AutoCalcBasketTPasPercent=1
FourToSevenTradesPercent=1.00000000
EightToTwelveTradesPercent=2.00000000
ThirteenPlusTradesPercent=3.00000000
bin6=Basket stop loss settings
BasketClosureSL=0
BasketSLinDollars=0
BasketDollarSL=100000.00000000
BasketSLasPercent=0
BasketSLPercentage=1.00000000
bin13=Basket jumping stop settings
BasketJumpingStop=0
BasketJumpingStopProfit=1.00000000
BasketAddBEP=1
BasketBreakEvenProfit=0.10000000
DisableBasketJumpStopAfterBE=0
bin7=Basket trailing stop settings
BasketTrailingStop=1
BasketTsAtProfit=400.00000000
BasketTrailPercent=75
bin8=Immediate basket closure setting. Use with care
BasketCloseImmediately=0
bin9=Trade expiry settings
TradesWillExpire=0
TradesWillExpireMins=210
bl3=---------------------------------------------------------------------
hs=----Hedge settings----
HeadgeEnabled=0
HedgeAtLossPips=0
HedgeTradeStopLoss=0
HedgeTradeTakeProfit=0
HedgeMultiplier=2.00000000
CloseAtBreakEven=1
Ins14=Trend filter choices
UseEnvelopeTrendFilter=0
LookBackBars=3
UseAdxTrendFilter=0
AdxPeriod=14
UseCandleDirection=1
LookBackCandleHours=3
bl5=---------------------------------------------------------------------
sps=----Shirt-protection settings----
spsi=Close all open trades at this $ loss
ShirtProtectionEnabled=1
MaxLoss=-300.00000000
IncludePendingInClosure=0
bl6=---------------------------------------------------------------------
OtherStuff=----Other stuff----
ShowAlerts=1
I selected the Basket trade settings group=true and selected 'Manage by Comments' to enable this. I left the Comments line blank, as all comments in my manually set trades had no comment.
My choice of settings was intended to begin a trailing profit stop on all open trades at $400 with a 75% profit trail. The terminal close basket profit level was $900.
I also turned on Global Order Closure at $1000 as a backup, and Shirt Loss Protections to -$300
The set file settings are below. Any suggestions will be appreciated. Thanks!
ManagementStyle=You can select more than one option
ManageByMagicNumber=0
MagicNumber=0
ManageByTradeComment=1
TradeComment=
ManageByTickeNumber=0
TicketNumber=0
OverRide=ManageThisPairOnly will override all previous
OverRide2=or can be used in combination with 1 of above
ManageThisPairOnly=0
OverRide1=ManageAllTrades will override all others
ManageAllTrades=1
bl1=---------------------------------------------------------------------
ManagementFacilities=Select the management facilities you want
slf=----Stop Loss & Take Profit Manipulation----
BE=Break even settings
BreakEven=0
BreakEvenPips=30
BreakEvenProfit=2
JSL=Jumping stop loss settings
JumpingStop=0
JumpingStopPips=30
AddBEP=1
JumpAfterBreakevenOnly=0
pcbe=PartClose settings can be used in
pcbe1=conjunction with Breakeven settings
PartCloseEnabled=0
Close_Lots=0.02000000
Preserve_Lots=0.02000000
TSL=Trailing stop loss settings
TrailingStop=0
TrailingStopPips=5
StopTrailAtPipsProfit=0
StopTrailPips=0
ITSL=Instant trailing stop loss settings
InstantTrailingStop=0
InstantTrailingStopPips=30
StopInstantTrailAfterBreakEven=0
StopInstantTrailAtPipsProfit=0
StopInstantTrailPips=0
MSLA=Add a missing Stop Loss
AddMissingStopLoss=0
MissingStopLossPips=200
MTPA=Add a missing Take Profit
AddMissingTakeProfit=1
MissingTakeProfitPips=200
bl2=---------------------------------------------------------------------
GOC=----Global order closure settings----
GlobalOrderClosureEnabled=1
IncludePendingOrdersInClosure=0
ProfitInDollars=1
DollarProfit=1000.00000000
ProfitAsPercentageOfBalance=0
PercentageProfit=10000.00000000
bl9=---------------------------------------------------------------------
bin1=----Basket trade settings----
bin2=Set ManageByMagicNumber or
bin3=ManageByTradeComment to true
bin4= to use these features
ManageBasketTrades=1
bin5=Basket take profit settings
BasketClosureTP=1
BasketTPinDollars=1
BasketDollarTP=900.00000000
BasketTPasPercent=0
BasketTpPercentage=1.00000000
AutoCalcBasketTPasPercent=1
FourToSevenTradesPercent=1.00000000
EightToTwelveTradesPercent=2.00000000
ThirteenPlusTradesPercent=3.00000000
bin6=Basket stop loss settings
BasketClosureSL=0
BasketSLinDollars=0
BasketDollarSL=100000.00000000
BasketSLasPercent=0
BasketSLPercentage=1.00000000
bin13=Basket jumping stop settings
BasketJumpingStop=0
BasketJumpingStopProfit=1.00000000
BasketAddBEP=1
BasketBreakEvenProfit=0.10000000
DisableBasketJumpStopAfterBE=0
bin7=Basket trailing stop settings
BasketTrailingStop=1
BasketTsAtProfit=400.00000000
BasketTrailPercent=75
bin8=Immediate basket closure setting. Use with care
BasketCloseImmediately=0
bin9=Trade expiry settings
TradesWillExpire=0
TradesWillExpireMins=210
bl3=---------------------------------------------------------------------
hs=----Hedge settings----
HeadgeEnabled=0
HedgeAtLossPips=0
HedgeTradeStopLoss=0
HedgeTradeTakeProfit=0
HedgeMultiplier=2.00000000
CloseAtBreakEven=1
Ins14=Trend filter choices
UseEnvelopeTrendFilter=0
LookBackBars=3
UseAdxTrendFilter=0
AdxPeriod=14
UseCandleDirection=1
LookBackCandleHours=3
bl5=---------------------------------------------------------------------
sps=----Shirt-protection settings----
spsi=Close all open trades at this $ loss
ShirtProtectionEnabled=1
MaxLoss=-300.00000000
IncludePendingInClosure=0
bl6=---------------------------------------------------------------------
OtherStuff=----Other stuff----
ShowAlerts=1
-
dudest
- Trader
- Posts: 1847
- Joined: Tue May 08, 2012 2:37 pm
Re: MPTM's -Settings for Percentage Profit Trail
Hallo,Leofitz wrote:Could someone take a look at my settings and suggest what alterations in the settings I should make to accomplish the closure of all open trades using a profit percentage trailing stop? I read the MPTM directions and have tested this a couple times but can't get the right combination of settings.
I selected the Basket trade settings group=true and selected 'Manage by Comments' to enable this. I left the Comments line blank, as all comments in my manually set trades had no comment.
My choice of settings was intended to begin a trailing profit stop on all open trades at $400 with a 75% profit trail. The terminal close basket profit level was $900.
I also turned on Global Order Closure at $1000 as a backup, and Shirt Loss Protections to -$300
The set file settings are below. Any suggestions will be appreciated. Thanks!
....
You seem to be using an MPTM older than that in post #1
In latest MPTM, there's also parameter AllTradesBelongToBasket (could come in handly esp because you don't want to manually set a trade comment; I'm not too sure a blank comment works )
AllTradesBelongToBasket=1
Hope attached setfile will be of help. Please download latest MPTM also
Cheers
You do not have the required permissions to view the files attached to this post.
-
rafo05
Re: MPTM's new home
Hello dudestdudest wrote:
Hallo,
I could be wrong, but those settings are not MPTM's...
Are you sure you are using MPTM? (see first post of this thread)
If yes, please post your full set file
CHeers
I am using MTP_1.9.mq4, the higher version I found on this long thread (There might be a most updated one?)
Follows parameters from "mtp_1.9_rafo05.set" (is this what you meant?):
PreSet_Name=Default
First_TP=100
Second_TP=0
Third_TP=0
TP_Increment=0
Close_Lots=0.02000000
Close_Method=1
First_Stop_Target=100
First_Stop=0
Second_Stop_Target=0
Second_Stop=0
Third_Stop_Target=0
Third_Stop=0
Trail_Stop_By=0
Max_Loss=40
Alert_Sound=1
Alert_Email=0
Magic_Number=0
Thank you
-
dudest
- Trader
- Posts: 1847
- Joined: Tue May 08, 2012 2:37 pm
Re: MPTM's new home
Hallo,rafo05 wrote: Hello dudest
I am using MTP_1.9.mq4, the higher version I found on this long thread (There might be a most updated one?)
Follows parameters from "mtp_1.9_rafo05.set" (is this what you meant?):
PreSet_Name=Default
First_TP=100
Second_TP=0
Third_TP=0
TP_Increment=0
Close_Lots=0.02000000
Close_Method=1
First_Stop_Target=100
First_Stop=0
Second_Stop_Target=0
Second_Stop=0
Third_Stop_Target=0
Third_Stop=0
Trail_Stop_By=0
Max_Loss=40
Alert_Sound=1
Alert_Email=0
Magic_Number=0
Thank you
I'm afraid what you have (MTP) is NOT MPTM.
Please download the latest version from POST #1 of this thread: http://www.stevehopwoodforex.com/phpBB3 ... p?id=13914
An MPTM set file looks like the one attached
Cheers
You do not have the required permissions to view the files attached to this post.
-
rafo05
Re: MPTM's new home
Thank you dudest
To be honest I got lost where I took that MTP_1.9.mq4 from. I will use the one you indicated on link download/file.php?id=13914
I appreciate your guidance.
Regards
To be honest I got lost where I took that MTP_1.9.mq4 from. I will use the one you indicated on link download/file.php?id=13914
I appreciate your guidance.
Regards
-
Leofitz
- Posts: 2
- Joined: Mon May 27, 2013 3:58 am
Re: MPTM's -Settings for Percentage Profit Trail
Thanks, I've downloaded the MPTM version on post #1 and will try your set. For future reference is the version of the MPTM hidden away somewhere down in the coding?dudest wrote: Hallo,
You seem to be using an MPTM older than that in post #1
In latest MPTM, there's also parameter AllTradesBelongToBasket (could come in handly esp because you don't want to manually set a trade comment; I'm not too sure a blank comment works )
AllTradesBelongToBasket=1
Hope attached setfile will be of help. Please download latest MPTM also
Cheers
I've kept the 'Manage by Trade Comment' selected with a blank in 'Comments' to try and match the blank on each trade ticket. I wonder if this is what Steve H. intended? I guess trial and error will tell.
I have the manager now running on a couple charts and will try to experiment to find what combination of settings he intended to allow the MPTM to manage all trades and as a basket. The note under the Basket Trading section about Comments or Magic Number needing to be selected in order for the Basket settings to work is now unclear. Does the new setting 'All Trades belong to Basket" override the Comments/Magic Number requirements?
In your set there's an additional settings on line 17 that you had set to False, "Manage all Trades"? Shouldn't this also be True?
Its hard to know if what appear to be mutually agreeable settings, but which are in different sections, might somehow conflict with each other. I'll post my findings here if I can isolate a definitive answer. Thanks for your help.
-
dudest
- Trader
- Posts: 1847
- Joined: Tue May 08, 2012 2:37 pm
Re: MPTM's new home
Hallo,
Yes, I know the params can sometimes be unclear
, but no worries, we'll figure it out.
Since you already have ManageByTradeComment=1, no need to have ManageAllTrades=1, especially coz you are interested in the basket functionality (which uses ManageByMagicNumber or ManageByTradeComment)
If you look at the code (basket trading functions), AllTradesBelongToBasket is checked along with ManageByMagicNumber and ManageByTradeComment [ OR condition ]. Which means as long as ANY of the 3 is set, basket trading will work [ hence why in my setfile, AllTradesBelongToBasket=1 ]
I'm just not sure about an empty comment (is it that much of a bother to put in a comment when setting/opening orders?) Anyhow, AllTradesBelongToBasket=1 will make it work whatever the case with the comment.
Steve didn't tag the latest version on post #1 with a version no. But the last version before this one was ver 4.29. Anyways, the latest ver is always on post #1
Cheers
Yes, I know the params can sometimes be unclear
Since you already have ManageByTradeComment=1, no need to have ManageAllTrades=1, especially coz you are interested in the basket functionality (which uses ManageByMagicNumber or ManageByTradeComment)
If you look at the code (basket trading functions), AllTradesBelongToBasket is checked along with ManageByMagicNumber and ManageByTradeComment [ OR condition ]. Which means as long as ANY of the 3 is set, basket trading will work [ hence why in my setfile, AllTradesBelongToBasket=1 ]
Code: Select all
if ((ManageByMagicNumber && OrderMagicNumber()==MagicNumber) || (ManageByTradeComment && OrderComment()==TradeComment) || AllTradesBelongToBasket)
Steve didn't tag the latest version on post #1 with a version no. But the last version before this one was ver 4.29. Anyways, the latest ver is always on post #1
Cheers
-
Headly
- Posts: 5
- Joined: Thu Jun 13, 2013 1:31 pm
Re: MPTM's new home
Good Day,
I am glad to join the forum as I have been a avid follower of Steve's unique creation.....I do have a request to modify a portion of the code to implement in my trading strategy.
Add hedge feature to:
- Open hedge trade once original order is triggered
- No order modification of original order
Just some ideas for added hedge trade management
- Add other Hedge Trade feature eg. trail, martingale & anti martingale by lot increment, jumping stop, partial close, partial closing, etc
I am glad to join the forum as I have been a avid follower of Steve's unique creation.....I do have a request to modify a portion of the code to implement in my trading strategy.
Add hedge feature to:
- Open hedge trade once original order is triggered
- No order modification of original order
Just some ideas for added hedge trade management
- Add other Hedge Trade feature eg. trail, martingale & anti martingale by lot increment, jumping stop, partial close, partial closing, etc