Jump to content
Day-Meister

Defined Risk Hotkeys for multiple range orders

Recommended Posts

3 hours ago, Day-Meister said:

OK, Try this for long:

CXL ALLSYMB; StopPrice=Price-0.01;DefShare=BP*0.5;Share=DefShare*0.333*Price*0.01;Price=Ask-Price+0.01;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;Share=Share/4;Share=Share*4;TogSShare;ROUTE=SMRTL;Price= Ask+0.05;TIF=DAY+;BUY=Send;DefShare=1000;
Price=Ask-StopPrice*1.5 +Ask;TriggerOrder=RT:SMRTL; Price=Round2; PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*2+Ask;TriggerOrder=RT:SMRTL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*3+Ask;TriggerOrder=RT:SMRTL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*4+Ask;TriggerOrder=RT:SMRTL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.3 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

and this for short:

CXL ALLSYMB; StopPrice=Price+0.01;DefShare=BP*0.5;Share=DefShare*0.333*Price*0.01;Price=Price-Bid+0.01;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;Share=Share/4;Share=Share*4;TogSShare;ROUTE=SMRTL;Price= bid-0.05;TIF=DAY+;SELL=Send;DefShare=1000;
Price=StopPrice-Bid*1.5;Price=Bid-Price; Price=Round2;TriggerOrder=RT:SMRTL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*2;Price=Bid-Price; TriggerOrder=RT:SMRTL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*3;Price=Bid-Price; TriggerOrder=RT:SMRTL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*4;Price=Bid-Price; TriggerOrder=RT:SMRTL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.3 ACT:BUY STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

That is for sizing based on BP

Replace the first line of each with the corresponding code for $fixed risk from above.

In testing, I noticed that sometimes it would only create 3 orders (I suspect it has something to do with calculation of the 1.5R) (EDIT: pretty sure that was the issue; corrected script with ROUND2 to hopefully fix that)

@Day-Meister Thanks so much! This is awesome; tested it in simulator. I adjusted it for $Fixed risk and also other Rs (just need the orders in and then I can slide em where I need on the chart) it seems to work. Just want to make sure its right or if anyone else needs it that its here This is for a short entry with a $20 Risk. I changed routes to my preferred routes and also because my broker doesn't use SMRTL (ILIMIT is what they use and I've seen some brokers use in Kyles excel file). Here's what I've got:

 

CXL ALLSYMB; StopPrice=Price+0.01;DefShare=BP*0.5;Price=Price-Bid+0.01;SShare=20/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;Share=Share/4;Share=Share*4;TogSShare;ROUTE=LIMIT;Price= bid-0.05;TIF=DAY+;SELL=Send;DefShare=1000;
Price=StopPrice-Bid*2;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*3;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*4;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*5;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.3 ACT:BUY STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

And for SSR gets changed to: ROUTE=LIMIT;Price= bid+0.01;TIF=DAY+;SELL=Send;DefShare=1000;

 

And Long will be:

CXL ALLSYMB; StopPrice=Price-0.01;DefShare=BP*0.5;Price=Ask-Price+0.01;SShare=20/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;Share=Share/4;Share=Share*4;TogSShare;ROUTE=LIMIT;Price= Ask+0.03;TIF=DAY+;BUY=Send;DefShare=1000
Price=Ask-StopPrice*2+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*3+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*4+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*5+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.3 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

This is definitely a life saver. Work smarter, not harder! Thanks again!

Share this post


Link to post
Share on other sites
3 minutes ago, jokajon00 said:

@Day-Meister Thanks so much! This is awesome; tested it in simulator. I adjusted it for $Fixed risk and also other Rs (just need the orders in and then I can slide em where I need on the chart) it seems to work. Just want to make sure its right or if anyone else needs it that its here This is for a short entry with a $20 Risk. I changed routes to my preferred routes and also because my broker doesn't use SMRTL (ILIMIT is what they use and I've seen some brokers use in Kyles excel file). Here's what I've got:

 

