placing stop loss

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #106196 quote
    Bob Harris
    Participant
    Average

    Hi,

     

    I’m sure this is a simple question but I’m struggling to make it work. I’m trying to place a stop loss on the exponential moving average 20, either above the price if going short or below the price if going long. anyone able to point me in the right direction?

    Many thanks

    #106198 quote
    Vonasi
    Moderator
    Master

    Either calculate the difference between close and the average and use SET STOP pLOSS or send a pending order at every bar to sell at the average price.

    if longonmarket then
    sl = close - average[20]
    set stop ploss sl
    
    if shortonmarket then
    sl = average[20] - close
    set stop ploss sl
    
    

    or

    if (your long conditions) then
    buy 1 contract at market
    sell at average[20] stop
    endif
    
    if longonmarket then 
    sell at average[20] stop
    endif
    
    if (your short conditions) then
    sellshort 1 contract at market
    exitshort at average[20] stop
    endif
    
    if shortonmarket then 
    exitshort at average[20] stop
    endif
    #106218 quote
    Bob Harris
    Participant
    Average

    Hi

    Thank you so much for your help, it is much appreciated

    Thanks

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

placing stop loss


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bob Harris @bob_harris Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Bob Harris
6 years, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/02/2019
Status: Active
Attachments: No files
Logo Logo
Loading...