~~Title: Limit Entry Loop~~ {{tag>guides}} ==== Example for LIMIT Entry Loop with Market Fallback ==== It is always recommended to use testnet/sandbox first! #~~codedoc:clean: update balance & cache current price (for slippage check)~~ update #~~codedoc:clean: only use cached balance from here on to have quantity % resolve consistently~~ cachedbalance jumpdelay=0 :limitLoop #~~codedoc:clean: place post-only limit order using leftover quantity from last canceled order in this alert or the specified quantity as fallback (used for first run!)~~ #~~codedoc:clean: accept a maximum of 0.5% price slippage against us (compared to cached price from start of alert), otherwise jump to "badPrice"...~~ #~~codedoc:clean: retry for a maximum time of 5 minutes (since start of alert), if not fully filled till then but we have a pos jump to "main", otherwise jump to "tooLong"...~~ [side]=YOUR_QUANTITY% lev=YOUR_LEVERAGE post leftover price=[-]0.25 maxslip=0.5% ifslip=badPrice id=entry maxtime=5m iftimepos=main iftime=tooLong delay=10s cancel id=entry save ifnone=posCheck #~~codedoc:clean: if all filled we are done => go to "posCheck", otherwise save leftover quantity for next run~~ do=limitLoop #~~codedoc:clean: price went too much against us, check if we have partial position and continue with "main", otherwise exit!~~ :badPrice ifpos=main side=[side] exit #~~codedoc:clean: limitLoop took to long to get an entry, open leftover quantity (or all, if no partial fill occured before) with market order~~ :tooLong [side]=YOUR_QUANTITY% lev=YOUR_LEVERAGE market leftover #~~codedoc:clean: Note: replace the line above with "exit" if you do NOT want to fallback on a market order!~~ #~~codedoc:clean: for safety give market order a few sec till its fully there~~ delay=2s goto=main :posCheck #~~codedoc:clean: in case the post-only order was just canceled (=no position yet), try again.. ~~ ifnopos=limitLoop side=[side] :main #~~codedoc:clean:## place SL and TP here ###~~ ''Quantity, leverage, stoploss and takeprofit have to be adjusted to your strategy / personal needs!'' === Attention === Always double check that you are using the right syntax/alert!