First derivative of SMA

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #49154 quote
    GreguigregGreguigreg
    Participant
    Junior

    hey everybody

    i’m new to proorder (not to trading hopefully).

    came here to code a strategy based on SMA first derivative (i.e. Current SMA versus previous SMA). Seems pretty basic to follow the trend but I don’t see anything on the strategies nor screeners … it’s always relative values of SMA between themselves

    did i miss something ? Shall I store the previous value in a WHILE loop ?

    thx for ur help,

    Greg

    #49160 quote
    NicolasNicolas
    Keymaster
    Legend

    To access the value of a variable of the past, it is simply necessary to choose the backward period that one wishes to observe, for example with a moving average SMA 20 periods:

    //moving average 20 periods
    sma20 = average[20]
    
    //value of SMA20, 1 period before  
    myValue = sma20[1]
    
    return sma20, myValue

    .. and please don’t double post 🙂

    #49816 quote
    LeoLeo
    Participant
    Veteran

    In case you need the secon derivate I use this:

    P=20
    mySMA=average[P](close)
    SecondDerivate= mySMA-2*mySMA[1]+mySMA[2]
    Nicolas and JesusCuenca thanked this post
Viewing 3 posts - 1 through 3 (of 3 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

First derivative of SMA


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Greguigreg @greguigreg Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by LeoLeo
8 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/12/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...