Hi everyone,
Before the weekend starts, I wanted to ask anyone here how to code (with DEFPARAM Cumulateorders = true) increasing orders every 3 pips.
Right now, I have coded it, and it open new orders every 3 pips, but start at the beginning of the next candle. Since I am working on large TFs (30 min, 1 hour), I would like to know the exact coding trick so I can open new orders in the same candlestick right after 3 pips.
Right now is:
IF LONGONMARKET AND Close-TRADEPRICE(1)> 3*pipsize AND MAXCONTRACTS THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
I understand that “AT MARKET” will open the order at the opening of next candle (regardless is long or short), but I have tried changing it with other formulas and doesn`t work.
I would appreciate any suggestions.
Many thanks and have a great weekend,
Juan
This is the normal behavior because your script is only read one time per bar at Close.
You can try to put pending stop orders at +3 pips like this:
IF LONGONMARKET AND MAXCONTRACTS THEN
BUY 1 CONTRACTS AT TRADEPRICE(1)+3*pipsize STOP
ENDIF
But be aware that 3 pips from the current Close is certainly too close to put a STOP order, it depends of instrument though… Should of course work beautifully in backtests 🙂
Hi Nicolas,
Thanks for your message. I knew it was possible because I read it before in one of your post, but I couldn’t find it.
I am aware that 3 pips is a very short distance, but I wanted to know the coding. I am working with relatively big timeframes (30′, 1h, 4h) and I wanted the accumulation to happen within the same candlestick. In any case, depending the case I will adapt the pips and the number of orders to the right scenario.
Thanks so much Nicolas!
Best,
Juan