Support Board
Date/Time: Thu, 06 Feb 2025 05:05:13 +0000
[Programming Help] - Buy Exit SL inconsistent behavior (SPREEDSHEET TRADING)
View Count: 820
[2020-04-06 15:15:28] |
User355030 - Posts: 163 |
I noticed (especially when backtesting in replay mode) my SL that is triggered by simple logic "J8>0" "J8<0" is inconsistent... All I am trying to do is have a SL placed at a certain area once I am in a position. Any better ways to engineer it? |
[2020-04-06 16:04:37] |
Sawtooth - Posts: 4169 |
J8>0 in L3 or J8<0 in N3, by themselves, would trigger an immediate exit. Also, when referencing static values outside of Formula Columns, you need to use an absolute reference: $J$8>0 $J$8<0 But this would likely not correct your problem. The easiest way to place a SL is to use Attached Orders instead of L3/N3. If you want to place the SL at a certain price, use Attached Orders, then move it using the Trade Management by Study study, referencing a spreadsheet subgraph/column: Attached Orders: Study Controlled Targets and Stops |
[2020-04-06 16:20:22] |
User355030 - Posts: 163 |
Hey Tom, Thanks for the reply. Let me add a little more substance to my current configuration. J72 & J74 are set to SL at a price lower then position entry. L3 & N3 are set to "J8>0" & "J8<0" This logic says to place the stop loss once the entry is filled. For the most part it works... but I do see times like explained above where the stop loss fails to be placed correctly. I haven't looked at the "Trade management by study" yet, maybe that will be more reliable. |
[2020-04-06 16:59:42] |
Sawtooth - Posts: 4169 |
SL in J72/J74 places a Stop Limit order at the price in J23/J25. You might want to use S instead of SL in J72/J74.
|
[2020-04-06 17:09:07] |
User355030 - Posts: 163 |
Tom, "SL in J72/J74 places a Stop Limit order at the price in J23/J25." - Correct, I have my formulas in those cells for my SL. I'm curious what would be the difference with me using "S" instead of "SL" ? |
[2020-04-06 17:27:01] |
Sawtooth - Posts: 4169 |
I'm curious what would be the difference with me using "S" instead of "SL" ?
Order Types: Stop-LimitJust don't confuse a Stop Loss (SL) with a Stop Limit (SL). |
[2020-04-07 01:30:43] |
User355030 - Posts: 163 |
I used the trade management study and it works great, thanks.
|
[2020-04-10 13:35:06] |
User355030 - Posts: 163 |
@tomgilb For some reason the "Trade management by study" isn't working correctly. Below is the detailed message log. It is saying "The 'Controlling Subgraph Reference' value is 0 at the last bar" , but the value it's referencing is not "0" Replay 30X: ESM20_FUT_CME[M] 10 Sec #1 | Performing a full recalculation because it has been tagged. Chartbook: Order Flow Algo.Cht | 2020-04-10 09:31:37.102 Chart: Replay 30X: ESM20_FUT_CME[M] 10 Sec #1 | Study: Trade Management by Study | Position does not exist. | 2020-04-10 09:31:37.170 Replay 30X: MESM20_FUT_CME[M] 10 Sec #3 | Performing a full recalculation because it has been tagged. Chartbook: Order Flow Algo.Cht | 2020-04-10 09:31:37.200 Replay 30X: GCM20_FUT_COMEX[M] 10 Sec #4 | Performing a full recalculation because it has been tagged. Chartbook: Order Flow Algo.Cht | 2020-04-10 09:31:37.277 Replay 30X: MGCM20_FUT_COMEX[M] 10 Sec #5 | Performing a full recalculation because it has been tagged. Chartbook: Order Flow Algo.Cht | 2020-04-10 09:31:37.357 Chart: Replay 30X: ESM20_FUT_CME[M] 10 Sec #1 | Study: Trade Management by Study | The 'Controlling Subgraph Reference' value is 0 at the last bar. | 2020-04-10 09:31:39.125 |
[2020-04-10 13:59:05] |
Sawtooth - Posts: 4169 |
If the log says it was zero, it was zero at the moment it looked at it. You'll need to modify the formula so that the value never flashes to zero. There can be a slight lag in its computation. You might try using an absolute value so that the entire column has the same value. If ln:4 is set to On Bar Close, it will be looking at row 4. It is difficult for me to offer a sure solution because each system is unique. |
[2020-04-10 14:09:50] |
User355030 - Posts: 163 |
Hey Tom, Here is the formula being referenced =IF(K3,D4,IF($J$8<0,0,P4)) |
[2020-04-10 14:33:39] |
User355030 - Posts: 163 |
After trial and error, I notice that it works when I "Single Chart" reply, but if I replay "All charts in chartbook" it does not work.... What's the reason for this?
|
[2020-04-10 14:45:49] |
Sawtooth - Posts: 4169 |
it works when I "Single Chart" reply, but if I replay "All charts in chartbook" it does not work.... What's the reason for this?
Try this: ln:4 Every N Seconds ln:5 1 second Cell P3: =IF(K3,D4,P4) |
[2020-04-10 15:28:41] |
User355030 - Posts: 163 |
I already had "ln:4 Every N Seconds, ln:5 1 second" and I tried "Cell P3: =IF(K3,D4,P4)" and I'm still experiencing the same behavior when running replay with multiple charts
|
[2020-04-10 15:57:34] |
User355030 - Posts: 163 |
@support This seems like a bug ? "After trial and error, I notice that it works when I "Single Chart" reply, but if I replay "All charts in chartbook" it does not work...." |
To post a message in this thread, you need to log in with your Sierra Chart account: