Support Board
Date/Time: Sat, 30 Nov 2024 02:32:26 +0000
Need Help With Spreadsheet Automated Trading Using Multiple Profit Targets
View Count: 537
[2022-12-14 17:15:47] |
Derek Benton - Posts: 9 |
Hello, I have searched extensively for the answer that helps resolve my issue. I'll get right to it: I have a Rolling VWAP Strategy that uses Buy/Sell signals at the peak of the top and bottom bands. I want (for example) a buy signal to purchase 2 contacts and sell 1 at VWAP and sell the other at the top/bottom band (depending if long or short). That's it! I can not figure this out. I have tried multiple Trade Management Studies and messed with the J83 cells, but all I can seem to do is either cancel both orders at the same time or cancel only one order leaving it without a profit target. I do not want a fixed price, since the study (VWAP) is always changing. Any Help would be greatly appreciated and please forgive me if this is not posted correctly. Cheers! Date Time Of Last Edit: 2022-12-14 17:25:56
|
[2022-12-14 19:09:15] |
Sawtooth - Posts: 4123 |
I would use two Attached Orders targets, and use the Trade Management by Study study, referencing a spreadsheet subgraph/Formula Column, where the row 3 formula returns the VWAP value when ABS(J8) is 2, and the outer band value when ABS(J8) is 1. I prefer to use an instance for Longs, and another for Shorts, to keep the formula simple. Set the 'Attached Order to Manage' to Nearest. |
[2022-12-15 01:53:12] |
Derek Benton - Posts: 9 |
@tomgilb, Thank you, I hadn't thought to use the spreadsheet with the trade management study. If you could please, I need some more help with writing the formula. Here's what I need: Column O is ID3.SG5 which is selected in my trade management study under Controlling Subgraph Reference In Column O, When J8 is 2, I need one profit target to trigger when D3 (high) Touches AA3 (VWAP), When J8 is 1, I need the other profit target to trigger when D3 touches AB3 (Top Band). Thank You! |
[2022-12-15 04:08:41] |
Sawtooth - Posts: 4123 |
The TMS study moves Attached Order targets or stops, so you'll need to create a Trade Window config that places 2 targets at some initial offsets when your system triggers an entry. The TMS study only sees row 3 of a spreadsheet column, IOW, only the most recent value. So you would only need to us a simple formula like this in cell O3: =IF($J$8=2,AA3,IF($J$8=1,AB3,0)) This formula is for Longs Targets only. Use another instance of the TMS study, and another spreadsheet Formula Column, for Short Targets. When price trades through AA3, the Attached Order target will fill because the TMS study moved it there. Same with AB3. |
[2022-12-15 04:39:14] |
Derek Benton - Posts: 9 |
@tomgilb, Thank You! That’s pretty what I knew it had to be, but knowing where and when to use commas and parentheses, was messing me up. I was also trying to use OR instead of IF
|
[2022-12-15 13:29:20] |
Sawtooth - Posts: 4123 |
Use IF when you want the formula to return a value. Use AND/OR when you want the formula to return T/F. |
[2022-12-17 17:26:50] |
Derek Benton - Posts: 9 |
@tomgilb, Ok, possibly one more formula help needed. How would I write a formula to move my stop loss to break even after the first profit target hits at VWAP? I think I would use another Trade Management Study set to Stops, and write a formula in another cell that triggers the stop to move when $j$8 goes from qty 2 to 1. Just not sure how to make the stop move to break even? Date Time Of Last Edit: 2022-12-17 17:33:07
|
[2022-12-17 18:27:09] |
Sawtooth - Posts: 4123 |
Try this: Use Attached Orders with 2 targets and a common stop, and 4 instances of the TMS study... Long target, cell O3: =IF($J$8=2,AA3,IF($J$8=1,AB3,0)) Short target, cell P3: =IF($J$8=-2,AA3,IF($J$8=-1,AC3,0)) Long stop, cell Q3: =IF($J$8=2,$J$48-$J$21*n,IF($J$8=1,$J$48,0)) Short stop, cell R3: =IF($J$8=-2,$J$48+$J$21*n,IF($J$8=-1,$J$48,0)) -where n is the initial stoploss offset, in ticks. |
[2022-12-18 22:56:20] |
Derek Benton - Posts: 9 |
@tomgilb That worked great! Cant thank you enough, you have have saved me days worth of trial and error trying to figure that out! Now, If I could figure out how to set the targets to execute a few ticks before the actual trigger (VWAP for example)? You know how price will come all the way to it, but not quite breach it? Any ideas?
|
[2022-12-18 23:19:45] |
Sawtooth - Posts: 4123 |
how to set the targets to execute a few ticks before the actual trigger
Try this:Long target, cell O3: =IF($J$8=2,AA3-$J$21*5,IF($J$8=1,AB3,0)) Short target, cell P3: =IF($J$8=-2,AA3+$J$21*5,IF($J$8=-1,AC3,0)) |
[2022-12-19 21:59:04] |
Derek Benton - Posts: 9 |
@tomgilb, Ok, it doesn't seem to work correctly just yet, meaning it still doesn't trigger until a breach of VWAP. I played with =,+,- instead of the asterisk, also played with the number value and can't seem to get any change. Any ideas?
|
[2022-12-19 22:23:45] |
Sawtooth - Posts: 4123 |
AA3-$J$21*5 will return a price 5 ticks less than the VWAP, where the TMS study would have moved the target. So where is the target in a replay? It should not be at the VWAP. |
[2022-12-20 00:03:19] |
Derek Benton - Posts: 9 |
@tomgilb Ok never mind. Now it is working! (idk lol) Sorry about that.
|
To post a message in this thread, you need to log in with your Sierra Chart account: