Login Page - Create Account

Support Board


Date/Time: Sat, 04 May 2024 04:11:40 +0000



[Programming Help] - How can I delay a new Entry after a filled Exit?

View Count: 837

[2020-08-05 12:01:23]
PeaceFrog - Posts: 102
Hello,

Thank you for taking the time to answer my question.

I’m using the study ”Spreadsheet System for Trading” for a Short Strategy and cannot figure out how to delay the next Sell Entry after a Limit Buy Order has been executed.

For example:
If at 1:00:00 Cell M3: Sell Entry returns a “1” for a Limit Sell Order and is filled and Cell N3: Sell Exit also returns a “1” for a Limit Buy Order.
Then at 1:30:00 the Limit Buy Order is filled.
From here, what I want to do, and cannot figure out, is how to make it so another M3: Sell Entry cannot occur from the time of the fill, 1:30:00, to 1:40:00.

Also, where do I input my preference for Time In Force instructions, DAY, GTC, etc...


Thank you for helping me with this. Your time and effort are very much appreciated.
[2020-08-05 15:16:17]
Hammerhead - Posts: 14
Hi,

I'm not an SC engineer, but they get a little overwhelmed with questions from time to time and I decided I would try to help out.

What I would do, and maybe this will work, I would put a formula in cell J28 (Disable auto-trading), where the value is 'true' from the time the Exit order is filled to the later time.

How I would go about doing that is use the SCDateTimes contained in cell J41 (Last Bar End DateTime) and J43 (Last Exit Trade DateTime).

So, the formula you would put in cell J28 would read something like this, but I don't know exactly if it would work for what you're trying to accomplish:

=AND(FRACTIME(J41)>=FRACTIME(J43),FRACTIME(J41)<(FRACTIME(J43)+(1/144)))

Where 'FRACTIME' gets the TimeValue of the cell, and according to this link https://www.sierrachart.com/index.php?page=doc/SpreadsheetFunctions.html#SerialDateTimeValues, the '1/144' would equal 10 mins.

One thing to be aware of though is that it seems that if the Entry column and cell J28 become 'true' simultaneously then the Entry order will still be submitted. I believe that would only occur in your case though, if your Limit Buy Order fill returns a '1' for cell M3.


As for the TIF:

"All new orders use the settings of the Trade Window for the chart.

Go to the chart that contains the Spreadsheet System for Trading study. Select Trade >> Attach Trade Window to Chart to see what the settings are set to.

For example, if the Time in Force is set to Day, then all new orders submitted from the Spreadsheet will automatically have a Time in Force of Day.

The settings that you can set in the Trade Window also include Attached Orders. For complete instructions for Attached Orders, refer to the Attached Orders page." -- https://www.sierrachart.com/index.php?page=doc/SpreadsheetSystemsAlertsAndAutomatedTrading.php#top

Regards,
[2020-08-06 12:35:56]
Sawtooth - Posts: 3993
Here's another way:

To wait 10 min after a Sell exit fill for a subsequent Sell entry signal, include something like this in M3:
=AND(YourSellConditions,FRACTIME($J$41)-FRACTIME($J$43)>=10/1440)
Date Time Of Last Edit: 2020-08-06 12:41:30
[2020-08-10 09:09:37]
PeaceFrog - Posts: 102
Hi Hammerhead and tomgilb,

Thank you both for taking the time to respond to my question. Hammerhead, your willingness to help out a fellow investor is admirable, inspirational and very much appreciated.

I tried to use the formulas you each suggested and found there was an issue with the FRACTIMES because, either J43 or J41 would be negative for very short period of time, like less than a minute, and cause the formula to not work.

Your suggestions definitely pointed me to cells J41 and J43 and I found that the formula:
=($J$43+(10/1440))>$A$3
seems to do the trick, $A$3 being the current candle's time and date. Do you see any potential issue with using this formula to achieve my goal?

Again, thank you both for your time and effort. I appreciate it very much.
[2020-08-10 19:25:26]
Hammerhead - Posts: 14
I suppose the effectiveness of your formula would depend on which cell it is entered into, but I don't really see an issue with it.
[2020-08-12 17:33:28]
PeaceFrog - Posts: 102
Hi Hammerhead,

Yes, I suppose knowing which cell I entered it in would help. It's in J28 "Disable Auto Trading (read/write):".

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

Login

Login Page - Create Account