CXL ALLSYMB; StopPrice=Price+0.01;DefShare=BP*0.5;Price=Price-Bid+0.01;SShare=20/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;Share=Share/4;Share=Share*4;TogSShare;ROUTE=LIMIT;Price= bid-0.05;TIF=DAY+;SELL=Send;DefShare=1000;
Price=StopPrice-Bid*2;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*3;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*4;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
Price=StopPrice-Bid*5;Price=Bid-Price; TriggerOrder=RT:NSDQL PX:Price ACT:BUY QTY:POS*.25 TIF:DAY+;
TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.3 ACT:BUY STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

And for SSR gets changed to: ROUTE=LIMIT;Price= bid+0.01;TIF=DAY+;SELL=Send;DefShare=1000;

 

And Long will be:

CXL ALLSYMB; StopPrice=Price-0.01;DefShare=BP*0.5;Price=Ask-Price+0.01;SShare=20/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;Share=Share/4;Share=Share*4;TogSShare;ROUTE=LIMIT;Price= Ask+0.03;TIF=DAY+;BUY=Send;DefShare=1000
Price=Ask-StopPrice*2+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*3+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*4+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
Price=Ask-StopPrice*5+Ask;TriggerOrder=RT:NSDQL PX:Price ACT:SELL QTY:POS*.25 TIF:DAY+;
TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.3 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

This is definitely a life saver. Work smarter, not harder! Thanks again!

Excellent! Glad you got something that works for you!

Share this post


Link to post
Share on other sites
Posted (edited)

Hey all! Amazing script thank you so much might help me a lot. I tend to exit my position sooner than I should. 

Anyone tried it with a fixed $ risk amount? Once 2R hits does the stop loss gets updated with the remaining shares.

 

Also I've noticed that when the STOP Loss hits it doesn't cancel the order target orders. Anyone found a way to fix this? 

 

EDIT: Is there a way to do the following: (1) Have my stop-loss updated with the new position if it hits one of the profit targets? 2) once both profit targets hit have that order removed? (3) if any of the profit targets hit have the stoploss moved to the breakeven range? 

Thanks!! @KyleK29  @Day-Meister
Edited by Fernando Samora
Added new info.

Share this post


Link to post
Share on other sites
On 3/14/2022 at 8:35 PM, Fernando Samora said:

Hey all! Amazing script thank you so much might help me a lot. I tend to exit my position sooner than I should. 

Anyone tried it with a fixed $ risk amount? Once 2R hits does the stop loss gets updated with the remaining shares.

 

Also I've noticed that when the STOP Loss hits it doesn't cancel the order target orders. Anyone found a way to fix this? 

 

EDIT: Is there a way to do the following: (1) Have my stop-loss updated with the new position if it hits one of the profit targets? 2) once both profit targets hit have that order removed? (3) if any of the profit targets hit have the stoploss moved to the breakeven range? 

Thanks!! @KyleK29  @Day-Meister

Hey Fernando,

- The Stop Loss for the remaining orders can not be updated automatically based on the automated profit taking as it is all set in one motion when you enter the trade. I don't know of anyway to carry your cost variable forward and have it re-write the orders based on the first (or any subsequent) fill.

- There are examples of this script with fixed $ in the thread

- If it is set up correctly, all orders should be set as range orders, therefore as soon as one condition is met (a specific target is achieved), the entire portion of that order will be complete leaving you with the remaining orders (or none in the case of stop loss). There should not be a state where one of the conditions of the range order is hit and executed but leaving the other side of the range intact.

- If all your profit targets are hit, you should be left with 1 outstanding stop loss order for 1/4 of your original share size; This is by design in order to let you manually ride the trend until you decide to exit.

 

I hope that answers your question.

Share this post


Link to post
Share on other sites

Hi @Day-Meister,

Thanks for your script, it works nearly great.

I chose the following one (short - $ risk / trade) where I replace the value 50 by 300 in order to have a $ 300 risk trade (capital 100 K)

Quote

