how to code trailing stop loss to EMA

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #195237 quote
    hemalashah2000
    Participant
    New

    Hi, I am new to Pro Real Code, I need help to code trailing stop loss linked to EMA…any help will be much appreciated.

    #195241 quote
    Nicolas
    Keymaster
    Master

    Example with a buy order, set the stoploss on a 20 periods EMA:

    if not longonmarket and buyconditions then 
     buy 1 contract at market 
     newBuysl=average[20,1]
     set stop price newBuysl
    endif 
    
    if longonmarket then
     newBuysl = max(newBuysl, average[20,1])
     set stop price newBuysl
    endif

    (not tested)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

how to code trailing stop loss to EMA


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
3 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/14/2022
Status: Active
Attachments: No files
Logo Logo
Loading...