Sunday, February 14, 2016

Manage Take Profit EA



Manage Take Profit EA
မဂၤလာပါ … မိတ္ေဆြတို႕
ဒီမွာေတာ့ ကၽြန္ေတာ္ Take profits ယူဖို႕နဲ႕ Stop loss အတြက္ Expert Advisor ေလးတစ္ခုေတြ႕ ထားတာေလးကို မွ်ေ၀ေပးခ်င္ပါတယ္။ ေလာေလာဆယ္ ကၽြန္ေတာ္ေတာ့ မသံုးျဖစ္ေသးပါဘူး။ ကၽြန္ေတာ္တို႕ အတြက္ အသံုး၀င္ႏိုင္လိမ့္မယ္ လို႕ေတာ့ ေမွ်ာ္လင့္မိပါတယ္။ ဘာပဲ ျဖစ္ျဖစ္ ယူထားရင္ေတာ့ ကုိယ့္အတြက္ အက်ိဳး မယုတ္ႏိုင္ပါဘူး။
ဒီ Expert Advisor က ဘယ္လို အလုပ္လုပ္သလဲ ဆိုေတာ့ ကၽြန္ေတာ္တို႕ Trade တစ္ခုထဲမွာ  profit levels အမ်ိဳးမ်ိဳး ရယူႏိုင္သလို Stop ကိုလည္း စိတ္ႀကိဳက္နီးပါး အမ်ိဳးအမ်ိဳး ထားႏိုင္တဲ႕ သေဘာရွိပါတယ္။ ဒီဇိုင္းထုတ္ထားတဲ႕ levels ေတြမွာ stop losses ေတြကို ေရႊ႕ေပးပါတယ္။ သူ႕ရဲ႕ customize parameters ေတြကို ေတာ့ ကၽြန္ေတာ္ နားလည္သလို ေရးေပးလိုက္ပါတယ္။
- First_Target:         ဒါဟာ ပထမ profit target ပါပဲ။ pips နဲ႕ ေဖာ္ျပရပါမယ္။ ဒါကို က ကၽြန္ေတာ္တို႕ သတ္မွတ္ေပးရမွာ ျဖစ္ပါတယ္။
- Target_Increment:            ပထမ profit target ကို တႀကိမ္ ေရာက္ရွိခဲ႕ၿပီး ဆိုရင္ ေနာက္ target ဟာ ေျပာင္းလဲ သတ္မွတ္ထား တဲ႕ Traget မွ သတ္မွတ္ထား တဲ႕ ပမာဏ အတိုင္း ထပ္တိုးပါတယ္။
-  Close_Lots:                    Target တစ္ခုစီ ေရာက္လို႕ရွိရင္ lots ဘယ္ေလာက္ ကၽြန္ေတာ္တို႕ အေနနဲ႕ ထြက္ခ်င္ပါသလဲ။ ဥမပာ ကၽြန္ေတာ္တို႕အေနနဲ႕ 10 Lots trade ထားတယ္ဆိုရင္ 1 Lot ထြက္မယ္လို႕ ယူမယ္ဆိုရင္ profit tergets 10 ခုရွိမွာ ျဖစ္ပါတယ္။ ဒါမွမဟုတ္ 5 lots ထြက္မယ္ဆိုရင္ 2 profit target ရွိမွာ ျဖစ္ပါတယ္။ မိတ္ေဆြ အဆင္ေျပသလို အသံုးျပဳႏိုင္ပါတယ္။
- Move_Stops:         True မွာ ထားသည္ဆိုပါစို႕၊ First_stop and Stop_Differential parameters အေပၚမွာ အေျခခံၿပီး Stops ေတြကို ေရႊ႕ေနမွာ ျဖစ္ပါတယ္။ အျခားတဖက္ False မွာ ထားသည္ဆိုပါစို႕၊ stop ေတြကို auto လိုက္မေရႊ႕ေတာ့ပါ။
- First_Stop_Target:            First_Stop level ကို Stop ကို မေရႊ႕ခင္မွာ Trade ေရႊ႕သြားမယ့္ ပမာဏ (pips) ျဖစ္ပါတယ္။
- First_Stop:             Target တစ္ခုသို႕ ေရာက္တဲ႕ အခါမွာ (in pips) သင့္ရဲ႕ stop loss ဟာ ေရႊ႕သြားပါလိမ့္မယ္။ ဒီ နံပါတ္ေတြဟာ Entry မွ pips ပမာဏကို ကိုယ္စားျပဳပါတယ္။ ၿပီးေတာ့ positive or negative ထည့္သြင္းႏိုင္ပါတယ္။
- Second_Stop_Target:        Second_Stop level သို႕ stop loss မေရႊ႕သြားခင္ Trade ေရႊ႕သြားရမယ့္ ပမာဏ (in pips) ျဖစ္ပါတယ္။
- Second_Stop:        Target တစ္ခုသို႕ ေရာက္တဲ႕ အခါမွာ (in pips) ကၽြန္ေတာ္တို႕ရဲ႕ stop loss ဟာ ေရႊ႕သြားပါလိမ့္မယ္။ ဒီ နံပတ္ေတြဟာ Entry မွ pips ပမဏကို ကိုယ္စားျပဳပါတယ္။ ၿပီးေတာ့ positive or negative ထည့္သြင္းႏိုင္ပါတယ္။
- Use_Max_Loss:      True မွာ ထားသည္ ဆိုပါစို႕၊ ကၽြန္ေတာ္တို႕ ရဲ႕ own stoploss ကို ထည့္သြင္းခ်င္တယ္ ၿပီးေတာ့ ကၽြန္ေတာ္တို႕ ရဲ႕ stop value ကို သင့္ရဲ႕ broker ကေနၿပီးေတာ့ ကြယ္ေဖ်ာက္ထားခ်င္တယ္ ဆိုရင္ ထည့္သြင္းလို႕ရပါတယ္။ ဒါကေတာ့ ကၽြန္ေတာ္တို႕ အေနနဲ႕ trade အေပၚမွာ အျမင့္ဆံုး ထားခ်င္တဲ႕ Risk ပါပဲ ။ Move_stops ကို ture မွာထား ၿပီး Move_Stop ဟာ ျဖစ္ေပၚေနမယ္ ဆုိရင္ေတာ့ ဒါဟာ အလုပ္လုပ္မွာ မဟုတ္ပါဘူး။
- Max_Loss:   ဒါဟာ Trade အေပၚမွာ သင့္အေနနဲ႕ လက္ခံႏိုင္တဲ႕ maximum pip loss ပဲ ျဖစ္ပါတယ္။ အကယ္၍ 0 မွာ ထားထား ရင္ေတာ့ ဒီ function ကို disabled လုပ္ထားတာပဲ ျဖစ္ပါတယ္။
- Magic_Number:      ဒါကေတာ့ particular magic number နဲ႕ trades ေတြကိုပဲ expert ျဖင့္ manages လုပ္ၿပီး အသံုးျပဳႏိုင္ပါတယ္။ Expert ဟာ တူညီတဲ႕ pair ေတြမွာ မတူညီတဲ႕ အျခားေသာ trade(s) ေတြရဲ႕ profits points ေတြ ရယူတာကို မေႏွာက္ယွက္ပါဘူး။
ေအာက္မွာေတာ့ မူရင္း လင့္ မွာ ေသခ်ာ ရွင္းျပထားပါတယ္။
ဒီမွာ Down ႏိုင္ပါတယ္။
Attached Files
 




