简体   繁体   中英

Reversing a position on the same candle in pinescript?

Strategy.entry will reverse your position after the close of one candle, but doesn't seem to handle it if both conditions are fulfilled on the same candle. Lets say that you have two stop orders either side of your close price, if one stop has triggered, I want the position to reverse if the price flies off the other way and hits the other stop on the same candle - anyone any ideas? thanks. Ive been toying with trying to use oca's and strategy.exits() but can't find a combo that will do it

Andrew, stop opens a market order. The v5 user manual talks about the broker emulator. History and real time are different. For historical bars, you can set 'use_bar_magnifier' to help the emulator find a lower time frame bar to execute the market order coming from the stop. Otherwise the next candle open will be the target. Using a limit order is handled differently however. Realtime bar execution depends on how you set up your parameters. If calc_on_tick then the actual price within a real time candle will be used. Some folks like the real time to behave the way history does and turn that off, and also set process_orders_on_close=true. There is good material from pinecoders on how the broker emulator works supplementing the user manual.

https://www.pinecoders.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM