how to code trailing stop loss to EMA

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #195237 quote
    hemalashah2000hemalashah2000
    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
    NicolasNicolas
    Keymaster
    Legend

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 NicolasNicolas
4 years, 4 months ago.

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