admin管理员组文章数量:1199521
I wrote a strategy with multiple entries (pyramiding). They should be triggered at different moments. I'm on a 1-minute timeframe.
When the conditions for the first entry is met, I will receive the same alert multiple times.
Multiple entries at the same time
Here is the part of my code that triggers the first entry; Barlastentry
is updated after each entry and should prevent 2 entries during the same bar (however, the first entry should happen only once):
// Execute first entry
if not na (currentPosName) and not firstEntryTriggered and Barlastentry != bar_index
// splitCapital := capital / numEntries
EntryID = "Long_1"
strategy.entry(EntryID, strategy.long, qty=splitCapital/close, comment= currentPosName+' 1/'+str.tostring(numEntries))
firstEntryTriggered := true
currentEntryCount := 1
previousEntryPrice := close
Bar1stentry := bar_index
Barlastentry := Bar1stentry
Question is: how can I prevent multiple entries at the same time ?
To prevent that, I added some code to avoid multiple entries durin the same Bar. There is no effect.
Of course, if I turn calc_on_every_tick
to false
, it's working, but I need to leave it to calc_on_every_tick = true
.
Thank tou for your help :)
Full code://@version=6
// © JayBen777
// Last updated: 2025-01-18
strategy("Test TV alerts", overlay=true, initial_capital=1000, commission_type = strategymission.percent, commission_value = 0.07, pyramiding = 3, calc_on_every_tick = true, trim_orders = true)
float margeerreur = 0.5/100 // on réduit le capital de 5% pour éviter qu'un ordre ne passe pas sur 3commas
capital = strategy.initial_capital * (1 - margeerreur)
string Str_Icon = na
// STRATEGIES
GorillaEnabled = input.bool(true, 'Gorilla', group = 'Strategies')
//--- VARIABLES
var bool firstEntryTriggered = false
var bool ttpEnabled = false
var float highestPriceSinceTTP = na
var string currentPosName = na
// MULTIPLE ENTRIES
int numEntries = na // should be same as strategy Pyramiding
float dropNextEntries = na // next entries
float splitCapital = na
// PnL
float TTP1Activation = na // % profit to activate TTP
float TTP1Deviation = na // % trail once TTP is active
// EXIT RULES
bool Step5Enabled = false
bool InPosition = not (strategy.opentrades == 0)
// Entries ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var float TTP1Price = na
var float trailingStop = na
var int Bar1stentry = na
var Barlastentry = bar_index
var int currentEntryCount = 0
var float nextTrigger = na
var float previousEntryPrice = 0.
//--- 1) First entry
// Gorilla
本文标签:
pine scriptTradingview Unwanted multiple entries at the same timeStack Overflow
版权声明:本文标题:pine script - Tradingview: Unwanted multiple entries at the same time - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1738579635a2101082.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论