How do you define a Custom Indicator?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #85534 quote
    Bard
    Participant
    Master

    Hi, I had an indicator I was using in a strategy, the Belkhayate Centre of Gravity found here:
    https://www.prorealcode.com/topic/center-of-gravity/#post-19219
    and it says “the variable needs to be defined” when I use the name of the indicator in the code.

    1) But how do you define it? I mean it’s in my list of indicators and so I thought it would “turn green” when added in the code like when you use an indicator like “average,” but apparently not… and so I’m not sure how to include it other than “calling” it and using some c1’s and c2’s etc.

    2) It doesn’t like lines 19 and 20 from the code pasted here below (with and without ” ” ).

    3) What I’m trying to do is define the best way (hence Idea #1 and #2) to determine the “slope” of the CoG so I can trade in that direction (albeit entering on some extreme std deviations on price).

    Paper trading this CoG line has been profitable, (even though it repaints because of the Detrended Price Oscillator), making a decision on the last bar available as to what is going to happen on the next bar and in conjunction with using the Mesa Trendline and Kalman Filter and Ehler’s CoG, seems effective. See CoG screenshot.

    4) It would also be nice to know what’s the best way not to trade when the market’s flat? Maybe using the MBFX Timing Indicator mid region or the ADX) but I also read the following on a forum post about “slopes” where Nicolas said: “It has already been discussed, it’s a common request since it should give an information about the trend slope. But the inclination (slope) of a moving average is nothing more than its percentage gain or loss since X periods. But you can get an error rate of the linear regression on a moving average like this:

    return R2[20](average[20])

    If the correlation is high, the moving average tends to be more similar to a straight trend line. Otherwise, I know there is this kind of indicator for mt4 (see attached screenshot), I think I could help to translate it. Lot of people are looking for a moving average angle indicator .. I don’t know how it’s calculated and its relevancy but we could give it a try?” (pls see screenshot).

    The thing is you can still have a shallow angled but relatively straight trend line so it’s not that easy to gain any great insight.

    Cheers for any thoughts in how to get this strategy coded.

    MyBelkhayateShort = "Belkhayate Centre of Gravity"[p1]
    MyBelkhayateLong = Belkhayate Centre of Gravity[p2]
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter positions
    indicator1, ignored, ignored, ignored, ignored, ignored, ignored = CALL "Belkhayate Centre of Gravity"
    indicator2, ignored, ignored, ignored, ignored, ignored, ignored = CALL "Belkhayate Centre of Gravity"
    
    c1 = (indicator1 > indicator2[10]) //If CoG > CoG[10]
    c2 = (indicator1 < indicator2[10]) //If CoG < CoG[10]
    
    ignored, ignored, ignored, ignored, ignored, ignored, CoG = CALL "Belkhayate Centre of Gravity"
    c3 = (close CROSSES OVER CoG)  //-2.2std
    c4 = (close CROSSES UNDER CoG) //+2.2std
    
    //IDEA #1
    p1 = 30
    p2 = 65
    
    MyBelkhayateShort = "Belkhayate Centre of Gravity"[p1]
    MyBelkhayateLong = Belkhayate Centre of Gravity[p2]
    
    Slope1 = (ABS(MyBelkhayateShort - MyBelkhayateShort[1]) / MyBelkhayateShort[1]) * 100
    Slope2 = (ABS(MyBelkhayateLong - MyBelkhayateLong[1]) / MyBelkhayateLong[1]) * 100
    
    //IDEA #2
    ShortLR = MyBelkhayateShort  //ShortLR = Lin Reg
    slope1 = ShortLR - ShortLR[10]
    
    LongLR = MyBelkhayateLong 
    slope2 = LongLR - LongLR[10] //LongLR = Lin Reg
    
    IF slope1 > 0 and slope2 > 0 and c3 then
    BUY 10 PERPOINT AT MARKET
    ENDIF
    
    IF slope1 < 0 and slope2 < 0 and c4 then
    SELL 10 PERPOINT AT MARKET
    ENDIF
    
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

How do you define a Custom Indicator?


ProOrder support

New Reply
Author
author-avatar
Bard @brad Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProOrder support
Language: English
Started: 11/23/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...