Help Needed With Expert Advisor for TP & SL
hi guys, i request if you could look into this EA that i use which automatically puts in SL, TP. i have attached the file along with the post.
ok, it does the first point below but not the remaining which i would prefer :-
1) automatically puts in a stoploss on new or existing trades
2) keeps a trailing stoploss so that stoploss is trailed above from ninitial SL & not from ntrailing stoploss ( ** example gieven below )
3) automatically puts a TP at opening or during of a position along with SL or puts a TP once trade is in x amount of pips in profit
3) push the price automatically to breakeven once the trade is in x amount of profits BUT does not trail stoplosses or keeps any SL after breakeven. (this never happens & something i want as an extra feature)
example of what i want from this EA :-
i enter EURUSD at 1.2222, n initial SL is set to 35 pips so it places an initial stoploss of 35 pips from 1.2222 & not from 1.2229 which might be current price & it should automatically set TP of 40 pips or i am able to set an option that once my trade is in 15 pips plus, "n trailing stoploss" is applied which is set to 5 pips...so once price hits 1.2237 it trails SL & SL becomes 1.2232 & keeps on trailing. " nProp Threshold is given in EA properties also but not able to figure it out
Sorry, if that seems juggled. pls create an EA like that for me or make me understand how this one actually works as the poster of this EA was confusing in his explaination. but i am providing his expltn below as well. he has probably made this EA for long trades but i want to use it for scalping on 15 - 30 min charts.
*** Example His default setting is ninitial stoploss of 15 & ntrailing stoploss of 30 pips which never happens in scalping. i tried ninitial SL of 30 & trailing stoploss of 5 pips...but it trails from current price and once price drops 5 pips trade is taken whereas n initial stoploss was set at 30 pips.
_____________his expltn of EA below _____________________
- changed algorithm: if there is no SL, EA sets nInitialSL (pips) from the current price, then nTrailingStop is used as normal trailing stop until nPropSLThreshold profit (in pips) is reached. From that point proportional SL is used: (Buy/Sell)
SL = OrderOpenPrice() +/- dPropSLRatio(Bid/Ask - OrderOpenPrice()) -/+ spread
- 3 logging level are now meaningful: 0 - no logging, 1 - (default) only events (change SL) are logged, 2 - additional log file for diagnostic
The settable parameters are:
extern int logging=1;
//logging=0,1,2 - logging level
extern int nInitialSL=15;
// inital SL
extern int nTrailingStop=35;
//nTrailingStop [pips] - initial trailing stop. It will be used until your trade will reach profit = nPropSLThreshold. If you don't want trailing stop, set to a big value (bigger then nInitialSL + nPropSLThreshold)
extern int nPropSLThreshold=12;
//nPropSLThreshold [pips] - after reaching this profit proportional trailing stop will be used
extern double dPropSLRatio=0.35;
//dPropSLRatio [decimal] - multiplying factor ( PropSL = Profit * dPropSLRatio - Spred )
extern int nUseEscape=0;
//nUseEscape [ 1 or 0 ] - escape misplaced trades as soon as they reach some minimal profit
extern int nEscapeLevel=0;
//nEscapeLevel [pips] - lose size after which we want our trade to terminate
//as soon as it will reach next high
extern int nEscapeTP=35;
//nEscapeTP [pips] - take profit level in pips (you can set to negative value
//- then it will be a lose that you would be happy to get,
//in the case your trade reached some impressive negative pips value)
extern int nSleep=0;
//delay after new bar
extern int nSlip = 2;
//maximum price slip allowed
This EA is only checking if the order is on the same currency pair (as the chart EA is attached to). I personally even use it from different location. I keep one running at home, with somehow relaxed settings. So if I would open a position at the office and lost patience and leave, the one at home would take care to move my stop. So if you trade 6 pairs, EA has to be attached to each pair's chart.
Regarding time frame - it really is up to you. If moving SL every hour is enough for you - why not to keep this EA on hourly chart?
Just have this in mind if you open a position, the initial SL will not be applied until bar on the EA's chart will arrive.
For the manually setting SL: this EA lets you keep your SL as tight as you like, but it will not let you loosen it, beyond EA's parameters.
The algorithm is to move SL only one way, so EA will apply new SL ONLY if it will be in the trade direction.
The initial SL will only be applied if there is no SL set yet.
Afther that - if you tighten SL - it will be respected, if you make bigger gap then it would be calculated by EA, than "TradeProtector" will apply it's SL.
As for TP my EA is ignoring them.
Maybe this will explain it the best (example for the BUY operation):
Start
Is order of the same currency pair?
no: break
yes: continue
Is any SL set yet
yes: calculate initial SL
no: continue
Is nPropSLThreshold exceeded?
no:
Is nTrailingStop <>0 ?
Calculate traling stop
yes:
Calculate proportional stop
calculate maximum of (current SL, initial SL, trailing stop, proportional stop) = SLmax
if SLmax > current SL
apply SL max as a new SL ;
_______________________________________explantn ended__________________________
thanks a ton guys !!!
regards
rishi