Hi fellow ProRealCode users,
I have been testing and trying stuff for the past month, but cant seem to get the code right for a specific action.
I want to open a position when the indicators cross over. , but I don’t want to open a extra position after that. (when first position is closed with profit) I only want to open again after the indicators crossed over again.
Something like this in normal words;
// Conditions to enter long positions
indicator1 = ExponentialAverage[5](close)
indicator2 = ExponentialAverage[20](close)
c1 = (indicator1 > indicator2[1])
c2 = (indicator1 < indicator2[1])
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF c1 but c2 hasent happend yet, don’t BUY 1 CONTRACT AT MARKET. (<– What I mean is ; after the c1 happened, and a contract is bought , only buy another one , when c2 happened. In the backtest it opens the trade correctly , and closes with a pPROFIT. But the next candle it opens again , because c1 is still valid. I want c2 to happen first , and then if c1 happens open another trade.)
Hopefully someone has an idea how to set this up… Its a guaranteed moneymaking machine… 😉 ;p
Hi AutoTrader,
Basically, what you want to do here is to test a crossover between 2 values, like moving average.
ProRealTime has instructions built in to test these conditions, they are called : CROSSES OVER and CROSSES UNDER
So your c1 and c2 conditions would be:
c1 = indicator1 crosses over indicator2
c2 = indicator1 crosses under indicator2
I believe that would make it, am I right?
Hi Nicolas,
That is correct! Thank you! Made a very simple system that scores 100% on the 5min Dax cash. (backtest) Will live test it next week Monday until Friday.
Thanks for pointing out the crossover!