Jump to content
onlyjava

DAS throwing a Script: Invalid price ERROR **SOLVED**

Recommended Posts

I am trying to use this script for a hot button to set a STOP LOSS:

CXL ALLSYMB;ROUTE=STOP;StopType=Market;StopPrice=Last-100/Pos;StopPrice=Round2;Share=Pos;TIF=DAY+;SELL=Send;

OR

CXL ALLSYMB;ROUTE=STOP;StopType=Market;StopPrice=AvgCost-100/Pos;StopPrice=Round2;Share=Pos;TIF=DAY+;SELL=Send;

The above scripts throws the following ERROR

Script: Invalid price 

Looks like DAS is not liking 

100/Pos

[  STOPPRICE = (AvgCost*Pos-100)/Pos = AvgCost - (100/Pos)  = AvgCost - 100/Pos ] 

If AvgCost=5 and Pos=25

STOPPRICE = 5 - 100/25 = $1

which means that the StopLoss value = ($5 - $1) * 25 = $ 100

I am using this formula to fix my Stop Loss to $100 - a  fixed amount.

Why is DAS throwing an error for this? 

Any pointers will be appreciated - thanks in advance.

 

**SOLVED**

 

Gist:

Stop Price does not support the POS command

Use this workaround:

CXL ALLSYMB;Share=Pos;Price=100/Share;Price=Last-Price;Price=Round2;ROUTE=STOP;StopType=Market;StopPrice=Price;Share=Pos;TIF=DAY+;SELL=Send;

 

Here's my interaction with DAS support chat

--------------------------

kris:
Hello, 
I am trying to use this script for a hot button to set a STOP LOSS: 
CXL ALLSYMB;ROUTE=STOP;StopType=Market;StopPrice=Last-100/Pos;StopPrice=Round2;Share=Pos;TIF=DAY+;SELL=Send; 
The above script throws the following ERROR 
Script: Invalid price  
Looks like DAS is not liking  
100/Pos 
I am using this formula to fix my Stop Loss to $100 - a  fixed amount. 
Why is DAS throwing an error for this?

        Call accepted by operator Customer Service. Currently in room: Customer Service, kris.

Customer Service:
Hi this is Rashada'
Customer Service:
Please allow me some time to review
kris:
thanks
Customer Service:
Allow me to use your script
kris:
ok
Customer Service:
Yes the rejection is coming from Stopprice=Last-100/Pos
kris:
the formula is correct
kris:
[  STOPPRICE = (AvgCost*Pos-100)/Pos = AvgCost - (100/Pos)  = AvgCost - 100/Pos ]  
 
If AvgCost=5 and Pos=25 
 
STOPPRICE = 5 - 100/25 = $1 
 
which means that the StopLoss value = ($5 - $1) * 25 = $ 100
kris:
so looks like DAS is not allowing 100/Pos ?
kris:
I can use AvgCost - 0.15 and it is fine
kris:
AvgCost or Last
Customer Service:
Just a moment
Customer Service:
Stop Price does not support the POS command
kris:
is there a workaround - like using DefShare=Pos;StopPrice=Last-100/DefShare - something like this?
Customer Service:
What are you trying to do?
kris:
I am using this formula to fix my Stop Loss to $100 - a  fixed amount.
kris:
see the calculation above
Customer Service:
You may try this hotkey to set your stop loss to be $100
Customer Service:
CXL ALLSYMB;Share=Pos;Price=100/Share;Price=Last-Price;Price=Round2;ROUTE=STOP;StopType=Market;StopPrice=Price;Share=Pos;TIF=DAY+;SELL=Send;
Customer Service:
Please test all Hotkey scripts prior to use to ensure accuracy. It is the responsibility of the trader for all order sent.
kris:
Appreciate your help - thank you so much!
Customer Service:
You are welcome
Customer Service:
Is there anything else I can assist you with?
kris:
No - thank you
Customer Service:
I hope you have a nice day. Goodbye!

----------------------------------------------------

 

Here's how my hot buttons look like 🙂

With the $100 stop loss, once it is set, I can click and drag it to adjust - you just have to enable it in your chart area.

Also, I can hit the button again - since it is programmed on Last, it will re-adjust.

image.thumb.png.99135cf1bda9f5cb7d0e73e12348e36a.png

 

 

Edited by onlyjava
  • Like 1

Share this post


Link to post
Share on other sites

Maybe it should be avgcost-100/Pos, but I’m just guessing, I’m sure someone else with more knowledge of scripts can help you out.


If you don’t have a mountain to climb, find one.

Share this post


Link to post
Share on other sites

Tried avgcost-100/Pos - same error

Looks like it is the 100/Pos part that is causing the error.

Thanks for the response.

Share this post


Link to post
Share on other sites

image.thumb.png.eb1093beb19660c6c09218760849de99.png

 

peterB - Your math is wrong - see figure in red!

 

if LAST=100 & POS=50

(Last*Pos-100)/Pos

(100*50-100)/50 = (5000-100)/50 = 4900/50=98

Last-100/Pos

100-100/50=100-2=98

 

Edited by onlyjava
  • Like 1

Share this post


Link to post
Share on other sites
On 3/22/2020 at 11:21 PM, onlyjava said:

Use this workaround:

CXL ALLSYMB;Share=Pos;Price=100/Share;Price=Last-Price;Price=Round2;ROUTE=STOP;StopType=Market;StopPrice=Price;Share=Pos;TIF=DAY+;SELL=Send;

Thank you for posting this. You would think this script would be one of the main basic ones available. I've been trying to figure this out for a few hours!

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.