Click here to Login





                                                   Buy at a specific intra-bar price

  0

0
Kiran
2016-12-06 18:54:56


I'm running a daily simulation and want to simulate buying at the mid-point of Open and Close, so i tried the following code, but it doesn't generate any trades.
Pl advise how to fix this script? If StopLimit doesn't work with specific price, is there some other way to trigger orders at this price point in Quantscript?

Buy = <condition>;
SetSimTiming(_Buy,_StopLimit,0);
midP = (ref(open,-1)+ref(close,-1))/2;
BuyPrice(midP,1);

I realize that placing an order at mid-point of Open & Close is peeking ahead, but i just want to compare approximate performance of placing orders middle-of-day vs at Close.

thanks
Kiran




QuantShare
2016-12-07 03:50:34

  0

In QS language, you cannot always simulate an order at that price because if you send a limit order with that price then if the asset opens below the mid point (open+close/2), the order will be executed at the open price.

The only way to simulate this is by using the money management script. You could just replace the order in the "OnNewPosition" event with "Orders.SimulatedOrder" function.



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
Price at a specific Intraday Time
S&P 500 Earnings and Price Earnings Ratio Estimations
Price Pattern Drawing Tool
Scale-In On Price Drop
Multiple Time Frames Trading System - Price / Moving Average Cros...

How-to Lessons
How to detect whether price movements are predictable or not
How to change volume bar colors when the price closes down
How to set order type of a trading system programmatically
How to perform a basic quantitative analysis using the S&P 500
How to download earnings calendar data for various stocks

Related Forum Threads
Buy a specific instrument via QS vector language
Set the buy or sell price
How do I refer to the close price of another symbol in a formula?
Regarding Ploting Buy Sell Signals
Indicator for price

Blog Posts
Buy the best/top rated stocks or how to create powerful rank base...
Quantitative Analysis: Price Channels
How to get buy and sell orders for a portfolio based on a trading...
How to create buy and sell trading rules based on News Data
Trading System: Moving average crossover and few others buy and s...









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.