Jump to content

We have moved to Discord. Please click here to join us in the Trading Terminal Discord server.



These forums are read-only.

kimfarr83

Hotkey to close and flip position

Recommended Posts

kimfarr83

Hello All,

Hope all of you are well.

I've got a hopefully easy fix question for those who might have it already. I would like to have a close and flip position hotkey please.

Scenario:

Step 1: Lets say I am short and want to cover my position and therefore I use the following hotkey from Kyle:

CXL ALLSYMB;Route=SMRTM;Share=Pos;Price=Ask+0.05;TIF=DAY+;BUY=Send;

Step 2: Now I would like to enter a long position with fixed risk, therefore I double click my stop loss price on the chart and use the following Kyle's hotkey:

StopPrice=Price-0.01;DefShare=BP*0.97;Price=Ask-Price+0.01;SShare=75/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=SMRTL;Price= Ask+0.05;TIF=DAY+;BUY=Send;DefShare=0;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.05 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

Question: Is it possible to have the above 2 steps in one single hotkey please?

Basically, I just need to get the amount of shares held in the current short, and add that number to the result of the long entry hotkey (step 2), before it is actually executed. That way the short is covered and a fixed risk long is opened.

Appreciate all the help.

Thanks in advance and good day,

Kim

Edited by kimfarr83

Share this post


Link to post
Share on other sites
paul ang

Wow that's a really complex kind of trading style. 

Definitely not my style hahaha, should be quite possible to set it up right?

Maybe can try with the sim and let us know.

Share this post


Link to post
Share on other sites
kimfarr83
2 hours ago, paul ang said:

Wow that's a really complex kind of trading style. 

Definitely not my style hahaha, should be quite possible to set it up right?

Maybe can try with the sim and let us know.

Not a very helpful comment but thanks anyway.

It is just that I do not know how to explain and the language barrier.

The hotkey above is just one of Kyle's hotkey which everybody uses as it works perfectly and it just basically calculates your number of shares based on your pre-determined risk. I think that should be a pretty standard approach no? To have a pre-determined risk I mean??!!!

Now, I am just asking to close any other positions for that ticker before actually executing  this trade. That's it!!

Anyway I have sorted it out in another post, I just add the current Pos value to the result of this hotkey. I still have an issue when flipping to a long though. Still, I can manage.

Thanks anyway,

Kim

Share this post


Link to post
Share on other sites
Bryan W

You would probably have to get Kyle's help directly for something like this if he was willing (he has been very busy latley).  You might be able to send him a direct message within the forum. In the top right of the forums, click the envelope and compose new... The type KyleK29. This is interesting for flipping a position with fixed risk, so maybe he would be interested in doing it.

Edited by Bryan Walquist

Share this post


Link to post
Share on other sites
kimfarr83
On 10/16/2020 at 7:43 PM, Bryan Walquist said:

You would probably have to get Kyle's help directly for something like this if he was willing (he has been very busy latley).  You might be able to send him a direct message within the forum. In the top right of the forums, click the envelope and compose new... The type KyleK29. This is interesting for flipping a position with fixed risk, so maybe he would be interested in doing it.

Hey Bryan,

Yeah will do that, appreciate your help.

Thank you,

Kim

Share this post


Link to post
Share on other sites
paul ang

Oh hey, i have tried it on SIM, basically, i think the easiest way is just to execute double of the opposite trade.

 

For example, if i'm LONG 1 share on ABC stock, if i need to flip it i will SHORT 2 share of it, automatically it will flip the position.

Something like that.

 

And the converse is true too, like if you are SHORT 4, you just need to LONG 8, to flip it.

Share this post


Link to post
Share on other sites
kimfarr83

Hello Paul,

Thanks a lot for your reply and suggestion.

Unfortunately it is not what I need. The reason is that if I just flip like that, the risk for the new trade would not be a fixed dollar value one in relation to the new technical stop loss.

Managed to do it one direction but not the other 😞

I sent to Kyle personally but got no reply yet. Maybe in time, and if that's the case I will provided it to you just in case you need it in the future.

Appreciate again the help,

Thanks,

Kim

Share this post


Link to post
Share on other sites
Joseph Yoo

Kimfarr83,

I've been working on the same script.  Here are the issues that I've come across and semi-solution w/ explanation below.

Preface: All of my trades calculates my share size with a risk of 0.5% of my equity and the distance of the stop (double click) price for both Long and Short.

I tried to combine my 100% sell/cover with my 0.5% long/short entry scripts, but it would only execute the first command.  When hitting this hot key, The 'Price' on the montage reverts from the double click stop price to the selling/covering price to close out the trade and therefore does not execute the 2nd command to enter the trade by calculating the share size needed for desired risk because that specific price amount needs to be in the montage, but reverted to the closing out of position price.  In other words, it doesn't work.

