Scaling Out Script

DocT
Trader
Posts: 149
Joined: Mon Apr 23, 2012 9:44 am
Location: Aberdeen

Scaling Out Script

Post by DocT »

Tommasso/Steve/Coders

I wonder if you can help? I am looking for a script (or two - one long one short) to help semi-automate manual trading for use on H4 and D charts - this would be a Scale Out Script as opposed to Scale In. In these ranging times, and following NBs 10.7 and 10.9 where the max price moves 1 to 3 levels before retracing, I would like to be able to send one pending order and then scale out x% at +y pips etc. Example below:

1. Place initial pending trade, with SL and TP (pip based or line based or ATR based)

2. Scale out trade as price moves in direction of trade

a) after x pip move, close 50% of initial trade and move SL to +y pips (BE +1 or 50% initial SL) [50% left]

b) after x pip move, close 50 % of trade remaining [25% left], move SL to +z pips or to BE+1

c) after x pip move, close 50% of remaining trade [12.5% left], trail stop or jump stop

d) trail SL with price - final 12.5% close out on jumping stop or TP

I do this using multiples of 10.6 Drop_Pending-Buy/Sell scripts but end up with so many lines on the charts and it can become complicated moving the SLs etc.

I have searched the forum, and internet, but most are Scale In scripts. I even tried a commercial Money Management EA which had a scale out feature but a) it was an EA and b) it used so much real estate on the screen that I couldn't see the Price Action.

Also I appreciate that when the markets start to trend again, using Scale In Scripts would be preferable - and those are already coded here on SHF (and I do use these too). But in ranging markets or slow moving markets a Scale Out script would be really useful.

Thanks for your consideration in this.
Cheers
Doc
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Scaling Out Script

Post by milanese »

Hi Doc,

I see it nearly impossible to do, what you want, with a script, imo this kind of scaling out needs an EA.

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
DocT
Trader
Posts: 149
Joined: Mon Apr 23, 2012 9:44 am
Location: Aberdeen

Scaling Out Script

Post by DocT »

Tommaso

Oh dear, I did wonder. So I was looking for the impossible - good to know.

In that case, how easy to create an EA for Scale Out? And is it possible to behave like. Script and delete itself after SL or TP???

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

Scaling Out Script

Post by milanese »

taggie11 » Thu Jun 26, 2014 5:34 pm wrote:Tommaso

Oh dear, I did wonder. So I was looking for the impossible - good to know.

In that case, how easy to create an EA for Scale Out? And is it possible to behave like. Script and delete itself after SL or TP???

Thanks
Doc
it is easy to code that it would remove itself from the chart if the work is done.
For the rest you should explain exactly how you want to have the EA to work..

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
DocT
Trader
Posts: 149
Joined: Mon Apr 23, 2012 9:44 am
Location: Aberdeen

Scaling Out Script

Post by DocT »

Tommaso

OK - here goes...

This is the way I imagine this EA to function – hopefully it will be possible:
1. Place pending trade on chart with initial SL and TP, and 3 Scale Out Levels pre-defined [basic would be by defined number of pips; but could be x.00 or x.50 horizontal levels; % ATR; fibs or pivots]. It would be good if all the trade lines - SL, TP, SOs - can be moved by dragging on the chart.
2. As price moves in our direction, trade activated
a. IF price does not activate trade within x time, deactivate EA
3. As price reaches pre-defined Scale Out Level 1, close 50% (variable) and move SL to BE + 2pips (variable)
4. As price reaches SO level 2, close 50% (variable) and move SL to SO Level 1
5. As price reaches SO level 3, close 50% (variable) and move SL to SO Level 2
6. Remaining % to close at either:
a. initial TP
b. Trail SL
c. Jump SL
d. Candle SL
e. More sophisticated option to capture as much of the remaining move as possible in combo with trail SL or jump SL, would be to also move the TP forward by x pips as price gets within y pips [a jump TP - I do not know if this is possible but would be amazing if you can code it]
7. On closure, EA should deactivate and remove itself from chart.

I have annotated a chart to hopefully illustrate what I mean.

The EA will need all the usual functions of the Shell eg trading time frame management, lot size or risk percent, TP and SL, Magic number and trade comment, ECN etc. However, as this is a tool for manual trading, it does not need the more sophisticated aspects of the Shell – MA, Slope, CSS etc. It does need Trading Hours and some people may want Alerts – I don’t.

For me, the idea is to leave the trade to either TP or SL – a semi-automatic manual system.

