Reply

Possible to close position partially after ATR target?

9 replies

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

10 years ago #112092

Possible to close position partially after ATR target?

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #124227

yes, it is possible, but you have to define such rule by yourself. Partial exits are not supported by standard order management,

but there’s nothing preventing you from making a rule where you’ll check for the order profit, and close a part of the position when reaches some level.

 

EA Wizard contains functions for checking for order profit as well as partial close.

Mark
StrategyQuant architect

0

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

10 years ago #124262

Hm, I am having trouble defining the rules for it. For take profit it is very simple to define.

For Partial close it is very different.

I was thinking like-
IF
Market Position is long
& Price= Entry+ ATR*1.5
THEN
Close position Partially

IF
Market Position is short
& Price= Entry – ATR*1.5
THEN
Close position Partially

Maybe you can simplify this one for me Mark. Having some difficulty.

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #124264

the code you wrote is exactly how it could work, what difficulty do you have with that?

 

Could you post your strategy here (.sqw)? I’ll then check it and correct it.

Mark
StrategyQuant architect

0

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

10 years ago #124272

Ah ok I’ve found it. I didnt know we had “OpenPrice”. I was looking for “Enrty” or something and thought maybe I was not able to do this function. Here is what I got so far. It still isn’t complete.

0

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

10 years ago #124305

Ok I got it working but maybe you can enlighten me on how the % partial close works with my ATR settings.
I separated the rules in the above post into 2 rule sets.
New problem I am having: Repeating partial closes for the same order.
Example-
40% partial close after ATR(10)[1]*1+ OpenPrice

Position size = 0.1Lot
Partial Close= 0.04

But during MT4 backtesting it keeps repeating partial close.

Position size is 0.1
So it partially closes 0.04
Position size now is 0.06
Now it partially closes 0.02
Then 0.01
0.01…

Is there a way I can set this so it only partially closes 1 time per order?

0

stearno

Customer, bbp_participant, community, 379 replies.

Visit profile

10 years ago #124336

Threshold,

Yes, there is a simple fix for only doing it once.

 

1. Create a new variable in the parameter.  I call mine ‘PartialOrder’ – make it int type and put the value of 0

2. Go to partial order rule tab

3. Add in the THEN statement another action to assign a value to the variable PartialOrder.  Asign it 1.

4. Add a rule to the IF statement of the Parial Order rule tab.  Add the condition that the varialbe PartialOrder must = 0 for the partial order rule to run

5. On your order entry rule(s), add another action to the THEN statement.  Assign the varialbe PartialOrder to 0.  

 

So this way when you enter an order, it flip the partial order switch to 0.  PartialOrder must equal 0 before it will take a partialorder from your order.  Then once it does it flips the variablle switch to 1, so that way it will not run that rule again until you enter another trade.

 

You will need this exact setup for each order you enter (so if you have Long Entry 1, 2, and 3. You will need to do this three times).

 

-Stearno

0

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

10 years ago #124385

Excellent.
Thank you sir.

0

Threshold

Customer, bbp_participant, community, 723 replies.

Visit profile

10 years ago #124412

From a recent backtest of the system on 14 year sample on just 1 pair (works on many.) 😉
Thx again.

0

stearno

Customer, bbp_participant, community, 379 replies.

Visit profile

10 years ago #124502

very nice!

0

Viewing 9 replies - 1 through 9 (of 9 total)