Hi
I was wondering if i could get some help
i use variable position sizes based on the amount of money i have in my account.
the thing is i have noticed that when i look to sell this amount, it changes, mostly because of the change in price when its calculated.
startingcapital = 100
cp=strategyprofit
contractsize=(startingcapital+cp)/high
if buyingcondition then
buy contractsize on market
end if
if sellingcondition then
sell contractsize on market
endif
This means i always have a little bit of left over in the market and I recently noticed, it affects the efficiency of my systems.
is there anyway i can create an array which remembers the value of the contract size use in a trade.
this is especially helpful when there are cumulative orders on the way.
i wanted to try some loops with trade price then realised that trade price could also consider sells, which is not what i want, i want to arrays to purely pick up the number of contracts of each previous trade.
If the system will always close out the oldest code, then this shouldn’t be an issue to work out.
any help would be greatly appreciated.
novembrepleut – Welcome to the forums. Please re-read the forum rules before posting again. Your topic has been moved to the correct place for strategy related questions.
The following will just close everything that you have open:
startingcapital = 100
cp=strategyprofit
contractsize=(startingcapital+cp)/high
if buyingcondition then
buy contractsize at market
end if
if sellingcondition then
sell at market
endif
If you want to store position sizes in an array then simply do this:
startingcapital = 100
cp=strategyprofit
contractsize=(startingcapital+cp)/high
if buyingcondition then
buy contractsize at market
a = a + 1
$myposition[a] = contractsize
endif
‘a’ will always be the latest position opened and ‘a’ minus 1 the previous and ‘a’ minus 2 the one before that and so on.