88 Comments
User's avatar
Korey's avatar

What can I do to adapt these to work with Schwab's OCO's/

Expand full comment
Peter Benci's avatar

you need to edit the route names for your entries

Expand full comment
Jurg Daku's avatar

Hey Peter, I tried these keybinds but I can't see the drag stop loss on my chart. I've setup the chart based on part 1 and enabled advanced hotkeys. I use version 5.8.0.6 x64 with Cobra

Expand full comment
Peter Benci's avatar

Helo,

probably this:

right click the chart -> chart area -> config area

check boxes for

-enable placing alert on chart

-show trades

-show orders

- enable order entry and order line movement

- hide order trype/qty

Expand full comment
Jurg Daku's avatar

Thank you so much for replying, I managed to get it to work. It was placing a stop order where I expected and I could actually drag it but it never gets triggered and I guess that's because I'm testing it during extended hours?

Expand full comment
Peter Benci's avatar

yes the traditional stops work only during market hours. if you need premarket working stops there are different solutions with more advanced scripting syntax

Expand full comment
Jurg Daku's avatar

ah right, I think that's one of the ones from your more recent posts. It's a shame das doesn't support this out the box and we have to resort to scripts :)

Expand full comment
Jurg Daku's avatar

Peter have I understood this post part 2 and part 8 correctly in that for part 8 to work I still have to enter my positions via the script on this part 2 first?

Also I get the error that many others get where by there is an error on line 7.

Expand full comment
Peter Benci's avatar

yes you enter the usual way. i do not know about the error until you say exactly what you are doing and what error you get

Expand full comment
Korey's avatar

Is there a way to modify the fixed risk with oco target scripts to work with Das/Schwab?

Expand full comment
Peter Benci's avatar

anything specific? you probably need to change just the route

Expand full comment
Jason's avatar

Hi Peter, thanks for the hot keys. I use the same script to exit partials but I’m trying to figure something out. For example, after a long position has progressed into profit I’d manually move the stop up. The issue I’m having is that when I take partial profits using the script the stop moves back to the initial location (double clicked location on chart). Do you know how the script could be modified to keep the stop from moving? Thanks

Expand full comment
Peter Benci's avatar

hi Jason, which script are we talking about?

Expand full comment
Jason's avatar

50% Partial Exit (updates stop shares)

CXL ALLSYMB;Route=SMRTL;Share=Pos*0.50;Price=Ask-0.01;TIF=DAY+;SELL=Send;ROUTE=STOP;StopType=Market;StopPrice=StopPrice;Share=Pos-share;TIF=DAY+;SELL=SEND

Expand full comment
Peter Benci's avatar

that does not seem to be a script from me... neither it is advanced hotkeys syntax. anyway you need to keep track of your original stop in a variable since the moment you entered the trade (only with advanced hotkeys enabled), or define a new stop by clicking on the chart and execute the hotkey that sets your stopprice to PRICE and position to POS

Expand full comment
Jason's avatar

My apologies, sent the wrong script. I was referring to the script below to close partials.

CXL ALLSYMB;

ROUTE="SMRTL";

Price=BID-0.05;

Price=Round2;

Share=Pos*0.50;

TIF=DAY;

SELL=Send;

ROUTE="STOP";

StopType="Market";

StopPrice=AvgCost;

Share=Pos-share;

TIF=DAY+;

SELL=SEND;

Expand full comment
Peter Benci's avatar

that script sets the stop to average cost of your position not to original stop so i am confused

i you want the stop to remain where you set it, change the Stopprice=$Mystop; instead of StopPrice=AvgCost;

it expects that you entered with the hotkey i provided for the entry too which sets the variable $mystop to a clicked price on the chart.

Expand full comment
Keith Allen's avatar

The hotkey for a buy stop limit doesn't seem to work any longer. It sets a buy stop for the top limit price, but does not seem to trigger at the actual price you'd like to enter. So if I do a price of $1.00 - it crosses $1.00, but doesn't seem to trigger, so it doesn't do anything til the top of the limit at $1.05.

Using DAS 5.8.0.3 Any ideas to make it work with this version?

CXL ALLSYMB;

$MYRISK=Price-$MYSTOP;

$MYSHARES=20/$MYRISK;

Share=$MYSHARES;

TogSShare;

StopPrice=Price;

TIF=DAY+;

Route="STOP";

StopType="Limit";

Price=Price+0.05;

Buy=Send;

TriggerOrder=RT:STOP STOPTYPE:MARKET PX:$MYSTOP ACT:SELL STOPPRICE:$MYSTOP QTY:Pos TIF:DAY+;

Expand full comment
Peter Benci's avatar

Anyway, if you see the order placed then there is no issue your order just got skipped because of the lack of liquidity at the price you wanted

