Support Board
Date/Time: Sun, 12 Jan 2025 22:00:01 +0000
[Programming Help] - Indicator problem
View Count: 800
[2017-02-28 13:03:35] |
User976133 - Posts: 38 |
I am trying to get an alert based on some indicators. I have used the study overlay to get the MACD from 2 higher time frames. They are show using slope to indicate uptrend or downtrend. The do exactly what is expected, and match another program I am using. The problem comes in when I try to write the alert. I am trying to set an alert when both lines are in upslope (green) or both are in downslope (red). The formula I use is AND(ID3.SG1>ID3[DG1[-1],ID4.SG1>ID4[DG1[-1]) for the uptrend. Downtrend is the same but changes the less than into more than. This does not get results that match the overlays. Is there a way to do this where the formula gets the same result in both instances? |
[2017-03-01 00:26:38] |
Sawtooth - Posts: 4149 |
First, there are syntax errors in your formula. Second, since overlaid studies from higher timeframes result in segments of equal value, you'll need to also reference the [-2] bar: =AND( OR(ID3.SG1>ID3.SG1[-1],AND(ID3.SG1[-2]>=ID3.SG1[-1],ID3.SG1>ID3.SG1[-1])), OR(ID4.SG1>ID4.SG1[-1],AND(ID4.SG1[-2]>=ID4.SG1[-1],ID4.SG1>ID4.SG1[-1])) ) Reverse all comparison operators for downtrend alerts. The above is a variation of the concept explained here: http://www.sawtoothtrade.com/example-6.html |
[2017-03-08 21:34:30] |
User976133 - Posts: 38 |
I have been playing with this and still have a question. To test it, I did one time frame at a time, and drew in arrows when the condition is greater than (green). It draws the arrow at the beginning of the time frame. Since I want to add this to a crossover event, it does not seem to work as I wanted. If the crossover corresponds with one of the arrows, it delivers as expected. But, the crossover rarely happens at the beginning of the higher time period. Is there a way to trigger the alert if the crossover occurs at the beginning, middle or anywhere in that time period? |
[2017-03-09 04:58:18] |
Sawtooth - Posts: 4149 |
Overlays from higher timeframes will occasionally either align late, or align early then not. There are only two settings that control this, but no combination of either will always give the desired result: -Data Copy Mode: Earliest or Latest -Bar Time Matching Method : Nearest or Containing You'll need to choose one combination and accept its limitations, or use a separate instance of the overlay study for each combination and discern which of the alerts is valid, the latter being cumbersome and neither being foolproof. |
To post a message in this thread, you need to log in with your Sierra Chart account: