Exit a position 1 cent or tick below or above target
Author: detdet
Creation Date: 6/6/2020 1:56 AM
profile picture

detdet

#1
To sum up,

I am using the following trade system:

Short at limit Channel High(channel period: 2)
Buy at limit Channel Low (channel period: 2)


However, i would like to know if there is a possibility of exiting the position 1 cent or tick below my target.


I have attached a picture showing that i should have exited the short position at limit channel low, however, it hadnt closed the position at this price level because there were not enough orders in the book. I think if i had set my exit price 1 cent above the channel low i could have exited the position.


Thanks!
profile picture

Eugene

#2
Sure there is. Since you not even mentioned what kind of system you're using, Rule based or WealthScript, let me guess. You're using Rules. Adding a value above or below a target goes beyond Rule Wizard's capabilities. So you have to tweak the code behind. It's very simple in this case - just click "Open code in new Strategy Window" and add or subtract a Bars.SymbolInfo.Tick e.g.

CODE:
Please log in to see this code.
profile picture

detdet

#3
Hello @Eugene,

My system code is this one

CODE:
Please log in to see this code.

Where should i add this?

BuyAtStop(bar + 1, Highest.Value(bar, High, 20) + Bars.SymbolInfo.Tick , "");
ShortAtStop(bar + 1, Lowest.Value(bar, Low, 20) - Bars.SymbolInfo.Tick , "");
profile picture

Eugene

#4
Here you go:

CODE:
Please log in to see this code.
profile picture

detdet

#5
Hello @Eugene,

You are amazing my friend, thanks for helping me. If i am not bothering you anymore, could you do excactly what you did but in this code?

CODE:
Please log in to see this code.



I would be grateful to pay you a beer, if you dont mind sending me your paypal xd

thanks!
profile picture

Eugene

#6
You're welcome Andre.

Wizard-generated output may not be optimal. As a DIY experience, you might want to compare the differences between it and my code in Notepad++ or other editor.

Good luck.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).