Closing and Opening Order


Category:
0
0

Good Morning! This is great!

After watching your “Autotrade almost” video I decided to put together something and noticed it works – but once its triggered it executes not on the opening of the next bar. Instead it executes sometime on the current bar or the next bar almost at random – maybe at the original limit price?

It’s very simple, basically I have an EMA – HLC3 – 1 period crossing above (or below) an EMA- OHLC4 – 20 period. When this happens and a bar closes its direction it will execute an order (whether close or open).

so if 1 period EMA cross above 20 period EMA and the close of the current bar is an up close, the next bar will execute a market order at its opening price.

 

here is what i have

<code>  plot _Data_ = MovAvgExponential(“price” = hlc3, “length” = 1).”AvgExp” is less than MovAvgExponential(“price” = ohlc4, “length” = 20).”AvgExp” and close is less than open;   </code>

 

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on August 18, 2017 8:09 am
138 views
0
Private answer

I see a couple potential issues here. The first one to examine is the chart settings. If you are using intraday time frames for the conditional order the charts are most likely not set correctly. The default settings provided by Thinkorswim don’t match Watchlists, Scans, Study Alerts or Conditional Orders. Read through the following post and make sure you chart settings are correct: https://www.hahn-tech.com/ans/hourly-adx-watchlist-not-matching-hourly-chart/

The other issue is rather obvious. In your specifications you describe your entry signal as a cross of two moving averages. However the code you generated using the condition wizard does not check for a cross. It merely checks if one moving average is less than the other. I have included a screenshot showing how to build the condition for a cross of these two EMA’s. Also note that I have adjusted the Offset to +1 on both sides. This requires that the cross of the two EMA’s will have occurred on the previous bar. And this ensure the execution will only occur after the signal has been locked in and confirmed at the close of the bar.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 18, 2017 8:37 am