Expand full comment
Peter Benci's avatar

use 5.8.0.6 version

Expand full comment
Chris M's avatar

these are great, thank you. ive been trying to come up with a fixed risk hot key long/short but instead of using market to enter the order, been trying to do something like split the spread with a limit order. any idea?

Expand full comment
Peter Benci's avatar

hi Chris, these are limit orders entry hotkeys. What do you need to solve?

Expand full comment
Chris M's avatar

sorry, should've been a little more clear. instead of buying the ask with a limit order im wanting to fill closer to the bid. i guess i could do something like this?

CXL ALLSYMB;

$buyprice=Bid+0.01; // Adjust to buy at the bid price plus 0.01

$risk=20;

$mystop=price;

$pricetostop=$buyprice-$mystop;

$amount=$risk/$pricetostop;

SShare=$amount;

Share=$amount;

TogSShare;

ROUTE="SMRTL";

Price=$buyprice*1.005;

Price=ROUND2;

TIF=DAY+;

BUY=Send;

TriggerOrder=RT:STOP STOPTYPE:MARKET PX:$mystop ACT:SELL STOPPRICE:$mystop QTY:Pos TIF:DAY+

Another one I've been struggling with is the same kind of order (fill slightly above bid) but use a stop limit order to exit - mostly for premarket small cap crazy stocks

but when I try this script

CXL ALLSYMB;

$buyprice=Bid+0.01; // Adjust to buy at the bid price plus 0.01

$risk=20;

$mystop=price;

$pricetostop=$buyprice-$mystop;

$amount=$risk/$pricetostop;

SShare=$amount;

Share=$amount;

TogSShare;

ROUTE="SMRTL";

Price=$buyprice*1.005;

Price=ROUND2;

TIF=DAY+;

BUY=Send;

TriggerOrder=RT:STOP STOPTYPE:LIMIT PX:$mystop ACT:SELL STOPPRICE:$mystop LIMITPRICE:($mystop-0.20) QTY:Pos TIF:DAY+

i get "invalid shares" as the error

Expand full comment
Peter Benci's avatar

you probably have not enabled advanced hotkeys in das trader pro settings or you are using version 5.8.0.5 which has a bug

Expand full comment
Albert's avatar

I am indeed running version '5.8.0.5 x64' which I can't change because it's part of a training program, so I understand your hotkeys unfortunately don't work with this version?

Expand full comment
Dan Steel's avatar

Peter, I use the short with the oco 3r script. However, when I double-click and hit the hotkey, I don't see the short order entered, only the limit order. Do you know how to fix this?

Expand full comment
Peter Benci's avatar

hi Dan,

it will be placed only after your limit entry hotkey is fully filled as it uses the TRIGGER ORDER command which has this limit

Expand full comment
Dan Steel's avatar

I tested it on replay, I will try it on real-time tomorrow. Thank you very much

Expand full comment
Korey's avatar

These are great!

Expand full comment
shridhar kumar's avatar

Good day Peter,

When i use your Static risk of $20 with automatic stop loss order attached it pops up a message stating

"trigger order only work in montage window."

What should i do for this error?

Thanks

Expand full comment
Komal's avatar

I get the following error.

Msg Box Script : Invalid operator

and this error in Montage Error:Invalid Shares!

When I run the below script using hot Button ($20 risk with 3x target ), I first double click on chart where I want the stop price and then click this Hot Button then I get the above error.

I have latest version of DAS 5.8.0.4 9 Nov 29th, 2024.

Please help.

CXL ALLSYMB;

$buyprice=Ask;

$risk=20;

$mystop=price;

$pricetostop=$buyprice-$mystop;

$target=3*$pricetostop+Ask;

$amount=$risk/$pricetostop;

SShare=$amount;

Share=$amount;

TogSShare;

ROUTE="SMRTL";

Price=$buyprice;

Price=ROUND2;

TIF=DAY+;

BUY=Send;

TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$mystop HighPrice:$target ACT:SELL QTY:POS TIF:DAY+;

Expand full comment
Komal's avatar

Forgot to mention that I am using Replay mode.

Expand full comment
Peter Benci's avatar

do not expect replay mode to work with advanced scripting as the data often does not exist

Expand full comment
EJ's avatar

Hi Peter, is there a way to store and change a variable's value in just one place, so that you can include that variable in multiple hotkeys, but only have to change the value in the one place, instead of having to change the value in each individual hotkey?

Expand full comment
Peter Benci's avatar

hi EJ, sure there is a way. You can have a prompt for that if you need to change it often or use it as a switch between two values as i do in one of the later posts with the account switcher. Also you csn have it changed based on any calculated or measured indicator value.

Expand full comment
Wahid's avatar

