How Scripts Work: Difference between revisions
From MultiCharts
→How Orders Are Sent Depending on the Last Bar Status
(2 intermediate revisions by the same user not shown) | |||
Line 189: | Line 189: | ||
The net result of executing the above orders, from a Short position, will be a Flat position. | The net result of executing the above orders, from a Short position, will be a Flat position. | ||
<br> | <br> | ||
=== How Orders Are Sent Depending on the Last Bar Status === | |||
Three collections of orders are filled on each calculation: This Bar Close, Next Bar Market, Next Bar Price.<br> | |||
If the last bar status of the base data series is closed (2 or -1) — This Bar Close orders are sent.<br> | |||
If the last bar status of the base data series is opened (0 or 1) — Next Bar Market, Next Bar Price orders are sent.<br> | |||
After the batch of orders is sent, it is cleared and will be filled only at the next calculation.<br> | |||
<div style="background-color: #E5F6FF;">Tip: It is possible to view bar statuses (bar status from the chart, not from the script is meant) with the help of an indicator that updates on every tick..</div> | |||
'''Examples'''<br> | |||
''Situation 1''<br> | |||
''2 and 2, where the number stands for the bar status from the script.''<br> | |||
Only This Bar Close orders are sent if there are no new bars on the chart by this moment.<br> | |||
If there is the new bar on the chart by this moment, Next Bar Market, Next Bar Price orders will be sent next.<br> | |||
''Situation 2''</br> | |||
''2 and 1''<br> | |||
Only This Bar Close orders are sent if there are no new bars on the chart by this moment.<br> | |||
If there is the new bar on the chart by this moment, Next Bar Market, Next Bar Price orders will be sent next.<br> | |||
''1 and 2''<br> | |||
Nothing is sent until the bar of the base data series is closed.<br> | |||
''Situation 3''<br> | |||
''1 and 2''<br> | |||
Nothing is sent.<br> | |||
''2 and 1''<br> | |||
Only This Bar Close orders are sent if there are no new bars on the chart by this moment.<br> | |||
If there is the new bar on the chart by this moment, Next Bar Market, Next Bar Price orders will be sent next.<br> | |||
''Situation 4''<br> | |||
''1 and 2''<br> | |||
Nothing is sent.<br> | |||
''2 and -1''<br> | |||
Only This Bar Close orders are sent if there are no new bars on the chart by this moment.<br> | |||
If there is the new bar on the chart by this moment, Next Bar Market, Next Bar Price orders will be sent next.<br> | |||
[[Category:PowerLanguage]] | [[Category:PowerLanguage]] |