Login Page - Create Account

Support Board


Date/Time: Mon, 23 Dec 2024 01:05:53 +0000



Trailing Stop Attached Order

View Count: 1053

[2015-08-28 05:12:46]
CustomIndicators - Posts: 126
I'm trying to get a bot to set a trailing stop connected to an order, but I'm not having the result I wanted. My bot had gotten into a trade, but didn't seem to set the trailing stop like I thought it would. Am I doing something wrong? How can I get an attached trailing stop to work? I couldn't find anything that would give me a better result. Here is a sample of my code that gets in, but not out.


s_SCPositionData PositionData;
int Result = sc.GetTradePosition(PositionData);
int PositionStatus = PositionData.PositionQuantity;

int chartNumber = 3;

if (PositionStatus <= 0 && sc.GetStudyPersistentIntFromChart(chartNumber - 1, 1, 1) == 1 && sc.GetStudyPersistentIntFromChart(chartNumber, 1, 1)) {
    // Go Long

    int Amount = (PositionStatus * -1) + 1;

    s_SCNewOrder GoLong;
    GoLong.OrderQuantity = Amount;
    GoLong.OrderType = SCT_MARKET;
    
    int Result = sc.BuyEntry(GoLong);

    if (Result > 0) {
      
      s_SCNewOrder TrailingStop;
      TrailingStop.OrderQuantity = PositionStatus;
      TrailingStop.OrderType = SCT_ORDERTYPE_TRAILING_STOP;
      TrailingStop.Price1 = sc.BaseData[SC_LAST][sc.Index] - TrailingStopTicks.GetInt()*sc.TickSize;
      
      sc.SellExit(TrailingStop);
    }

  }

[2015-08-28 18:20:53]
CustomIndicators - Posts: 126
Is there a way to turn this into an attached order easily?
[2015-08-28 19:08:37]
Sierra Chart Engineering - Posts: 104368
Refer to this section here for help for this:
https://www.sierrachart.com/index.php?page=doc/doc_ACSILTrading.html#DebuggingTradingSystems

You cannot later attach a Target or Stop order to another order. That must be done all at the same time.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2015-08-28 19:09:26
[2015-08-28 23:29:10]
CustomIndicators - Posts: 126
That link shows me how to put the errors into the message log. Can you give me an example of how I can add in an attached trailing stop to my market order?
[2015-08-29 00:17:01]
Sierra Chart Engineering - Posts: 104368
As we said in our previous post, this cannot be done at a later time.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2015-08-29 02:47:27]
CustomIndicators - Posts: 126
I don't want it done at a later time. I want it done asap. How do I use attached orders? Or are attached orders in ACSIL impossible?
[2015-08-29 03:37:23]
Sierra Chart Engineering - Posts: 104368
Refer to the ACSIL Trading page and the structure members for s_SCNewOrder.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account