Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 23:03:10 +0000



[Programming Help] - Automated Trading

View Count: 4189

[2019-02-26 12:04:22]
User575872 - Posts: 59
I think I caused confusion. I wanted to design a spreadsheet system with the following parameters:
Buy entry if low previous day is reached plus 2 ticks
Sell entry if high previous day is reached minus 2 ticks.
Date Time Of Last Edit: 2019-02-26 12:25:01
[2019-02-26 14:07:37]
Sawtooth - Posts: 3976
Not a single order is triggered. I can not find the mistake.
Ticksize is found in J21. You'll need to reference it.

Assuming the Daily OHLC study is at the top of the Studies to Graph list,
and that its 'Reference Days Back' is set to 1,
and you want yesterday's Open to be between yesterday's High and Low, but not equal to either,
and you want to trigger an entry if the current Last price is within 2 ticks of yesterday's High or Low,
and you only want the first occurrence of either trade direction,
and you always want to alternate longs and shorts:

P3:
=IF(AND(E3>=AB3-2*$J$21,AA3<AB3,AA3>AC3), 1, IF(AND(E3<=AC3+2*$J$21,AA3<AB3,AA3>AC3), 0, P4))
K3:
=AND(P4 = 0, P3)
M3:
=AND(P4, P3 = 0)

Note: this is an example of the necessity for specificity.
Date Time Of Last Edit: 2019-03-06 21:51:33
[2019-02-27 14:15:38]
Sawtooth - Posts: 3976
Formula in post 51 has been corrected.
[2019-03-01 17:36:10]
User575872 - Posts: 59
#51 works great. Many Thanks!

Now I have tried to tell the system the following formulas:
Trigger a sell order if the difference between the high and low of the last bar is greater than 0.06 ticks and C3 is less than B3.
Trigger a buy order if the difference between the high and low of the last bar is greater than 0.06 ticks and D3 is less than B3.

=(C3-D3>0.06)=AND (C3<B3)

=(C3-D3>0.06)=AND (C3>B3)

Is triggered almost on every candle and I do not know why.
[2019-03-01 20:59:09]
Sawtooth - Posts: 3976
The formula is properly written as:
=AND(C3-D3>0.06,C3<B3)
and says:
the current bar's range is greater than 0.06 points (not ticks),
and the current bar's high is less than the current bar's open.

If you want to reference ticks instead of points, you must reference the tick size in J21:
=AND(C3-D3>6*$J$21,C3<B3)
[2019-03-06 19:39:57]
User575872 - Posts: 59
1. How can I tell the system that the formulas from #51 are only used when the High and Low from "Reference Days Back 1" are in the range of "Reference Days Back 2"?

2. Why is it that using the formula from # 51 at this point in the chart does not trigger an order? (see attached pictures)
image20190305_184217_001.jpg / V - Attached On 2019-03-06 19:37:26 UTC - Size: 5.44 MB - 306 views
imageInked20190305_184029_001_LI.jpg / V - Attached On 2019-03-06 19:37:52 UTC - Size: 2.9 MB - 333 views
[2019-03-06 19:52:35]
Sawtooth - Posts: 3976
1. Please tell me the ID#s of both instances of the Daily OHLC study.

2. Swap the shorts and longs in the P3 formula:
P3:
=IF(AND(E3>=AB3-2*$J$21,AA3<AB3,AA3>AC3), 1, IF(AND(E3<=AC3+2*$J$21,AA3<AB3,AA3>AC3), 0, P4))
Date Time Of Last Edit: 2019-03-06 21:52:32
[2019-03-06 20:33:02]
User575872 - Posts: 59
Daily OHLC study Ref. Days Back 1 ID:2

Daily OHLC study Ref. Days Back 2 ID:3
[2019-03-06 23:50:00]
Sawtooth - Posts: 3976
When referencing study outputs, you really should use this method:
Working with Spreadsheets: References to Study Subgraph Columns when using the Spreadsheet Study

So the formula in post #56 would look like this:
P3:
=IF(AND(E3>=ID2.SG2@3-2*$J$21,ID2.SG1@3<ID2.SG2@3,ID2.SG1@3>ID2.SG3@3),1,IF(AND(E3<=ID2.SG3@3+2*$J$21,ID2.SG1@3<ID2.SG2@3,ID2.SG1@3>ID2.SG3@3),0,P4))
Reasons for using this format:
- You can insert/delete Formula Columns on the spreadsheet while retaining the correct references.
- You can add/remove/rearrange studies in the Studies to Graph list while retaining the correct references.
- You can increase/decrease the Number of Formula Columns while retaining the correct references.

1. Try this:
- Don't use the P3 formula.
Q3:
=IF(AND(ID2.SG2@3<ID3.SG2@4,ID2.SG3@3>ID3.SG3@4),1,IF(OR(ID2.SG2@3>ID3.SG2@4,ID2.SG3@3<ID3.SG3@4),0,Q4))
R3:
=AND(Q3,E3>=ID2.SG2@3-2*$J$21,ID2.SG1@3<ID2.SG2@3,ID2.SG1@3>ID2.SG3@3)
S3:
=IF(AND(Q3,R3),1,IF(OR(Q3=0,AND(E3<=ID2.SG3@3+2*$J$21,ID2.SG1@3<ID2.SG2@3,ID2.SG1@3>ID2.SG3@3)),0,S4))
T3:
=AND(Q3,E3<=ID2.SG3@3+2*$J$21,ID2.SG1@3<ID2.SG2@3,ID2.SG1@3>ID2.SG3@3)
U3:
=IF(AND(Q3,T3),1,IF(OR(Q3=0,AND(E3>=ID2.SG2@3-2*$J$21,ID2.SG1@3<ID2.SG2@3,ID2.SG1@3>ID2.SG3@3)),0,U4))
K3:
=AND(S3,S4=0)
M3:
=AND(U3,U4=0)

I don't mind helping out with basic questions but the answers to your requests are becoming more complex than a forum post can accommodate.
[2019-03-07 14:39:27]
User90125 - Posts: 715
I don't mind helping out with basic questions but the answers to your requests are becoming more complex than a forum post can accommodate.

Tom, the OP should be paying you for a consultation on this, since this is what you do for a living.

https://www.sawtoothtrade.com/services.html
[2019-03-08 19:55:35]
User575872 - Posts: 59
Sorry, I did not know that this question required such an extensive answer. Irrespective of that, I am very happy for the support
[2019-03-19 18:20:06]
User575872 - Posts: 59
#58 I used the formula for cell p3

Only a understanding ask: Why does the spreadsheet-system trigger day 4-12 but not 4-13 ?
image20190319_185546.jpg / V - Attached On 2019-03-19 18:15:46 UTC - Size: 4.53 MB - 366 views
[2019-03-19 18:21:03]
User575872 - Posts: 59
...it was breakout at high or low
[2019-03-19 20:10:58]
Sawtooth - Posts: 3976
Why does the spreadsheet-system trigger day 4-12 but not 4-13 ?
The P3 formula in post #58 doesn't give another long unless the Last price crosses the LOD.

From post #51:
and you always want to alternate longs and shorts

[2019-04-08 15:41:44]
User575872 - Posts: 59
Sorry, I still have a question of understanding: What exactly is to be understood by "LOD" in the context of your answer in post 63?
[2019-04-08 16:32:53]
Sawtooth - Posts: 3976
LOD = low of day

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

Login

Login Page - Create Account