CXL ALLSYMB; StopPrice=Price+0.01;DefShare=BP*0.5;Price=Price-Bid+0.01;SShare=300/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;Share=Share/4;Share=Share*4;TogSShare;ROUTE=SMRTL;Price= bid-0.05;TIF=DAY+;SELL=Send;DefShare=1000;Price=StopPrice-Bid*2;Price=Bid-Price;TriggerOrder=RT:STOP STOPTYPE:RANGE LowPrice:Price HighPrice:StopPrice ACT:BUY QTY:POS*.25 TIF:DAY+;Price=StopPrice-Bid*3;Price=Bid-Price;TriggerOrder=RT:STOP STOPTYPE:RANGE LowPrice:Price HighPrice:StopPrice ACT:BUY QTY:POS*.25 TIF:DAY+;Price=StopPrice-Bid*4;Price=Bid-Price;TriggerOrder=RT:STOP STOPTYPE:RANGE LowPrice:Price HighPrice:StopPrice ACT:BUY QTY:POS*.25 TIF:DAY+;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.3 ACT:BUY STOPPRICE:StopPrice QTY:Pos*.25 TIF:DAY+;

When I replace the value 50 by 100, it works perfectly. I get the good amount of shares so that my total risk = $100. Perfect.

But in the script above, when I replace 50 by 300, I don't get a $300 risk. Even stranger, I made 3 trades on AAPL as a test tonight and I got the exact same amount of shares (344) opened, regardless the size of the risk.

Example 1 : entry = 145.16 / stop loss = 145.53 => risk = $0.37 / number of shares = 344 / total risk = $127.28

Example 2 : entry = 145.11 / stop loss = 145.2 => risk = $0.09 / number of shares = 344 / total risk = $30.96

Example 3 : entry = 145.32 / stop loss = 145.74 => risk = $0.42 / number of shares = 344 / total risk = $144.48

Did I do something wrong ?

Thanks for your help.

Best,

Pierre

 

Share this post


Link to post
Share on other sites
Posted (edited)
17 minutes ago, paqueuc said:

Hi @Day-Meister,

Thanks for your script, it works nearly great.

I chose the following one (short - $ risk / trade) where I replace the value 50 by 300 in order to have a $ 300 risk trade (capital 100 K)

When I replace the value 50 by 100, it works perfectly. I get the good amount of shares so that my total risk = $100. Perfect.

But in the script above, when I replace 50 by 300, I don't get a $300 risk. Even stranger, I made 3 trades on AAPL as a test tonight and I got the exact same amount of shares (344) opened, regardless the size of the risk.

Example 1 : entry = 145.16 / stop loss = 145.53 => risk = $0.37 / number of shares = 344 / total risk = $127.28

Example 2 : entry = 145.11 / stop loss = 145.2 => risk = $0.09 / number of shares = 344 / total risk = $30.96

Example 3 : entry = 145.32 / stop loss = 145.74 => risk = $0.42 / number of shares = 344 / total risk = $144.48

Did I do something wrong ?

Thanks for your help.

Best,

Pierre

 

What I think is happening is you don't have enough buying power for it to purchase a full $300 risk.

If it is a margin account and you have $100k available BP, the script is designed to use half of that amount: "DefShare=BP*0.5", so $50K

344 shares * $145 = $49,880

So, although you narrowed your stop loss vs. the purchase price, you couldn't achieve more than your total def shares as above. If you want to test that theory, you can change the "DefShare=BP*0.5" to "DefShare=BP*0.75" and see if that changes the amount of shares it takes.

Edited by Day-Meister

Share this post


Link to post
Share on other sites
Posted (edited)

what is your buying power/BP? you have half of the BP used in the script

test with wider stop like 2 dollars to see if you hit the BP limit or not

Edited by peterB

Share this post


Link to post
Share on other sites

Thanks @Day-Meister and @peterB,

I'm currently in the Peak Capital Trading demo DAS account. I don't know the BP set on this account. But with Day-Meister's explanation, I got a key that I didn't see before. I'll give it a try.

If we are willing to risk a maximum of 1% per trade and dealing with a maximum of 2 trades at the same time, do we need to take this extra caution of reducing our BP by 50 % ? What's the real motivation of doing this ?

