Buy or Sell at a certain distance from moving average

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #211982 quote
    Wolf
    Participant
    New

    Hi,

    Proreal does not have by default an indicator to calculate distance in % from price to a moving average, as this one…How Can I Measure the Distance Between Price and a Moving Average? | MailBag | StockCharts.com

    Can we please have it, and also can you please show me the code for a strategy where I can automate to buy or sell when price is at a certain % from 200 moving average?

    Thanks

    Wolf

    #211980 quote
    Wolf
    Participant
    New

    Hi,

    Proreal does not have this indicator, How Can I Measure the Distance Between Price and a Moving Average? | MailBag | StockCharts.com

     

    Can we please have it, and also can you please show me the code for a strategy where I can automate to buy or sell when price is at a certain % from 200 moving average

     

    Thanks

     

    Ivan

    #211991 quote
    JS
    Participant
    Senior

    Hi @Wolf,

    Hereby a simple trading system based on %difference between Close and MA200…

    DefParam CumulateOrders = False
    
    Once PercLong = 2 //If difference >= PercLong then go LONG
    Once PercShort = -2 //If difference <= PercShort then go SHORT
    
    MA200 = Average[200](Close) // 200 units Moving Average
    PercDiff = (Close - MA200) / MA200 * 100 // % Difference between Close and MA200
    
    If PercDiff >= PercLong then // If % Diffence >= PercLong then go LONG
    Buy 1 Contract at Market
    EndIf
    
    If PercDiff <= PercShort then // If % Diffence <= PercShort then go SHORT
    SellShort 1 contract at Market
    EndIf
    
    //Graph PercDiff
    #212054 quote
    Nicolas
    Keymaster
    Master

    You can find the PPO (Percent Price Oscillator) here: https://www.prorealcode.com/prorealtime-indicators/percentage-price-oscillator-ppo/

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

Buy or Sell at a certain distance from moving average


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Wolf @bud Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by Nicolas
2 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/23/2023
Status: Active
Attachments: No files
Logo Logo
Loading...