မူရင္း လင့္ ပါ => http://www.forexfactory.com/showthread.php?t=9553
Hi Everyone,
I've developed an expert that is designed to help me stick to my system a bit better than what I do by myself. Use it at your own risk, though.
The expert works by taking profit out of a trade at various take profit levels. It also moves stop losses at designated levels. You have the ability to customize the following parameters:
  • First_Target: This is the first take profit target, in pips, that you specify.
  • Target_Increment: Once the first profit target is reached, the next target will increment by the amount specified by the target increment variable.
  • Close_Lots: This is how many lots you want to take out at each target. For example, if you have 10 lots, you can take 1 lot out at each of 10 profit targets, or 5 lots out at each of two targets. It's up to you.
  • Move_Stops: Set to true if you want the expert to move stops based on the First_Stop and Stop_Differential parameters. Otherwise, set to false if you don't want stops moved automatically.
  • First_Stop_Target: This is the amount in pips the trade moves before your stop loss is moved to the First_Stop level.
  • First_Stop: This will move your stop loss when a target, in pips, is reached. The number represents the number of pips from entry and can be postive or negative.
  • Second_Stop_Target: This is the amount in pips the trade moves before your stop loss is moved to the Second_Stop level.
  • Second_Stop: This will move your stop loss when a target, in pips, is reached. The number represents the number of pips from entry and can be postive or negative.
  • Use_Max_Loss: Set to true if you want to input your own stoploss and hide your stop value from your broker. This is the maximum loss you'll risk on the trade. It's irrelevant if Move_Stops is set to true AND Move_Stops was triggered.
  • Max_Loss: This is the maximum pip loss you'll accept on the trade. If set to 0, this function is disabled.
  • Magic_Number: You can use this to ensure the expert only manages trades with a particular magic number. This will allow you to trade the same pair using different systems without this expert interfering with the take profit points of the other trade(s).
