Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 16:08:01 +0000



[Programming Help] - Colour Based on Alert Condition

View Count: 644

[2022-04-09 06:26:09]
eatsleeptrade555 - Posts: 12
Hi,

Context: Short arrow alert when price reaches xx bar + bearish bar, buy arrow alert when price reaches xx bar + bullish bar

Top band: ID2.SG1
Middle band: ID2.SG3
bottom band: ID2.SG2

Context: Short arrow when price is same or lower than Top band
Is this correct?
OR(AND(ID2.SG1>=O[-1]>C[-1]))

Question
How do I only show 1 entry rather than multiple?
How do I program it for reversal trade? (I only want the signal if it comes from either a)bottom band or b) middle band)
imageScreenshot 2022-04-09 132249.jpg / V - Attached On 2022-04-09 06:23:03 UTC - Size: 74.43 KB - 114 views
Attachment Deleted.
[2022-04-09 14:21:12]
Sawtooth - Posts: 3992
Short arrow when price is same or lower than Top band
How do I only show 1 entry rather than multiple?
Try this:
CROSSFROMBELOW(H,ID2.SG1)

How do I program it for reversal trade? (I only want the signal if it comes from either a)bottom band or b) middle band)
Try this:
1. Add the Spreadsheet Formula study
- Move it above your Color Bar study in the Studies to Graph list.
- Set 'Draw Zero Values' to No
- Check 'Hide Study'
- Use a formula like this in its Formula field:
=IF(OR(CROSSFROMBELOW(L,ID2.SG2),CROSSFROMABOVE(L,ID2.SG3)),1,IF(CROSSFROMBELOW(H,ID2.SG1),0,ID4.SG1[-1]))
-where ID4 is the Spreadsheet Formula study.
This creates a persistent True when the Low crosses either the bottom or middle bands, then releases it when the High crosses the upper band.
2. Use a formula like this on the Alerts tab of your Color Bar study:
=AND(CROSSFROMBELOW(H,ID2.SG1),ID4.SG1[-1]=1)
-where ID4 is the Spreadsheet Formula study.
[2022-04-16 06:07:53]
eatsleeptrade555 - Posts: 12
Thanks Tomgilb! It is getting clearer for me.

Do you have any suggestions on which studies I should use for backtesting strategies?
(I want to see if xx amount of this trades taken over xx trades = how many losers/winners)
[2022-04-16 13:42:14]
Sawtooth - Posts: 3992
Do you have any suggestions on which studies I should use for backtesting strategies?
- If you are referring to which studies to use for signals in an autotrader, use what ever gives the signals you require. There are myriad possibilities.
To get an idea of what you are up against, see this:
[AUTOMATE] What are you thought about automate trading ?
- If you are referring to which backtesting mode to use, see this:
Auto Trade System Back Testing
- If you are referring to which study to use to create an autotrader, I prefer the Spreadsheet System for Trading study.
Spreadsheet Systems, Alerts and Automated Trading

I want to see if xx amount of this trades taken over xx trades = how many losers/winners
The Trade Activity Log will give you this info.
Date Time Of Last Edit: 2022-04-17 13:02:38
[2022-04-17 08:36:56]
eatsleeptrade555 - Posts: 12
Thanks Tomgilb.

I would like to create a strategy and backtest it.

So I assume I would need to do the following

1) Create the strategy in Spreadsheet System for Trading
2) Go into Bar Based Back Testing


Context
Top band: ID2.SG1
Middle band: ID2.SG3
bottom band: ID2.SG2

Context
Price forms a bearish bar at the top band and I will like to short it. (reversal strategy)
So if price comes from bottom or middle and reaches "top band" and close with a bearish bar = short

I tried this
=IF(OR(CROSSFROMBELOW(L,ID2.SG1),CROSSFROMABOVE(H,ID2.SG3)),1,IF(CROSSFROMABOVE(L,ID2.SG1),CROSSFROMABOVE(H,ID2.SG1)),0)

And got ARGS
[2022-04-17 13:37:34]
Sawtooth - Posts: 3992
The formulas I gave in post#2 use Alert syntax. You must use spreadsheet syntax on a spreadsheet, e.g. in cell P3:
=IF(OR(CROSSFROMBELOW(D3:D4,ID2.SG2@3:ID2.SG2@4),CROSSFROMABOVE(D3:D4,ID2.SG3@3:ID2.SG3@4)),1,IF(CROSSFROMBELOW(C3:C4,ID2.SG1@3:ID2.SG1@4),0,P4))

Then in M3:
=AND(CROSSFROMBELOW(C3:C4,ID2.SG1@3:ID2.SG1@4),P4=1)
https://www.sierrachart.com/index.php?page=doc/SpreadsheetFunctions.html#CROSSFROMBELOW_Function
Working with Spreadsheets: References to Study Subgraph Columns when using the Spreadsheet Study

For longs, use O3 and K3, respectively.
K3 to N3 are only for entry/exit signals. Other Formula Columns can be used for intermediate calculations.

Regarding which backtest mode: I gave the wrong link. Read the entire section of the documentation on backtesting.
The Bar Based Backtest might not be what you want to use. It is fast but not the most accurate.
Auto Trade System Back Testing

What you want to do is simple to explain but not as simple to program.
You will likely need to modify the formulas, and there will likely be situations where it will be difficult to get the signal you want.
The examples are only meant for you to know the concept how it might be done.

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

Login

Login Page - Create Account