Risk Management Strategy


Category:
0
0

Hi Hahn,

HOPE ALL IS WELL! Just watched your “Introduction to Strategies” video & I must say all your commentary regarding “you might be thinking” was exactly what I was thinking. LOL.  Great teacher!

I have a 4x  questions that I was hoping you might know regarding ToS Strategies

1.)  I noted the Ichimoku Chart Alerts produce different long/short signal if you use a 1min chart w/ 4 day interval as opposed to a 1 day interval.  In my strategy, how do I make sure that the signals are using a 4 day interval on the 1min chart & not the 1 day interval.

2.) I’m looking to build a trailing stop system based on target price levels.  For instance, if 80% of my target price is hit, then set a trailing stop at 50% of target price.  Is this possible?

3.) I’m wondering if ToS Strategies allow multiple stop criteria.  For instance, having the trailing stop system mentioned above in place, but also have other criteria. (i.e. If I’m in a long position & receive a short signal, it closes my long & creates an entry to go short.)

4.) Can stops or targets be something that is dynamic/moves after entry?  For instance, using the 1 month VWAP on the 1min chart as my target price or if it is above the VWAP using 1 standard deviation of the VWAP as the target price.

 

THANKS AGAIN,

DN

Marked as spam
Posted by (Questions: 3, Answers: 23)
Asked on May 12, 2017 5:54 am
473 views
0
Private answer

Before getting into the answers I will be sure to include a link to the video you referenced so other viewers know exactly what you are referring too: https://www.hahn-tech.com/thinkorswim-strategy-guide/

Responding to item number one. There are certain studies that require more historical data than others. I if you need the strategy to use 4 days of historical data then you must set your chart to 4 days of 1 min candles. Each time to change the time frame or the number of days of historical data the strategy will produce different signals as a normal part of operation. I could spend a great deal of time explaining the how and the why but there are another 3 components to your question so I must be brief.

Item number two. This is possible but most often the solution is very complex. I suggest you read my article that goes into more detail on complex stop management in strategies for Thinkorswim: https://www.hahn-tech.com/thinkorswim-strategies-complex-stop-management/

Question number three is basically just a stop and reverse strategy. Most of the built in strategies on the platform perform this very thing.

Number four is a solid yes. Dynamic elements in the chart are most often the tools used for triggering entries and exits. In fact I would go so far as to say there are none that use static elements. I mean, what in the world would that even look like? Buy on Mondays and sell on Friday’s. I suppose that might be one example.

I can tell by your questions what sort of ideas you have about building custom strategies in TOS. Let me assure you those solutions are extremely complex and very difficult to get working as expected.

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on May 12, 2017 9:03 am
0
Private answer

Hey Hahn,

Thanks for the reply.  Very informative regarding the ToS limitations.  In regards to the video I initially watched, I was actually referring to the video “ThinkOrSwim Strategy Guide”: https://www.youtube.com/watch?v=XZRpOMAbTOg

1.) Regarding the Exit Strategy, if I have multiple exits in my code, will ToS pickup whatever condition happens first for the open position & ignore the others?  (i.e.  having multiple ‘AddOrder(OrderType.SELL_TO_CLOSE, ).

2.) Also, is there a way to backtest further than my chart interval?  I’m currently using a 1min 4day chart to generate an ichimoku trading strategy.  Does ToS allow a way to backtest further without ruining the signals being generated by the 4day interval?

3.) Is there an easy way on how to turn on Autotrader for the Ichimoku/Parabolic strategy that I have playing in the Chart P&L?

4.) Is there a way to get text alerts on when my strategy enters & exits a trade & at what price??

 

 

 

 

Marked as spam
Posted by (Questions: 3, Answers: 23)
Answered on May 15, 2017 12:12 pm
0

The link you provided is the exact same video I linked. The only difference is that I linked to the post on this website that hosts that video.

1. Correct, first entry signal is taken. Any subsequent entry signals are ignored until an exit or a reversal order occurs.

2. If you need to go back further than 4 days of historical data you will need to do so using some other platform.

3. You can not turn on autotrader. Because there is no autotrader in Thinkorswim. To learn more about the limited auto trade functions that are supported be sure to view this video: https://www.hahn-tech.com/thinkorswim-autotrade-almost/

4. You can add alerts to the strategy. But the alerts will be based on the all entries and exits in your algorithm. The alerts will not be perfectly aligned with the theoretical orders displayed by your strategy. See response to question 3.

( at May 15, 2017 1:42 pm)
0
Private answer

Hey Hahn,

Do you have any recommendations regarding other platforms?  I would like to automate the following code for /ES & /ZB trading on the 1min 4 day chart.  My global settings are max 2x contracts in any direction.