As I thought about it, I figured that I simply needed to close out of my existing position and add the new position with one simple hot key--closing out of the position and entering in the new one is the same action:  Sell/Short = Long to Flip.  Cover/Buy = Short to Long.

 

So what I did was utilize my 0.5% hot key that calculates the share size for desired risk (0.5% of equity) and added '+Pos'  after the SShare as follows in BOLD:

 

Long flipping to Short:

;CXL ALLSYMB;DefShare=BP*0.97;Share=DefShare*0.167*Price*0.005;Price=Price-Bid+0.01;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare+Pos;TogSShare;ROUTE=LIMIT;Price=bid-0.03;TIF=DAY+;SELL=Send;DefShare=100;

The hot key does close out my existing Long position and enters into a new flipped/short position where the amount of shares for the flip position is calculated based on where I double clicked my stop price and actual entry; however, due to buying power reasons (meaning, depending on the amount of buying power you have currently in the moment that is available to execute these hot keys/order commands because they change with every open position and/or order),  you would need to scale out of the original 1st position close to 100% and THEN use the flip key to get close to the same 0.5% risk and/or share size.  Let me explain it this way. 

 

Scenario 1:

If my first position is 1000 shares Long on ABC Stock with a .10cent spread/difference between stop and entry and I scaled out of my position to 100 shares left and wanted to FLIP the position short provided it's the same stop and entry distance as the first Long entry (.10 cents), the Short Share Size Position of the Flip would probably be close to 800-900~ shares because the existing 100 shares is taking up the available buying power to calculate how many shares you can enter--on the flip. 

 

I'm imagining the commands to ideally flow like this:

Original Position 1000 shares Long scaled to only 100 shares before the flip

New FLIP Position w/ same stop distance: -1100 shares Short (100 shares left of original position + 1000 shares for new position) to get in -1000 shares short for new position.

The idea was for the hot key to sell the existing position AT THE SAME TIME Sell short the new position, which is calculated by the stop distance.  Once again, share size on the flip varies based on available buying power and price of stock, which is attached to the amount of shares you're currently holding so it's most optimally used if you've been scaling out most of your original position.

Note: The price of the actual stock is an important factor to how much buying power you utilize for your share size.

Scenario 2:

If my first position is 1000 Shares Long on ABC stock with a .10cent spread/difference between stop and entry and I DID NOT scale out of the position and it remains at 1000 shares and I want to FLIP my position to the short side utilizing the same .10cent spread/difference, the Short Position size would be close to 500-750~ shares short instead of the 1000 shares.  Once again, due to the available buying power always changing with every order whether they're open positions or open orders.   This is also contingent on the actual Price of the stock as well.

The Flip Position Hot Key Share Size calculation on both flipping Long or Short will always be different due to changing available buying power.

 

Short Flipping to Long:

;CXL ALLSYMB;DefShare=BP*0.97;Share=DefShare*0.167*Price*0.005;Price=Ask-Price+0.01;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare+Pos;TogSShare;ROUTE=LIMIT;Price= Ask+0.03;TIF=DAY+;BUY=Send;DefShare=100;

This one works a little different than Long to Short and I'm not sure why.   Scenario 2 above works fine going from LONG to SHORT, but it DOES NOT work going from SHORT to LONG--I'm not sure why.

Testing the short to long flip hot key, it works very well when you scale out of your original short position first AND THEN flip to the long side.

 

Sorry for the long post and I hope it was concise enough to understand.

 

Long story short (Pun intended):

1. Both Flip Keys work extremely well ONCE you've scaled/closed out of most of your original position (80% is closed out and I'm left with about 10-20%) going into the Flip.

2. Long to Short Flip key-- you don't necessarily need to scale out of the Long position to get into a Short position; however, if you have a long position remaining, the Short Position size on the flip will vary even if it's the same stop distance as your long trade.  This is due to the available buying power that is constantly changing.

3. Short to Long Flip key-- DOES NOT flip your position Long if you DID NOT scale out of your original Short Position. It only works if you've already scaled OUT of your short position and THEN flip to the Long.  New Long position size will also vary due to available buying power.

4.  The new FLIPPED position will actually risk less than the 0.5%, which, to me, I think is actually a great thing so as to help me manage the risk and the trade when Flipping the position.

 

This is what I've got so far when it comes to flipping the position.  Hope that helps!

 

Bro

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
Joseph Yoo

Correction on point 4 at the end.

 

4. The new FLIPPED position does risk the 0.5% fairly close ONLY if you've scaled out of your original position and THEN flipped.

Share this post


Link to post
Share on other sites

[[Template core/front/global/mobileNavigation is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.