Thanks Tomasso – if you need any more information, please let me know.
Doc
You do not have the required permissions to view the files attached to this post.
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Scaling Out Script

Post by milanese »

:smile: Looks that is somewhat more to code as I thought in the first moment, I have some other thingies to code, but I will take a look if I find time ...

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
DocT
Trader
Posts: 149
Joined: Mon Apr 23, 2012 9:44 am
Location: Aberdeen

Scaling Out Script

Post by DocT »

milanese » Fri Jun 27, 2014 12:28 pm wrote::smile: Looks that is somewhat more to code as I thought in the first moment, I have some other thingies to code, but I will take a look if I find time ...

Cheers :)

Tommaso
Much appreciated Tommaso. I think this would be a really useful EA for many people, especially those who trade NB10.7 and 10.9 with TMA.

I know you are busy so fingers crossed you can find some time :good:

Thanks
Doc ;-)
User avatar
milanese
TechAdmin
Posts: 3293
Joined: Wed Jan 09, 2013 9:02 am
Location: btr rdx, r8 +

Scaling Out EA

Post by milanese »

Hic Doc,

here comes the first version of Scale Out EA, the relevant inputs are:

DelteOrderAfterXMinutes if the pending order is not filles in x minutes, the EA will be remove itself from the chart, set this to 0 and the EA will never be removed from chart
BuyEntry Here you set your PendingPrice Buy it must be > as the actual ASK, setting here 0 will deactivate the BUY function
c]SellEntry[/c] Here you set your PendingPrice Sell it must be < as the actual Bid, setting here 0 will deactivate the SELL function
MaxSpreadAllowedMultiplicator here you can set how much the actual spread could be higher than the average spread for opening the order
ScaleOutLevelOnePipshere you enter the pips needed for the first part close and the BE setting
ScaleOutLevelTwoPipshere you enter the pips needed for the second part close and moving SL to the ScaleOutLevelOne
ScaleOutLevelThreePips here you enter the pips needed for the third part close and moving SL to the ScaleOutLevelTwo
BEProfit this is added to the OpenPrice if BE is set
PartClosePercent enter here the PartClosePercent you wish every step closed

The rest should be self explaining, the EA will be remove itself from chart if all open positions are closed and DelteOrderAfterXMinutes is not set to 0.
ScaleOutAndMoreTradeManager.mq4
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
DocT
Trader
Posts: 149
Joined: Mon Apr 23, 2012 9:44 am
Location: Aberdeen

Scaling Out EA

Post by DocT »

milanese » Fri Jun 27, 2014 5:23 pm wrote:Hic Doc,

here comes the first version of Scale Out EA, the relevant inputs are:

DelteOrderAfterXMinutes if the pending order is not filles in x minutes, the EA will be remove itself from the chart, set this to 0 and the EA will never be removed from chart
BuyEntry Here you set your PendingPrice Buy it must be > as the actual ASK, setting here 0 will deactivate the BUY function
c]SellEntry[/c] Here you set your PendingPrice Sell it must be < as the actual Bid, setting here 0 will deactivate the SELL function
MaxSpreadAllowedMultiplicator here you can set how much the actual spread could be higher than the average spread for opening the order
ScaleOutLevelOnePipshere you enter the pips needed for the first part close and the BE setting
ScaleOutLevelTwoPipshere you enter the pips needed for the second part close and moving SL to the ScaleOutLevelOne
ScaleOutLevelThreePips here you enter the pips needed for the third part close and moving SL to the ScaleOutLevelTwo
BEProfit this is added to the OpenPrice if BE is set
PartClosePercent enter here the PartClosePercent you wish every step closed

The rest should be self explaining, the EA will be remove itself from chart if all open positions are closed and DelteOrderAfterXMinutes is not set to 0.

Cheers :)

Tommaso
Brill Tommasso - that was quick ;-)
I look forward to seeing it in action on Monday. I will keep you posted on how it functions.
Thanks and have a great weekend.
Cheers
Doc :clap:
DocT
Trader
Posts: 149
Joined: Mon Apr 23, 2012 9:44 am
Location: Aberdeen

Scaling Out Script

Post by DocT »

Tommaso

The markets are quite quiet so not much to report on ScaleOutAndMore EA. I have several trades entered but none reached Scale In levels - yet ;-). Others removed themselves after the allotted time interval which was great. :clap:

The only request at this time would be to be able to see the pending trades and scale in levels on the actual chart - at the moment all is hidden.

However, I will report back on the scale in's/part closure as and when.

Thanks Tommaso

Doc
Post Reply

Return to “Scripts”