'Complete trade first and get new signal
I've been trying for the build backtest strategy. My signal based flip flop. How can i complete this trade and ignoring any new signals?
var longPosMem = false
var shortPosMem = false
longPosMem := long ? true : short ? false : longPosMem [1]
shortPosMem := short ? true : long ? false : shortPosMem [1]
// Defines Trade Signals
buy = long and longFiltersApproval and longAdx and not (longPosMem [1])
sell = short and shortFiltersApproval and shortAdx and not (shortPosMem [1])
EntryExit = strategy.position_size == 0
if buy and EntryExit
strategy.entry('Long Entry', strategy.long)
strategy.exit('Exit Long', 'Long Entry', stop=Long_StopLoss, limit=Long_TakeProfit)
if sell and EntryExit
strategy.entry('Short Entry', strategy.short)
strategy.exit('Exit Short', 'Short Entry', stop=Short_StopLoss, limit=Short_TakeProfit)
My bakctest strategy looks like this: My bakctest looks
Sorry for my bad english. Thank's
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
