NexusFi: Find Your Edge


Home Menu

 





How to place an order where the stop loss price changes when a price is touched


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one hamstonil with 6 posts (4 thanks)
    2. looks_two kevinkdog with 3 posts (4 thanks)
    3. looks_3 Blash with 3 posts (2 thanks)
    4. looks_4 planetkill with 1 posts (0 thanks)
    1. trending_up 4,645 views
    2. thumb_up 10 thanks given
    3. group 5 followers
    1. forum 14 posts
    2. attach_file 0 attachments




 
Search this Thread

How to place an order where the stop loss price changes when a price is touched

  #11 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,664 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,359


hamstonil View Post
How would you do it in EasyLanguage? I was actually going to figure that out myself as a next step as soon as I figured out how to do it the Trade Bar. Currently, I have a TradingApp I made placing an entry order with 2 OCO's attached to it (OSO): one that's -1R stop, +1R profit and the other is -1R stop, +2R profit. Those 5 trades go in together and work excellent. But I want it to move the -1R stop loss on the -1R/+2R bracket up to 0R as soon as that -1R/+1R bracket trades (i.e., as soon as the stock hits +1R).

If you are in a long trade, it would look something like this:

if marketposition=1 then begin

sell next bar at XXXX stop;
sell next bar at YYYY limit;
end;


XXXX and YYYY would be prices you calculate based on your scheme. You could use reserved words like "maxpositionprofit" and "openpositionprofit" to help you know when to move stops.

Simple example:

XXXX=3100.00; //set stop at price of 3100

if maxpositionprofit> 1000 then XXXX=3140; //once $1000 per contract hit, stop moves up to 3140


It can get trcky, but that should at least get you started.

Follow me on Twitter Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
NexusFi Journal Challenge - May 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
 
  #12 (permalink)
hamstonil
Kansas City, MO, United States
 
Posts: 6 since Jul 2020
Thanks Given: 1
Thanks Received: 4


kevinkdog View Post
If you are in a long trade, it would look something like this:

if marketposition=1 then begin

sell next bar at XXXX stop;
sell next bar at YYYY limit;
end;


XXXX and YYYY would be prices you calculate based on your scheme. You could use reserved words like "maxpositionprofit" and "openpositionprofit" to help you know when to move stops.

Simple example:

XXXX=3100.00; //set stop at price of 3100

if maxpositionprofit> 1000 then XXXX=3140; //once $1000 per contract hit, stop moves up to 3140


It can get trcky, but that should at least get you started.

Thanks, but I'm using the OrderTicket object (and OCOOrderTicket and OSOOrderTicket objects) to create and place the orders. For example:

EntryOrder.Symbol = txtSymbol.Text;
EntryOrder.type = OrderType.StopLimit;
EntryOrder.Route = "intelligent";
EntryOrder.Quantity = intShares;
EntryOrder.Account = AccountNumber;
EntryOrder.SymbolType = SecurityType.Stock;
EntryOrder.Duration = Duration;
EntryOrder.LimitPrice = dblEntryLimitPrice;
EntryOrder.StopPrice = dblEntryStopPrice;
If(rdoLong.Checked) Then
Begin
EntryOrder.Action = OrderAction.Buy;
End
Else
Begin
EntryOrder.Action = OrderAction.SellShort;
End;

[stuff happens]

OCOOrderTicket1.Siblings.Add(ProfitTargetOrder);
OCOOrderTicket1.Siblings.Add(StopLossOrder);

OSOOrderTicket1.SecondaryTickets.Add(OCOOrderTicket1);
OSOOrderTicket1.PrimaryTicket = EntryOrder;

[other stuff happens]

OCOOrderTicket2.Siblings.Add(ProfitTargetOrder2);
OCOOrderTicket2.Siblings.Add(StopLossOrder2);

OSOOrderTicket1.SecondaryTickets.Add(OCOOrderTicket2)

MyOrder = OSOOrderTicket1.Send();

Reply With Quote
Thanked by:
  #13 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,664 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,359



hamstonil View Post
Thanks, but I'm using the OrderTicket object (and OCOOrderTicket and OSOOrderTicket objects) to create and place the orders. For example:

EntryOrder.Symbol = txtSymbol.Text;
EntryOrder.type = OrderType.StopLimit;
EntryOrder.Route = "intelligent";
EntryOrder.Quantity = intShares;
EntryOrder.Account = AccountNumber;
EntryOrder.SymbolType = SecurityType.Stock;
EntryOrder.Duration = Duration;
EntryOrder.LimitPrice = dblEntryLimitPrice;
EntryOrder.StopPrice = dblEntryStopPrice;
If(rdoLong.Checked) Then
Begin
EntryOrder.Action = OrderAction.Buy;
End
Else
Begin
EntryOrder.Action = OrderAction.SellShort;
End;

[stuff happens]

OCOOrderTicket1.Siblings.Add(ProfitTargetOrder);
OCOOrderTicket1.Siblings.Add(StopLossOrder);

OSOOrderTicket1.SecondaryTickets.Add(OCOOrderTicket1);
OSOOrderTicket1.PrimaryTicket = EntryOrder;

[other stuff happens]

OCOOrderTicket2.Siblings.Add(ProfitTargetOrder2);
OCOOrderTicket2.Siblings.Add(StopLossOrder2);

OSOOrderTicket1.SecondaryTickets.Add(OCOOrderTicket2)

MyOrder = OSOOrderTicket1.Send();


I don't use OOEl, since it is not good for backtesting. Sorry!

Follow me on Twitter Reply With Quote
Thanked by:
  #14 (permalink)
hamstonil
Kansas City, MO, United States
 
Posts: 6 since Jul 2020
Thanks Given: 1
Thanks Received: 4


kevinkdog View Post
I don't use OOEl, since it is not good for backtesting. Sorry!

No worries. Thanks for looking!! I just use it for order entry of complex orders, so backtesting not needed.

Reply With Quote
Thanked by:
  #15 (permalink)
icanseethefuture
boston, ma, usa
 
Posts: 1 since Nov 2019
Thanks Given: 0
Thanks Received: 0

I was looking to accomplish the same thing with no luck. Tradestation seems limited as far as easily and quickly maneuvering in and out of trades, with multiple profits targets and stops. I started looking at other platforms and seems like sierra charts can do this easily with breakeven stop functionality as well as scale in and scale out. So I'm planning on trying it out with my AMP account.

Reply With Quote




Last Updated on July 22, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts