Click here to Login

                                                   MMScript - Exit at the close of a bar


Obuli Govindaraju
2013-05-04 17:21:11

I am testing a gap fill based trading system. The buy rule was rather easy - buy at the open of next bar when gapdown() function is 1.

I was successful at exiting at the open of the next bar(of the bar that closes the gap).

However I want to exit at the close of the bar that closes the gap (instead of next day open).

How do I do this through MM Script?

2013-05-05 11:19:21


Best Answer

When creating your order using the MM script, simply specify the "-1" as "orderLag" to buy at the close of the signal's bar.
Orders.CloseMarketOrder(-1, 5)

No more messages


No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"


Trading Items
High to low stock pattern for the close price
How far are the close prices from the support line
Market Rule based on the Crossover Between Stock Close prices and...
Set the First Trading Bar Values to Not a Number
Decreasing the Trailing Stop Level every Trading Bar

How-to Lessons
How to display the bar index of a stock on a chart
How to change volume bar colors when the price closes down
How to display two stocks on the same chart
How to plot the number of stock tweets per day
How to add a metric in the trading system simulation report

Related Forum Threads
Money Management script and exit options in the wizard
close above the highest high in the last 5 days
close next bar with intraday bars
How do you retrieve the entry and exit price for a position?
How do I refer to the close price of another symbol in a formula?

Blog Posts
The Ultimate Guide to Create Trading Systems in QuantShare
Working with the formula editor
Create Realtime Quote Sheets with the Watchlist Tool
How to Select the Best Market Indicator for your Trading System
Detect chart patterns using the auto support/resistance indicator

Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2020
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.