Specify close of candle in conditions?


0
0

Thank you for this very informative website.

I’m experimenting with placing conditional orders based on MACD crosses intraday. It seems straightforward to do this with the Condition Wizard using the following condition for a bull cross:

MACD().”Value” crosses above MACD().”Avg”

and the following for a bear cross:

MACD().”Value” crosses below MACD().”Avg”

So, I tried sequencing a buy order based on a bull cross with a sell order based on a bear cross, using the 3m time frame. I ran a few trials that turned out the same way. The buy orders seemed to trigger when I wanted them to: at the close of the 3m candle that resulted in a bull MACD cross. But the sell orders seemed to trigger quite prematurely. Looking back at the chart, no bear cross took place around the time that the sell triggered. I’m guessing this was because there was a bear cross intracandle, but by the candle close there wasn’t one. That’s my best guess, because I can’t think of any other reason why the sell order would have triggered.

Is it possible to specify in Condition Wizard that those signals should wait for the close of the candle? I definitely don’t want them to trigger intracandle.

Marked as spam
Posted by (Questions: 4, Answers: 4)
Asked on February 17, 2020 6:37 pm
192 views
0
Private answer

There are two potential issues involved here. One is a chart setting. So let's make sure you check that your charts are set correctly. The checkbox to include extended hours must be set to match your charts. If you are not using extended hours then you must make sure the setting named "Start aggregation at market open" is unchecked. The screenshot below shows where to find this setting.

Now on to your code. There is no setting to force a Conditional Order or Study Alert to wait for the bar to close. You must address this directly in your code and you do this through the Condition Wizard. The value is called "Offset".

Setting the Offset value to 1 will make the following changes to your code:

MACD().”Value” crosses above MACD().”Avg” from 1 bars ago

This will force the code to examine the previous bar for the signal instead of the current bar. Which means that only once the signal bar closes (and the next bar opens) will the signal be considered. Which means the signal will only trigger once the crossover bar has closed and locked in the signal.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on February 18, 2020 9:11 am
0
Thanks, Pete! I wasn't able to find answers anywhere else. I had figured out the extended hours bit. I should have mentioned that. I had also tried the offset, but apparently I adjusted it in the wrong direction. So, just one detail I'm not clear on: Shouldn't the offset be applied to both the value and the average? MACD().”Value” from 1 bars ago crosses above MACD().”Avg” from 1 bars ago
( at February 19, 2020 7:40 am)