% distance from Moving average condition

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #236988 quote
    Tbone6060
    Participant
    New

    Hey there guys –  wondering if anyone could help with code condition for only taking a trade if price is a certain % above moving average?

    so price must be within 5% of 200 ema? any help appreciated thanks

    #236999 quote
    robertogozzi
    Moderator
    Master

    There you go:

    // price must be within 5% of 200 ema
    
    Ema200 = average[200,1](close)
    Above  = Ema200 * 1.05          //5% above
    Below  = Ema200 * 0.95          //5% below
    Cond   = (close <= Above) AND (close >= Below)
    RETURN Cond AS "Within 5%"
    Iván González thanked this post
    #237011 quote
    Tbone6060
    Participant
    New

    Thank you!

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

% distance from Moving average condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Tbone6060 @tbone6060 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Tbone6060
1 year, 5 months ago.

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