The image below represents example parameters that can be set for the expert. I'll explain each one with a scenario. Assume you place a 1 lot sell order for EURUSD at 1.2100 (1.2103/1.2100 - ask/bid). (Assume a 3 pip spread.)
  • The expert will take .1 lots ("Close_Lots"), or 1/10th of this scenario's order, out at +10 pips ("First_Target"), or 1.2090/1.2087.
  • After that, the next profit target will increment 8 pips ("Target_Increment") to 1.2082/1.2079. and another .1 lots will be taken out at that level. The expert continues to increment the preceding profit target by 8 pips until the original order is closed. In this example, the maximum pips gained would be 10 + (8*9), or 82 pips. (First target pips + increment pips * number of times to increment, which would vary depending on the original order size and the "Close_Lots" parameter.)
  • When the trade reaches +15 pips ("First_Stop_Target"), the stop loss will be moved to -5 pips ("First_Stop") from the order entry price. In this case, the order entry price was 1.2100, so the new price would be 1.2105. This means that you would lose 5 pips if the trade turned. Set the "Stop_Differential" parameter to "0" in order to move stops to breakeven (1.2100). If this parameter were, for example, set to 5, then the stop loss would be moved to 1.2095, and you would have a 5 pip increase if the move turned against you and stopped you out.
  • When the trade reaches +30 pips (Second_Stop_Target), the SL is moved to Entry Price + 10 pips.
  • If you don't want the expert to move the order's stop loss, then set the "Move_Stops" parameter to "false". I think this works, but haven't fully tested it.
In case you're wondering, the reason I wrote this is so that I didn't have to place 5 different stop loss orders in order to manage different take profit levels. Since I don't want to sit in front of the computer all the time, waiting for these levels to hit and I take out a portion of the order, I figured an expert would do just the thing.

Regards,
stockwet

** Important **
I've found that if I'm in the middle of trade and make a change to the expert parameters, it resets everything. So, here's an example. Let's say that I want to take 1 lot out at 20 pips and another out at 40 pips. The price moves to 25 pips and takes out my first lot. I decide that I want to change my stop rules to move stops from breakeven to +10 pips if the price goes to +30 pips. The problem is, my take profit had incremented to watch for +40 pips but my initial target is still set to 20. If I close the expert, it resets the incremented value to the initial target. Since the price is now +25 pips and my initial target is set to 20, even though the expert incremented to 40 as the next target, the reset causes my second lot to be taken out.

So, if you're targets have incremented and you want to change your move stops or any other value, make sure you make your initial target to be the new next target you want to take profit out at.

** Updates**
11/2/2006 (v2.3) :: Fixed bug that caused the sl var to be set to 1 when a pending order was > than the First_Stop_Target value. In other words, if a pending order was in, not an actual order, and the price was greater than First_Stop_Target pips from the pending order entry, then the expert would honor the second move stops stop target, and skip the first.
1/23/2007 (v2.4) :: Fixed pip calculation. The old way of calculating pips could be off by 1 pip, resulting in missed TP or move stops. The new calculation is more accurate.

Attached Files
File Type: mq4ManageTPv2-3.mq4   6 KB |
File Type: mq4ManageTPv2-4.mq4   6 KB |

No comments:

Post a Comment