Hi Everyone,
Could anyone help me get me started in creating some code ? I’ve looked at many functions (positionperf, countofposition) and can’t figure this one out.
I’m looking to count previous positions. My thinking is to reject “gamblers fallacy”, i.e. Entries are not statistically independent when an overall system is following a trend.
For example, if last my last 3 closed positions in profit were: Long , Long , Long => Count of 3 => The likelihood of a 4th Long resulting in gains is minimal, and therefore avoid taking a 4th Long (given prior conditions are met).
Thanks in advance,
Regards,
This will only show open positions and not closed.
countoflongshares[1]>0 and countoflongshares[2]>0 and countoflongshares[3]>0
I think you can use a loop over the last n ‘positionperf’, to count if their profit were in the same row, and then modify a variable to tell your strategy to trade or not:
count = 0
for n = 1 to 3 do
if positionperf(n)>0 then
count=count+1
endif
next
if count = 3 then
allowtrade = 0
else
allowtrade = 1
endif