love your work and just started following your blog for the scripts. Quick question: For the 'Static risk of $20 with automatic stop loss order,' how do I set up a fixed number of shares (like 100 shares) instead of having it automatically calculate the number of shares. Thanks.

Expand full comment
Peter Benci's avatar

you just place a static number at the shares part

Expand full comment
Wahid's avatar

Thanks for your reply, Peter. I did as you mentioned but the stop loss is not working. It is simply not stopping when the loss is over $20. Appreciate your suggestion.

Expand full comment
Peter Benci's avatar

how is it not working? has the order been placed or not?

Expand full comment
Wahid's avatar

Yes, order has been placed. I am using a simulator account. Do you want me to share a screenshot with you?

Expand full comment
Peter Benci's avatar

that would certainly help

Expand full comment
Wahid's avatar

https://postimg.cc/DW3Ppvvv

here is the script:

---------

CXL ALLSYMB;

$buyprice=Ask;

$risk=20;

$mystop=price;

$pricetostop=$buyprice-$mystop;

$amount=$risk/$pricetostop;

SShare=100;

Share=100;

TogSShare;

ROUTE="SMRTL";

Price=$buyprice*1.005;

Price=ROUND2;

TIF=DAY+;

BUY=Send;

TriggerOrder=RT:STOP STOPTYPE:MARKET PX:$mystop ACT:SELL STOPPRICE:$mystop QTY:Pos TIF:DAY+

Expand full comment
Bill's avatar

Hi Peter, For your entry hot keys, what is the reason or purpose for putting in the line SSHARE=$amount?

Expand full comment
Peter Benci's avatar

that was an old school habit to toggle show share. it is not necessary and you can omit that completely

Expand full comment
Lazzy's avatar

Hi Peter, Love your scripts, good work, thank you.

I need to ask you if is it even possible,

Static risk with $20 and attached range (OCO) orders of 3R target - for this script,

can we have two different range orders at the end with 50% position out at 3R and rest of 50% at 4R? like two different targets?

Expand full comment
Peter Benci's avatar

yes that is quite easy to acomplish-one is to divide it to two orders. the disadvantage is that if you get stopped you pay double commissions. the other is by calling the partial hotkeys at the desired time which has the disadvantage of being complex and has its limitations but i can figure it out with the new timer scripts

Expand full comment
Nayef's avatar

Hi Peter,

I was testing the (Static risk with $20 and attached range (OCO) orders of 3R target) on DAS with a sim account. I have IBKR account by the way. It worked in buying the shares but didn't place any OCO orders for STOP or Take Profit at 3R. any idea why ?

Expand full comment
Peter Benci's avatar

hi, you probably missed some of the prerequisities or have a syntax error in the script

Expand full comment
Nayef's avatar

Advanced hotkey and double click to trade are both checked and Style is Stop. My other Kyle's hotkeys work fine.

I used the exact script in Replay Mode and selected the sim account on the montage. What should the route be?

Expand full comment
Peter Benci's avatar

Replay mode is very special. many things do not work there. always test in SIM not in Replay Mode

Expand full comment
Nayef's avatar

Never mind. I was testing them yesterday in a Replay mode and it didn't work properly. Today I tested them when the market opened, and it worked flawlessly.

I need to tweak a little bit on the ($buyprice=Ask) to make me get filled faster.

Also, I tested a risk of $10 on AMZN, and the realized gain was $28.40, I was expecting it to hit exactly $30 as a 3R profit target.

Expand full comment
Peter Benci's avatar

you can always get some slippage

-on calculation (spread)

-on entry

-on exit

-on commissions and fees

Expand full comment
Ben's avatar

Hello Peter,

Is it possible to have a condition based on whether my position is a long or a short ?

If I currently hold a long : do this, but if it's a short : do that.

Thank you !

Expand full comment
Peter Benci's avatar

yes for example you can exit in a single button.hotkey like this

$MYPOS=GetAccountObj("TRIBT8888").getposition($MYSYMB).share;

if ($MYPOS==0)

{

MsgBox("No position to close");

}

else

{

CXL ALLSYMB;

ROUTE=SMRTL;

if ($MYPOS > 0)

{

Share=$MYPOS;

Price=Bid*0.99;

Price=ROUND2;

SELL=Send;

}

else

{

Share=$MYPOS;

Price=Ask*1.01;

Price=ROUND2;

BUY=Send;

}

}

Expand full comment
Ben's avatar

Is it possible to not calling the account number ? So I can go easily from sim to real ?

Expand full comment
Peter Benci's avatar

you can create account number trigger into a variable then use that variable in the scripts

Expand full comment
Ben's avatar

Great It works thank you.

Before that I was doing MYPOS=GetWindowObj("Montage").share;

but would only give me positive number whether it was long or short.

Now with your script it's fine ;)

Expand full comment