Also, after looking at the code attached, is it possible to set up buy & sell text alerts using the code below without generating multiple hypotheticals?  If so, can you explain?

 

 

Marked as spam
Posted by (Questions: 3, Answers: 23)
Answered on May 15, 2017 2:35 pm
0

I did not see any code attached to your last response. Platforms I think you should research are Amibroker, TradeStation and NinjaTrader.

Text alerts may not even be possible using an ichimoku on a 1 min time frame. Depends on your settings. As to why they CAN NOT be matched to theoretical orders, sufficient details have already been given.

( at May 15, 2017 2:57 pm)
0
Private answer

Here is my code.

Marked as spam
Posted by (Questions: 3, Answers: 23)
Answered on May 15, 2017 3:36 pm
0

Nope, still didn’t get any code. But that is of little consequence since at this point it is pretty clear you will need to move to another platform to achieve your goals.

( at May 15, 2017 4:25 pm)
0
Private answer

Hey Pete,

Just realized the chart interval didn’t affect my strategy.

Also, if I wanted to plot & create a scan based on the Ichi/PARSar strategy longs & shorts, how would I convert the autobuy/autoshort into a scans?  I’m having trouble writing the multiple conditions found within the autobuys & autoshorts.

Marked as spam
Posted by (Questions: 3, Answers: 23)
Answered on May 17, 2017 3:56 am
0

My first thought is that we have already done this: https://www.hahn-tech.com/thinkorswim-scan-ichimoku/

Please review that video and let me know if that solves your question.

( at May 17, 2017 8:14 am)
0

Hey Pete,

For the following Autobuy,
AddOrder(OrderType.BUY_AUTO, longEntry and low > parSAR and open[-1] > parSAR, open[-1], tradeSize, Color.BLUE, Color.LIGHT_GREEN);
I understand I can write ”plot scan = longEntry” to perform the scan for bullish break with confirmation.
However, I was trying to write the following ”plot scan = longEntry and low > parSAR and open[-1] > parSAR” & the code is coming back as invalid.

( at May 17, 2017 9:27 am)
0

I FIGURED IT OUT! YAY!!!! Oddly off by a few minutes on a few signals, but it works for me.

( at May 17, 2017 11:20 pm)
0

Nice. Glad you got it working. I’ve been working non-stop on a strategy for a client and my brain doesn’t want to see another Parabolic SAR, ever. It’s not easy to wrap your brain around.

( at May 18, 2017 8:27 am)
0

Quick question when you have time, I’m trying to set up a scan/text message alert using the Ichi/SAR strategy on my /ES only watchlist on a 1min time frame but I haven’t received a single alert.

Does this make any sense to you?

The strategy plots out fine.
I’ve tried the following in the scan tab:
”When scan ’is true’”
”When scan ’is greater’ than value:zero”

while Scanned in my ”/ES” watchlist that is made up of the current contract.

No luck….

( at May 19, 2017 5:04 am)
0

There are a lot of things to check. Have you watched our video titled ”Thinkorswim Overnight Range Scan Alert” ? https://www.hahn-tech.com/thinkorswim-overnight-range-scan-alert/
This video will cover all the details that do not pertain directly to the code you are using now. But it will at lease ensure you have all the platform settings adjusted correctly in order to achieve text notifications from a saved custom scan. Once you can verify all the settings are correct, we can focus on the code itself.

( at May 19, 2017 7:43 am)
0

Hey Pete,
I got it working!
No idea what was wrong but I did change the scan setting from ”within number of bars from 1 to 5” & adding ALERT coding into my study.

( at May 21, 2017 5:14 pm)
0

Hi again Pete,
I was trying to AutoTrade my exits & I’m receiving the following message ”rec usage is not allowed in this context”. Have you seen this before? Does this mean I can’t AutoTrade my Ichi confirmation strategy?

( at May 22, 2017 12:09 pm)
0

If I recall correctly, you are using a Parabolic SAR for the exits. This indicator is not compatible with the Conditional Order or the Study Alert. You can use the Conditional Orders to get you into new positions. But once a position has opened, you will have to manually enter a stop loss order and trail it using the value of the Parabolic SAR of the previous bar.

( at May 22, 2017 12:49 pm)
0

Hey Pete,
Can I use an Ichimoku Confirmation for my exits as shown below? Also, are you saying that I can use Parabolic SAR for my entries but not my exits because I am able to plots my long/short entries in study alerts? However, I just run into this error ””rec usage is not allowed in this context”” when entering my long/short entries in orders. See below for strategy coding I’m referring to.

LONG ENTRY
AddOrder(OrderType.BUY_AUTO, longEntry and low > parSAR and open[-1] > parSAR, open[-1], tradeSize, Color.BLUE, Color.LIGHT_GREEN);

