Risk Management code + ATR stop loss

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

    Guys

    Very new to all this but managed to come up with the below algo.

    Can anyone advise how do i change the below code  so it does the following points

    Risk Management  – Auto calculates £ per point based upon 10% risk to my capital account. e.g £10,000 capital would risk £1000.

    stop loss  = 1* ATR

    take profit = 5* ATR

    so if ATR is 10, the £ per point would  be £100 (stop loss  = 1* 10*£100 = £1000) which is my risk management strategy.

    // Conditions to enter long positions
    
    indicator1 = Average[90](close)
    
    c1 = (close[1] > indicator1[1])
    
    indicator2 = MACDline[12,26,9](close)
    
    indicator3 = ExponentialAverage[9](indicator2)
    
    c2 = (indicator2[1] CROSSES OVER indicator3[1])
    
     
    
    IF c1 AND c2 THEN
    
    BUY 100 PERPOINT AT MARKET
    
    ENDIF
    
     
    
    // Conditions to exit long positions
    
    indicator4 = MACDline[12,26,9](close)
    
    indicator5 = ExponentialAverage[9](indicator4)
    
    c3 = (indicator4[1] CROSSES UNDER indicator5[1])
    
     
    
    IF c3 THEN
    
    SELL AT MARKET
    
    ENDIF
    
     
    
    // Conditions to enter short positions
    
    indicator6 = Average[90](close)
    
    c4 = (close[1] < indicator6[1])
    
    indicator7 = MACDline[12,26,9](close)
    
    indicator8 = ExponentialAverage[9](indicator7)
    
    c5 = (indicator7[1] CROSSES UNDER indicator8[1])
    
     
    
    IF c4 AND c5 THEN
    
    SELLSHORT 100 PERPOINT AT MARKET
    
    ENDIF
    
     
    
    // Conditions to exit short positions
    
    indicator9 = MACDline[12,26,9](close)
    
    indicator10 = ExponentialAverage[9](indicator9)
    
    c6 = (indicator9[1] CROSSES OVER indicator10[1])
    
     
    
    IF c6 THEN
    
    EXITSHORT AT MARKET
    
    ENDIF
    
     
    
    // Stops and targets
    
    SET STOP pLOSS 50
    
    SET TARGET pPROFIT 200
    #80826 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    To write code, please use the <> “insert PRT code” button, to make code easier to understand. Thank you.

    #80993 quote
    razalgorazalgo
    Participant
    New
    / Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    indicator1 = Average[90](close)
    c1 = (close[1] > indicator1[1])
    indicator2 = MACDline[12,26,9](close)
    indicator3 = ExponentialAverage[9](indicator2)
    c2 = (indicator2[1] CROSSES OVER indicator3[1])
    
    IF c1 AND c2 THEN
    BUY 100 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    indicator4 = MACDline[12,26,9](close)
    indicator5 = ExponentialAverage[9](indicator4)
    c3 = (indicator4[1] CROSSES UNDER indicator5[1])
    
    IF c3 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    indicator6 = Average[90](close)
    c4 = (close[1] < indicator6[1])
    indicator7 = MACDline[12,26,9](close)
    indicator8 = ExponentialAverage[9](indicator7)
    c5 = (indicator7[1] CROSSES UNDER indicator8[1])
    
    IF c4 AND c5 THEN
    SELLSHORT 100 PERPOINT AT MARKET
    ENDIF
    
    // Conditions to exit short positions
    indicator9 = MACDline[12,26,9](close)
    indicator10 = ExponentialAverage[9](indicator9)
    c6 = (indicator9[1] CROSSES OVER indicator10[1])
    
    IF c6 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 50
    SET TARGET pPROFIT 200
    
    #80994 quote
    razalgorazalgo
    Participant
    New

    Hi – I used the <>”insert PRT button”  –  thanks for advising that. much appreciated

    What needs to change so it automatically calculates the £ per point based upon my risk management strategy (10% risk loss of capital per trade) and max loss is 1* ATR and take profit at 5*ATR

Viewing 4 posts - 1 through 4 (of 4 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

Risk Management code + ATR stop loss


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
razalgo @razalgo Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/18/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...