How do you create a stop based on entry in a stratagey?


Category:
0
0

Example:

TTM_squeeze fires let stop at entry low of entry.

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on May 2, 2017 10:24 am
166 views
0

I don’t see very much detail to work with here so I’ll need to ask some questions. You did not provide any code so it’s tough to get the context of your question. It seems to me you are using TTM_Squeeze for the entry in your strategy, and that when it fires you want to use the low of the entry bar as the stop. Is that correct? If so, then is there any adjustment to the stop, after entry? Or does it just stay at that level until a new entry occurs?

( at May 2, 2017 1:19 pm)
0

Your assumption is correct, I would like to set a stop on low of entry bar for when it fires. No adjustments to stop just stays at that level till new entry occurs. Thank you in advance. Your website and videos are great!

( at May 2, 2017 7:22 pm)
0

Ok so the last bit of detail here. Don’t want to assume anything. When you say that the TTM_Squeeze fires. Are you talking about when the red dot changes to green on the zero line? There is a complication here. Because your strategy may stay in a position through the next series of red and green dots. At which time the stop will reset because it does not know the strategy is still in a position and should be tracking the original trigger.

( at May 2, 2017 7:36 pm)
0

Just sent you a donation on paypal. Yes when red dot turns to green entry happens, then will exit auto order once histogram turns over. Example long Cyan to blue. As safety net will have stop from original entry low. I will most likely adapt script for other strategies… this is just a great starting point.

( at May 3, 2017 5:56 am)
0
Private answer

Ok now that we have the details clear I can post a bit of code here to capture the low of the candle when TTM_Squeeze fires green and hold that until the next green dot fires. You did not post any code and only asked for the stop so I presume you already have the rest worked out.

I will borrowing some code from a video we did showing a custom watchlist column using the TTM Squeeze: https://www.hahn-tech.com/thinkorswim-watchlist-ttm-squeeze/

Here is the code:

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeDots = TTM_Squeeze(price, length, nK, nBB, alertLine).SqueezeAlert;
def squeezeFiresGreen = squeezeDots[1] == 0 and squeezeDots == 1;
rec lowAtFirstGreenDot = CompundValue(1, if squeezeFiresGreen then low else lowAtFirstGreenDot[1],
0);
plot lowAtEntry = lowAtFirstGreenDot;

The attached screenshot shows how this looks on a chart. The cyan colored line on the price graph plots the low of the first green dot each time the TTM Squeeze fires.

Please be sure to up-vote any answers that best solve your question!

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 3, 2017 8:13 am