LONG EXIT
def longExit = shortBreakConfirmed[-1];
AddOrder(OrderType.SELL_TO_CLOSE, longExit[-1], Min(open, parSAR[0]), tradeSize, Color.PINK, Color.PINK);

( at May 23, 2017 7:09 am)
0

You cannot use the Parabolic SAR (parSAR) for any conditional order.

( at May 23, 2017 8:02 am)
0

Thanks for clarifying.
What about Ichimoku Cloud Break that requires confirmation?
I’m getting the same response ”rec usage is not allowed in this context”.

Also, Can you explain in non-math terms why the Parabolic SAR won’t work but a moving average crossover will?
I’m assuming it has something to do with recursions, which I don’t quite understand.

On the thinkorswim website, it mentions that ”def variables cannot be recursive”. Is there any way to write the defined variables in a way that calls upon itself/not recursive?
http://tlc.thinkorswim.com/center/howToTos/thinkManual/Trade/Order-Entry-Tools/conditionalorders.html

( at May 23, 2017 11:13 am)
0

If you strip out the entire section that contains the Parabolic SAR and leave only the Ichimoku code in place, the conditional order should accept that. We provided an example of this here: https://www.hahn-tech.com/thinkorswim-autotrade-almost/

Recursion, is when a variable must read a previous value of itself in order to calculate it’s current value.

( at May 23, 2017 12:35 pm)
0

Thanks again Pete! I was able to create my exit order w/o an error message.

( at May 23, 2017 4:43 pm)
0

Hi Pete,

I was wondering if you can translate the coding below into English for me so I know I understand.

def longExit = shortBreakConfirmed[-18];
def shortExit = longBreakConfirmed[-18];

AddOrder(OrderType.BUY_TO_OPEN, shortExit[-1], Min(open, open), tradeSize, Color.PINK, Color.PINK);

AddOrder(OrderType.SELL_TO_CLOSE, longExit[-1], Min(open, open), tradeSize, Color.PINK, Color.GREEN);

AddOrder(OrderType.SELL_TO_OPEN, longExit[-1], Max(open, open), tradeSize, Color.BLUE, Color.LIGHT_GREEN);

AddOrder(OrderType.BUY_TO_CLOSE, shortExit[-1], Max(open, open), tradeSize, Color.BLUE, Color.PINK);

( at May 24, 2017 12:25 pm)
0

Also, have you already covered the regenerating conditional orders? You mentioned the following on YouTube.

”1. There is an option you can check that will cause the conditional order to automatically regenerate after it is triggered. We do plan to cover this in a follow up video. If you attempt to do this I advise extreme caution and that you practice for a long time with PaperMoney before trying this with live money.
2. I’ll try to remember to cover this in the follow up video. It’s a great question.”

( at May 24, 2017 12:55 pm)
0

In regards to regenerating conditional orders. Unfortunately it has been confirmed this is actually not possible. The setting they provide on the conditional order is completely non-functional. You can read more about it here in this post: https://www.hahn-tech.com/ans/auto-trade-almost-and-automatically-regenerate-open-and-exit-orders/

Scroll down to the posts from April 12th, 2017.

As to the english translation of the code you posted. There is not really enough there to explain much. You have shifted the shortBreakConfirmed and longBreakConfirmed 18 bars into the future. I have no clue why you did that. You will get results that can never be replicated in live trading. And for each of the orders your entry price makes no sense at all. The Min of open or open is the same saying open. And instead of four AddOrder statements you can accomplish the very same result with two if you set the BUY_TO_OPEN to BUY_AUTO and likewise for the SELL_TO_OPEN. Given what I have seen here I am guessing you need a professional to review your code and make many corrections. This is way beyond the scope of anything we would cover in the Q&A forum.

( at May 24, 2017 3:26 pm)
0

Thanks Pete for clearing things up. At first I thought ”this can’t be replicated in real time”, but when I saw it plotted in the strategy I thought ThinkOrSwim certainly wouldn’t allow a way to make strategy results perform better actually possible & ThinkOrSwim is translating in way that I possibly don’t understand.

Your video ”Thinkorswim Strategy Guide MTF” is also a compliment to shortfalls found in strategies.

( at June 10, 2017 12:39 pm)
0

It absolutely is possible to write a strategy that cannot be replicated in real time. I see them all the time. Thinkorswim has no protections against it. That is up to each individual. Strategies are very complex pieces of code. Be sure to read my answer to the following post for more details: https://www.hahn-tech.com/ans/parablic-sar-signal-not-firing-in-tos-strategy/

( at June 10, 2017 2:05 pm)