Hi,
I wish to use a MA which takes data from the 1H chart, but I want to run it on 1M chart, how do I code it?
I also wonder how to limit a code so it only takes one buy- and one sellshort-position per day?
Thanks in advance!
EricParticipant
Master
“I also wonder how to limit a code so it only takes one buy- and one sellshort-position per day?”
I am also interested in this, using this code for example?
// Definition of code parameters
// Conditions to enter long positions
indicator1 = Average[20](close)
indicator2 = Average[50](close)
c1 = (indicator1 > indicator2)
IF c1 THEN
BUY 1 SHARES AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = Average[20](close)
indicator4 = Average[50](close)
c2 = (indicator3 < indicator4)
IF c2 THEN
SELL AT MARKET
ENDIF
It’s easy, just count how many times your conditions to open a position is met in a variables ‘opensell’ and ‘openbuy’. Add a conditional request on this variables on your conditions to open trades and reset them on each new day.
if intradaybarindex = 0 then
openbuy=0
opensell=0
endif
// Definition of code parameters
// Conditions to enter long positions
indicator1 = Average[20](close)
indicator2 = Average[50](close)
c1 = (indicator1 > indicator2)
IF c1 and openbuy=0 THEN
BUY 1 SHARES AT MARKET
openbuy = openbuy+1
ENDIF
// Conditions to exit long positions
indicator3 = Average[20](close)
indicator4 = Average[50](close)
c2 = (indicator3 < indicator4)
IF c2 THEN
SELL and opensell=0 AT MARKET
opensell = opensell+1
ENDIF
Hello,
the original question was not answered, is it possible to trade in the M30, but use indicator from the H1 or H4?
One way would be for example of course to calculate indicator or oszilator on your own based out of the smaller timeframe, but then once you run out of bars. 🙂
Is there a function or code, like for example MovingAverage(H1, xy, xx,…) or something like this:)
Best regards
Wolfgang