Click here to Login





                                                   Money Management to read future values (e.g. next day open)

  0

0
Andrew Thomas
2022-04-23 18:51:04


My question involves using the advanced money management system to access future price data for a stock. I'm currently using AMM to set the number of shares to buy/sell using the close price of the previous day. However if there is a big jump/drop on the open of the next day (trading day) it leads to big errors. I would like to use the open of the actual trading day to set the number of shares to buy/sell.

Here is a section of existing code (in the OnEndPeriod section)

for(int i=0;i<sorders.Length;i++)
{
TimeSeries open = Data.GetPriceSeries(sorders[i].Symbol, "open");
double newopen = open[0] ; // I think -1 gives the open of the next day - the day the trade will happen

int size = (int)Math.Floor(samount / newopen); // determines shares to buy/sell using the amount of funds per stock (samount) divided by the price of the stock

sorders[i].NbShares = size;
sorders[i].SubmitChanges();
}

I know that [0] is current day and [1] is previous day, and usually [-1] is next day, but it does not seem to work here. Is using an index of [-1] not allowed for a timeseries and if so is there another way to access a future open price in the AMM system to set orders for the day?

Thanks! This seems like a simple question - but I couldn't find the information online.

Best - Andy



QuantShare
2022-05-18 19:30:45

  0

Try to replace the "double newopen" line by this:
double newopen = Data.ParseFormula("a=open(-1);").GetTimeSeries(sorders[i].Symbol, "a")[0];



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
Withdraw a Fixed Amount Every Month - Money Management
Correlation Filter Money Management Strategy
Investing in stocks using the Kelly criterion money management st...
Return per Bar Stop - Money Management Strategy
Averaging Down Money Management Strategy

How-to Lessons
How to calculate the average of a time series using the money man...
How to debug a trading system using the money management tool
How to plot the number of stock tweets per day
How to add future bars to plan for market scenarios
How to display the number of stocks per day for different RSI gro...

Related Forum Threads
Advanced Money Management
Money management script help - Targeted net profit per day
Money Management - Scale-In
Money Management Scripting
Place a profit stop through Money management strategy

Blog Posts
Create a trading strategy using the money management tool - Part ...
Basic trading system implemented using the money management tool
Several money management strategies in a trading system
Create a trading strategy using the money management tool - Part ...
Money Management: Scale-in Trading Strategy









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.