mercredi 25 octobre 2017

Writing a program for Forex in R

I have some data:-

Open High Low Close 2017-09-01 1.29360 1.29951 1.29052 1.29495 2017-09-03 1.29600 1.29660 1.29444 1.29535 2017-09-04 1.29536 1.29643 1.29124 1.29300 2017-09-05 1.29306 1.30440 1.29088 1.30331 2017-09-06 1.30331 1.30820 1.30181 1.30471 2017-09-07 1.30472 1.31381 1.30325 1.31319 2017-09-08 1.31319 1.32239 1.31233 1.31945 2017-09-10 1.31816 1.31978 1.31736 1.31769 2017-09-11 1.31769 1.32223 1.31593 1.31764 2017-09-12 1.31766 1.33145 1.31703 1.33097 2017-09-13 1.33096 1.33286 1.31836 1.32040 2017-09-14 1.32039 1.34055 1.31501 1.33955 2017-09-15 1.33955 1.36159 1.33922 1.35871 2017-09-17 1.35579 1.36029 1.35579 1.35921 2017-09-18 1.35921 1.36181 1.34646 1.35176 2017-09-19 1.35176 1.35515 1.34683 1.35178 2017-09-20 1.35178 1.36573 1.34517 1.34914 2017-09-21 1.34914 1.35861 1.34706 1.35761 2017-09-22 1.35760 1.35955 1.34496 1.34935 2017-09-24 1.34872 1.35339 1.34832 1.35261 2017-09-25 1.35262 1.35706 1.34308 1.34816 2017-09-26 1.34816 1.35139 1.34094 1.34385 2017-09-27 1.34386 1.34389 1.33634 1.33753 2017-09-28 1.33754 1.34551 1.33427 1.34159 2017-09-29 1.34160 1.34258 1.33497 1.33963

What I would like to do is to have a program where I can choose a date I want to enter and assign that to the Open price corresponding to the date chosen.

I would like to set a Stop Loss at the opening price of the date above minus 0.05

I would then like it to look at subsequent dates to the date chosen and in turn, record the maximum price and minimum price attained on that date.

If the minimum price is not below the stop loss I would like to record the maximum price attained on that date.

If the minimum price is below the set stop loss, I would like it to say "Exited on 'yyyy-mm-dd' with maximum price of 'max of previous dates calculated' "

Hope this makes sense!

TIA :)

Aucun commentaire:

Enregistrer un commentaire