How would I write a short program to buy and sell by specific dates?
For Example:
Buy on 11-01-2014
Sell on 05-01-2014
Size:
Color:
Simlar question got raised just last week:
Buy stock on given date with Trailing stopIt can be made even simpler, the key is in comparing a supplied DateTime with the current bar's DateTime e.g.
CODE:
Please log in to see this code.
Size:
Color:
Thanks for the prompt response. I'll try it.
UpdateEugene,
I tried to simplify your strategy above to buy just 1 stock on 1 date and then sell that stock on a later date. I obviously don't know enough to make it work successfully. I got several compile errors.
I'll try to attach my code below:
CODE:
Please log in to see this code.
Would you please look it over and suggest how I might fix it. Or if it's hopeless, please provide a better simple version.
Thank you.
Size:
Color:
Robert,
Here's a version of the code that
buys just 1 stock on 1 date and then sell that stock on a later date:
CODE:
Please log in to see this code.
Size:
Color: