Login Page - Create Account

Support Board


Date/Time: Sat, 27 Apr 2024 12:38:37 +0000



[Programming Help] - Automated Trading

View Count: 4191

[2019-01-22 14:44:31]
User575872 - Posts: 59
Thank you very much, I have a very good basis for experimenting. But the structure is not so clear to me that I can help myself completely.

Some things work very well, others do not. For example, the command for Cell J89 "Cancel order at 11:00:00" does not work for me at all.

Also different entries (post # 17) are not executed. I enlarged the list to seven times. The following happens: Time entries 1 and 2 are executed, 3 and 4 are not, 5, 6 and 7 are executed again. Here too, canceling the non-executed orders does not work (via: Cell J27: = OR (AND (J4> 0, FRACTIME (J41) - Y3> = H4 / 1440), AND (J4 <0, FRACTIME (J41) - Z3 > = H4 / 1440)).
   
Another timed entry question: Is there a formula for regular entry, for example every ten minutes?

For my question from post # 18 ("Second question: Is it possible to trigger an order via volume?") I found the following formula: = AVERAGE (SG1 [0: -10)]> 100
But I do not know how to assign this formula to the volume.
[2019-01-23 05:29:36]
Sawtooth - Posts: 3976
the command for Cell J89 "Cancel order at 11:00:00" does not work for me at all.
You must enable this with a =1 in J88.

The following happens: Time entries 1 and 2 are executed, 3 and 4 are not, 5, 6 and 7 are executed again
Some possible causes:
- You have 'Allow Multiple Entries In Same Direction' or 'Allow Entry With Working Orders' set to No.
- J41 is not updated within the time window in your formula.
- K4 or M4 are 1 and there is no transition from 0. (You could set 'Reset Condition On New Bar' to Yes)

canceling the non-executed orders does not work
You must use J78 instead of J27 for this.

Is there a formula for regular entry, for example every ten minutes?
The formulas you are using should work. But here is another way if your signal chart is time based with a shorter evenly divisible time than 10 minutes:
Add a 10 min chart, and overlay the Main Price Graph on your signal chart using the Study/Price Overlay study, with the 'Fill Blanks With Last Value' set to No. Then include this in your entry formula:
=ID1.SG1@3>0
where ID1 is the Study/Price Overlay study; edit as needed.

Is it possible to trigger an order via volume?") I found the following formula: = AVERAGE (SG1 [0: -10)]> 100
That formula is using the Simple Alert syntax. The syntax for spreadsheets would be:
=AVERAGE(F3:F13)>100
[2019-02-11 17:01:00]
User575872 - Posts: 59
Most of the automatic trading is going very well. But there are still some questions …

1. How do I tell the spreadsheet system that I want yesterday's "Daily High & Lows", rather than today's?

2. For example, if I want to place an order every day at 9:00 am, it will not run every day even though the order validity is one day, which will not fail because of too many open orders or similar errors.

3. In "Replay Mode" I currently have the problem that it looks like the backtest is running well, but in the "trade activity log", for example, it only shows the trades for a week, even though the test was over two months… ("single Chart, Accurate Trading System..., use start date-time checked, Speed 100.000, skip empty periods checked").
[2019-02-11 17:22:01]
Sawtooth - Posts: 3976
1. How do I tell the spreadsheet system that I want yesterday's "Daily High & Lows", rather than today's?
You can add the Daily OHLC study, with 'Reference Days Back' set to 1, and reference its outputs with your formulas.

2. For example, if I want to place an order every day at 9:00 am, it will not run every day even though the order validity is one day, which will not fail because of too many open orders or similar errors.
I don't understand this. Please explain.

3. In "Replay Mode" I currently have the problem that it looks like the backtest is running well, but in the "trade activity log", for example, it only shows the trades for a week, even though the test was over two months…
- Go to Trade >> General Trade Settings and verify the 'Number of Days to Save in Trade Activity Log' is sufficient.
- In the Trade Activity Log, verify that the Date Range 'From' date is early enough.
[2019-02-11 18:21:36]
User575872 - Posts: 59
1. "... and reference its outputs with your formulas…"

Okay, how do I do that exactly? About J17 and J18 and K3 and M3?


2. Example: Every morning at 9 o'clock the system should trigger a buy and a sell entry. It works maybe ten times (days), then five times not, then three times well. The offsets for the entries are so small that it can not be that the order is not filled (3 Ticks).


3. Yes, I changed that. It also had something to do with "maximum position allowed" in spreadsheet settings.
[2019-02-11 20:43:27]
Sawtooth - Posts: 3976
1. "... and reference its outputs with your formulas…" Okay, how do I do that exactly?
A study's outputs appear on the spreadsheet beginning in columns AA to BR, depending on the Number Of Formula Columns setting.
You can reference them using the column/row but the preferred way is to use this method:
Working with Spreadsheets: References to Study Subgraph Columns when using the Spreadsheet Study

2. Example: Every morning at 9 o'clock the system should trigger a buy and a sell entry. It works maybe ten times (days), then five times not, then three times well. The offsets for the entries are so small that it can not be that the order is not filled (3 Ticks).
At a replay speed of 100, the orders might not even get placed. Locate a specific day when there is no entry, and replay thru it at a slower speed.
[2019-02-12 17:00:20]
User575872 - Posts: 59
Hi, for "1" in post #30 I need some time …
so first this question… How can I tell the trading system that, for example, starting at 8 am, the highs and lows of the first 15-minute bar should ALWAYS be used for the entry buy or entry sell?
[2019-02-12 17:53:19]
Sawtooth - Posts: 3976
How can I tell the trading system that, for example, starting at 8 am, the highs and lows of the first 15-minute bar should ALWAYS be used for the entry buy or entry sell?
Create persistent variables of the High and Low of the 8am 15min bar, using a Formula Column for each, with formulas like this:
e.g. cell S3 for the High:
=IF(AND(FRACTIME(A4)<TIMEVALUE("08:00:00"),FRACTIME(A3)>=TIMEVALUE("08:00:00")),C3,S4)
e.g. cell T3 for the Low:
=IF(AND(FRACTIME(A4)<TIMEVALUE("08:00:00"),FRACTIME(A3)>=TIMEVALUE("08:00:00")),D3,T4)

Then include a reference to these values in your entry conditions.

There are other examples of persistent variable formulas here:
Spreadsheet Example Formulas and Usage
[2019-02-14 18:36:25]
User575872 - Posts: 59
from post #32:

"Then include a reference to these values in your entry conditions."


Sorry, I don´t know what I have to do exactly
[2019-02-14 19:29:05]
Sawtooth - Posts: 3976
With the formulas in post #32, the High and Low of the 8am 15min bar will be retained all day, so reference them instead of any other highs or lows.
[2019-02-14 19:49:08]
User575872 - Posts: 59
….I think its not sufficient, if I write "=S3" in K3 and "=T3" in M3 ….
I have a basic understanding-problem with the term "reference"
[2019-02-14 20:19:27]
Sawtooth - Posts: 3976
the highs and lows of the first 15-minute bar should ALWAYS be used for the entry buy or entry sell?
What are your entry conditions/rules regarding the High and Low of the first 15-minute bar?
I can only assume that you'd compare current price to these values.
[2019-02-14 20:43:58]
User575872 - Posts: 59
Yes, but it is also important from where the course comes. Buy entry should only be triggered if the price was below the 15-min high, sell entry if the price was above the low.
[2019-02-14 23:00:58]
Sawtooth - Posts: 3976
Buy entry should only be triggered if the price was below the 15-min high, sell entry if the price was above the low.
Then include something like this in your entry formulas:
K3:
E3<S3
M3:
E3>T3
[2019-02-18 17:54:40]
User575872 - Posts: 59
# 30: I have now entered the formulas =AC3<=(E3+2) in K3 and =AB3<=(E3-2) in M3 and it works so far … (to trigger limitorders on the high and the low of the previous day).

I would like to add conditions:
- the order should only be triggered if the opening is in the range high / low of the previous day
- that only on the first arrival of the condition (once low, once high) is triggered.

I noticed that the function "Flatten positions & cancel orders in time" (J88, J89) gets from (my) system prio 1. So stops or limits are disregarded when I activate this feature. Can I change that?
[2019-02-18 23:37:58]
Sawtooth - Posts: 3976
I would like to add conditions:
- the order should only be triggered if the opening is in the range high / low of the previous day
Add conditions to the formulas:
K3:
=AND(AC3<=E3+2,opening<rangehigh,opening>rangelow)
M3:
=AND(=AB3<=E3-2,opening<rangehigh,opening>rangelow)

- that only on the first arrival of the condition (once low, once high) is triggered.
Put the entry formulas in a Formula Column where you can create a persistent variable of the entry, then in K3/M3 find the transitions. Here is an example:
Spreadsheet Example Formulas and Usage: Buy on First Signal and Ignore Multiple Signals

I noticed that the function "Flatten positions & cancel orders in time" (J88, J89) gets from (my) system prio 1.
Don't use J85 to J89. Instead, do this:
-Use a formula like this in J28:
=AND(J8 = 0, OR(FRACTIME(J41) < TIMEVALUE("09:30:00"), FRACTIME(J41) > TIMEVALUE("16:00:00")))
This will allow exits/flattening after autotrading entries are disabled.
-Then use a formula like this in J29:
=FRACTIME(J41) > TIMEVALUE("16:14:00")
The time in J29 should be later than the end time in J28.
[2019-02-19 11:06:01]
User575872 - Posts: 59
#40
okay, I put =AND(AC3<=E3+2,AA3<AB3,AA3>AC3) in K3 and =AND(AB3<=E3-2,AA3<AB3,AA3>AC3) in M3

and =IF(=AND(AC3<=E3+2,AA3<AB3,AA3>AC3, 1, IF(=AND(AB3<=E3-2,AA3<AB3,AA3>AC3, 0, P4)) in P3

because of this info in the support board
Cell P3: =IF(BuyConditions, 1, IF(SellConditions, 0, P4))
In the above formula BuyConditions would be replaced with a desired Buy formula, and the SellConditions would be replaced with a desired Sell formula.

But there comes a ERROR SYNTAX

Also when I use the other info from the support board:

Cell K3: =AND(P4 = 0, P3)
Cell M3: =AND(P4, P3 = 0)

I don´t know where and how I have to place these formulas. I added them to the buy/sell formulas in K3 and M3 and used them alone ... both wrong
[2019-02-19 12:35:44]
jenda3 - Posts: 21
I would like to go back to that:

1. How do I tell the spreadsheet system that I want yesterday's "Daily High & Lows" rather than today's?
You can add the Daily OHLC study, with 'Reference Days Back' set to 1, and reference its outputs with your formulas.

I need something like this. I added Daily OHLC study, it works as I need but when i run back test with thist study it's very very very slow. For example, without this study, back test to 30 days, takes about 10 minutes and with Daily OHLC study, takes about 3 hours. And I need a back test for one year.

I tried to use the Daily High Cell J17 and Daily Low Cell J18. But they are running value and do not reset at the beginning of the day

So can I calculate Daily High and Daily Low for the previous day somehow differently?

Thanks
[2019-02-19 14:36:35]
Sawtooth - Posts: 3976
I don´t know where and how I have to place these formulas.
Remove the = before AND.

P3:
=IF(AND(AC3<=E3+2,AA3<AB3,AA3>AC3), 1, IF(AND(AB3<=E3-2,AA3<AB3,AA3>AC3), 0, P4))
K3:
=AND(P4 = 0, P3)
M3:
=AND(P4, P3 = 0)
Date Time Of Last Edit: 2019-02-19 14:47:31
[2019-02-19 15:35:15]
Sawtooth - Posts: 3976
I added Daily OHLC study, it works as I need but when i run back test with this study it's very very very slow.
There is nothing inefficient about the Daily OHLC study. It must be something else. Here's a possibility:
Chart Studies: Study Calculation Precedence And Related Issues

So can I calculate Daily High and Daily Low for the previous day somehow differently?
You could use the High/Low for Time Period - Extended study.
This wouldn't fix an unrelated inefficiency problem.

You could calculate it on the spreadsheet:
O3:
=IF(INT(A3)>INT(A4),C3,MAX(C3,O4))
current day's midnight-to-midnight high
P3:
=IF(INT(A3)>INT(A4),O4,P4)
previous day's midnight-to-midnight high
Q3:
=IF(INT(A3)>INT(A4),D3,MIN(D3,Q4))
current day's midnight-to-midnight low
R3:
=IF(INT(A3)>INT(A4),Q4,R4)
previous day's midnight-to-midnight low
[2019-02-19 17:59:08]
User575872 - Posts: 59
#43
I removed the = before AND.

P3:
=IF(AND(AC3<=E3+2,AA3<AB3,AA3>AC3), 1, IF(AND(AB3<=E3-2,AA3<AB3,AA3>AC3), 0, P4))

...and I did this:

K3:
=AND(P4 = 0, P3)
M3:
=AND(P4, P3 = 0)

..but no order is triggered (I disabled J28/J29 for this attempt) ... I think I have to do a little more…..
[2019-02-24 19:05:34]
User575872 - Posts: 59
#43: I have activated the studies Spreadsheet for trading and Daily OHLC (reference days back 1) and used the following formulas:

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

Not a single order is triggered. I can not find the mistake.
[2019-02-24 19:17:24]
Sawtooth - Posts: 3976
What studies are AA, AB and AC?
Date Time Of Last Edit: 2019-02-24 19:18:08
[2019-02-24 19:34:37]
User575872 - Posts: 59
I think these are the references of the OHLC study. Maybe I misunderstood your post #43
[2019-02-24 21:37:22]
Sawtooth - Posts: 3976
I think these are the references of the OHLC study
Post 43 is merely using your example references.
You need to be sure what these are actually referencing.
[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

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

Login

Login Page - Create Account