This ProBuilder code snippet demonstrates how to track the number of bars from the time a trading order is placed until it becomes profitable. The code uses basic trading strategy elements like RSI indicators for entry signals, and profit and loss thresholds. It also includes a mechanism to count the number of bars that have elapsed since the order turned profitable.
defparam cumulateorders=false //strategy example
if not onmarket and rsi[14] crosses over 50 then
buy at market
start = barindex
set target %profit 5
set stop %loss 2.5
endif
//how many bars were in profit
if onmarket then
//floating profit
floatingprofit = (((close-positionprice)*pointvalue)*countofposition)/pipsize
if floatingprofit>0 and lastorder
Explanation of the Code:
This snippet is useful for traders who want to analyze the efficiency of their entry strategy by measuring how quickly their trades become profitable.
Check out this related content for more information:
https://www.prorealcode.com/topic/connaitre-le-nombre-de-chandelier-sous-0e/#post-139861
Visit Link