How do i make a condition to enter a trade without it having a specific timeframe?
For example in this code when 5 ma crosses over 20 ma it will buy, buy only if the RSI is below 30 in the same time period.
How do i create a code that recognise that 5 ma has crossed over 20 ma and the first time RSI goes below 30 any time after that, if 5 ma is still over 20 ma it buys.
Can i somehow loop c1 untill c2 has happend?
//Enter Long
indicator1 = Average[20](close)
indicator2 = Average[5](close)
c1 = (indicator2 CROSSES OVER indicator1)
indicator3 = RSI[14](close)
c2 = (indicator3 < 30)
IF c1 AND c2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
There you go:
Once c1 = 0
indicator1 = Average[20](close)
indicator2 = Average[5](close)
If OnMarket or (indicator2 CROSSES UNDER indicator1) then
c1 = 0
Endif
If c1 = 0 then
c1 = (indicator2 CROSSES OVER indicator1)
Endif
indicator3 = RSI[14](close)
c2 = (indicator3 < 30)
IF c1 AND c2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF