Coding uptrends and downtrends

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35948 quote
    smokingfox
    Participant
    Junior

    Hi,

    In prorealtime charts you can set the system to colour code when a Moving Average is in an uptrend and when it is in a downtrend.

    If you want to use this in a automated strategy, e.g. you create an indicator which is the 50day moving average basis closing prices.

    then you want to code the system such that it can identify if the 50MA is an uptrend or a downtrend.

    what i cant find is how you write this in code.

    any ideas please?

    #39045 quote
    Nicolas
    Keymaster
    Master

    If the color is green, trend is up, basically it means that the current value of the indicator is higher than the previous period one. So for a simple moving average, it would mean:

    //define your indicator 
    indi = average[20]
    
    //trend is bullish? (green) result = 1 if true
    result = indi>indi[1]

    and opposite rule for a bearish trend. Hope it helps, sorry for delay answering your question.

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

Coding uptrends and downtrends


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
smokingfox @smokingfox Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/18/2017
Status: Active
Attachments: No files
Logo Logo
Loading...