0
var float loLows = na
is_new_position = (strategy.position_size[1] != strategy.position_size)    // This will only be true on the bar of the entry
loLows := is_new_position // Only update the value if it is a new position. Keep the old value otherwise
TPL=(strategy.position_avg_price/RR)-(loLows/RR)+strategy.position_avg_price
TPS=(strategy.position_avg_price/RR)-(hiHighs/RR)-strategy.position_avg_price

if inDateRange and (close > (ema200) and close > (ema992) and ta.crossover(ema13,ema62) and ta.crossover(ema21,ema62)) strategy.entry("entry long", strategy.long) strategy.exit("long exit", profit=TPL, stop=loLows)

if inDateRange and(close < (ema200) and close < (ema992) and ta.crossunder(ema13,ema62) and ta.crossunder(ema21,ema62)) strategy.entry("entry short", strategy.short) strategy.exit("short exit", profit=TPS , stop=hiHighs)

jyjy
  • 11
  • Questions that contain just a code dump in the post body (especially when no effort has been made to format that code) do not usually do well. You need to clearly explain the problem with the code you've posted and ask a **specific question** related to that code. You'll find your experiences here will be much better if you spend some time taking the [tour] and reading the [help] pages to learn how the site works before you begin posting. I'd pay special attention to [ask] and [mre]. – Ken White Oct 03 '22 at 00:21
  • sorry it s my first post i will read it ! my problem it s said : Mismatched input 'is_new_position' expecting 'end of line without line continuation' and i don't know how to fix it – jyjy Oct 03 '22 at 15:52
  • You need to [edit] your post and **clearly** describe the problem there, format your code, and then ask a **specific question** related to that code. Do so with an EDIT to your original question, not here in a comment. We cannot help you until you've asked a proper question here, and you have not done that yet. – Ken White Oct 03 '22 at 16:31

0 Answers0