Before DAS, I was using TWS with IB and never got a margin problem on my live account when I was risking 1% of my account on a single trade. I could even run 2 or 3 trades at the same time without issue. But I don't know how DAS manages - interact with the IB buying power...

Thanks for your thoughts on this.

Share this post


Link to post
Share on other sites
1 minute ago, paqueuc said:

Thanks @Day-Meister and @peterB,

I'm currently in the Peak Capital Trading demo DAS account. I don't know the BP set on this account. But with Day-Meister's explanation, I got a key that I didn't see before. I'll give it a try.

If we are willing to risk a maximum of 1% per trade and dealing with a maximum of 2 trades at the same time, do we need to take this extra caution of reducing our BP by 50 % ? What's the real motivation of doing this ?

Before DAS, I was using TWS with IB and never got a margin problem on my live account when I was risking 1% of my account on a single trade. I could even run 2 or 3 trades at the same time without issue. But I don't know how DAS manages - interact with the IB buying power...

Thanks for your thoughts on this.

This gives maximum flexibility over a variety of stocks trading at varying price levels. Basically, your BP is fixed and is based on what DAS has calculated. so BP *.5 allows you to enter 2 trades at the same time using a total of your Max BP. The issue you have run up against is that your risk level is so narrow on this price of stock that it is not giving you full risk $, but using the full amount of buying power you have elected to use per trade. (for example: If I have a micro account with BP of $100 and want to risk all of it on a stock that is trading at $50, it doesn't matter where I put my Stop, I can't buy more than 2 shares)
 

As for DAS, you should see what DAS has calculated as your buying power in your account window. You should also be able to see BP withheld in your positions window.

Hope that makes sense.

Share this post


Link to post
Share on other sites

Yes, it makes a lot of sens. Thanks @Day-Meister

Sure enough this BP logic is risk free for the broker as a stock may go to 0 but it is rare.

Nevertheless, In the PCT account, the BP is 100 K and this will have an impact on my strategies (not letting a profitable partial trade run for the rest of the day as it will impact my possibility of opening a new trade at full size).

Thanks a lot.

Share this post


Link to post
Share on other sites

just lower your risk and you are gonna be fine with 100k BP

you have 2 months to reach the profit target

Share this post


Link to post
Share on other sites

Yes  @peterB. I do agree. Honnestly, I don't care about the profit target. The rules are clear. I just want to learn and improve.

The starting point was that 1% risk / trade commonly seemed to be an acceptable ratio in the real life. As I'm growing, I'm more willing to take less and less risk, even in my real trades. Currently, I'm thinking about 0.5 to .8% / trade. And here at PCT, I was thinking even lower, around 0.3% ($300) just to be able to make a lot of errors and progress. Now, the Buying Power comes in to play in PCT and I didn't see it (That is the reason of my question). In IB, I currently have around  a 6X buying power. It never restricted me to have 2 or 3, 1% risk trades on at the same time, so I didn't think of this detail anymore.

 

Share this post


Link to post
Share on other sites
Posted (edited)

in IB you have 6X BP just on paper as margin requirements apply. you will never be able to utilize the full BP for all stocks and especially for short positions so these limits exist everywhere and we need to learn to live with them. the goal of PCT camp is to show consistency and process, not big numbers

Edited by peterB

Share this post


Link to post
Share on other sites

You're right. On paper only as BP decreases when volatility increases. In March 20, I got a margin call, so I understood it very well.

Today, I'm focusing on risk per trade only. 6X is just a confortable margin to forget that you have a BP to deal with (under "normal market cconditions", we do agree).  PCT just reminds me that this detail also exists and it is fine. I quite agree with you regarding the goal of PCT, I'm here for this exact reason : process and consistency. I'm not looking for a seat at the end of the bootcamp and I don't care if I reach the 10K goal or not. I just want to be consistently profitable at the end of the bootcamp as I'm currently in the breakeven zone since 2 years now.

 

Share this post


Link to post
Share on other sites

Just found this, wow! So many people asking for Kyle's to set range orders and here you are with it all figured out, nice work! 

It would be great if there was an easy way to move all of the stops to breakeven after the first target is hit, any ideas?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

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.