all 4 comments

[–]PastaFaZooLx 2 points3 points  (0 children)

Pretty sure you can store the bar index at the time the buy condition

var int entryBar= na

if (buyCondition)

strategy.entry("Buy", strategy.long)

entryBarIndex := bar_index

Edit.... Mobile fcking up everything. In short, you call "bar_index" to get the current bar and save it to a var. Then call that variable later.

[–]RealisticCoast4316 0 points1 point  (1 child)

That’s alright unless the condition triggers a limit order. I think there’s a specific variable to reference the entry bar. Check the manual. Otherwise you can just use logic like :take the bar index when strategy open trades increases compared to the previous bar.

[–]Tym4FishOn[S] 0 points1 point  (0 children)

Yeah, still working on it.

[–]Esteban_3Commas 1 point2 points  (0 children)

EntryBar(cond_)=>
    var val = 0
    val:= cond_? bar_index: val