Is it possible to have code to buy at market immediately as the signal is generated, rather than at market which is on the open of the next candle? any help would be greatly appreciated.
Yes, it is possible, but with multi timeframe coding instructions, not yet activated publicly (still beta).
Firstly, embed all your strategy code into the desired timeframe: (15-minutes one for example)
1
2
timeframe(15minutes)
test=rsi[14]crosses over50
Then, embed in timeframe “default”, the orders management. Default timeframe will be the one where the strategy will be running, so in order to get almost instantaneous code reading, send it on the smaller timeframe possible (aka 1-second TF):
1
2
3
4
timeframe(default)
ifnotonmarketandtestthen
buyatmarket
endif
So in this example, the “test” variable will be sync with the default timeframe, the test condition will be tested each second, but with the RSI value from the 15-minutes TF.
Also, keep in mind that the RSI value will continuously changing during the 15 minutes bar, changing its value depending of new ticks received each new second. It is possible to use the RSI value the “normal” way, with calculation made only at bar Close with “timeframe(15 minutes,updateonclose)”, but it would make no sense here as per your initial request.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue