Click here to Login





                                                   Need help with a MM Script

  1

0
Obuli Govindaraju
2013-05-09 06:29:02


Lets say my buy rule is rsi(4) < 20. Exit is N-bar stop with a value of 2.

If the bar that generates the exit signal still meets the buy rule I do not want to exit and move the exit by another 2 bars.

How do I do this? I know that I should use the ClosePosition event but after that I am a bit clueless on what to do.




QuantShare
2013-05-09 11:11:20

  0

Best Answer
In "OnStartSimulation", you instruct QS to execute "OnClosePosition" event when a stop is initiated.
TradingSystemSettings.IsExecuteOnClosePositionOnStop = true;

In the "OnClosePosition" event, evaluate the buy rule then ignore the order if this rule is true:

TimeSeries buyrule = Data.ParseFormula("a = rsi(4) < 20;").GetTimeSeries("SYMBOL NAME", "a");
if(buyrule[0] == 1)
{
Functions.DontCloseTheCurrentPosition();
}




No more messages
0




Reply:

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"










QuantShare

Trading Items
Update the Stock Exchange Associated With U.S. Stocks - Market Fi...
Long strategy created with the money management tool
Design and backtest a trading system with two strategies
Long Term Up Trend with Short term re-entery Signals
Stock Correlation with its Industry - Change over time

How-to Lessons
How to run a screen or a watchlist from a script
How to use QuantShare with Metastock data
How to associate an index with a list of stocks
How to get stocks for a particular index using the global script
How to execute a script at regular intervals

Related Forum Threads
Help With Daily Data Import Script
Speed of script execution for symbols with many bars
Need assistance with C# creating an indicator
Money management script help - Targeted net profit per day
Help with Quantshare Language

Blog Posts
Working with the formula editor
QS Trading Software: Global Script
Create Realtime Quote Sheets with the Watchlist Tool
Display several stock market charts with one click
Ranking stocks based on their correlation with the S&P 500 Index









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
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.