EMA with a horizontal and verticle shift

Viewing 13 posts - 16 through 28 (of 28 total)
  • Author
    Posts
  • #193420 quote
    MIKE PAPY
    Participant
    New

    Pouvez-vous me donner un exemple

    Can you give me an example

    #193421 quote
    MIKE PAPY
    Participant
    New

    Pouvez-vous me donner un exemple avec un indicateur simple, décalage à gauche et décalage à droite

    Can you give me an example with a simple indicator, shift left and shift right

    #193430 quote
    robertogozzi
    Moderator
    Master

    @MIKE PAPY

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.

    Again, please abide by the rules highlighted in yellow (below).

    Thank you 🙂

    #193451 quote
    josward1
    Participant
    New

    Is the REturn necessary to make the indicator work accurately? When i put RETURN under the line as the example shows it underlines it indicating an error

    #193452 quote
    josward1
    Participant
    New

    I did it like this

    EMAPer1 = exponentialaverage[EMAPer1]
    RETURN EMAPer1

    #193454 quote
    josward1
    Participant
    New

    I am finding that my code isn’t honoring the MA’s im using as i see them on the chart. I’m also measuring the distances between the MA’s to fine tune entrys and i find trades aren’t taken in situations when the gap is above the distance i have set but takes trades whenthe lines are squashed together. I i’m starting to think i have something missing with regard to the MA coding

    #193455 quote
    JS
    Participant
    Senior

    It’s easier to help when you post the code…

    #193461 quote
    josward1
    Participant
    New
    The full code is too big to post plus it’s not mine to do so, it’s one that i’m working on as a trader. but this is the section i have for the MA’s. The top two lines determine the MA’s which are set in variable optimisation to 3 and 5. the next line down determines the conditions which have to be met to take a long. So i want EMA 3 (EMAPer1) to be over the EMA5[1horizontal shift] (EMAPer2)  by the Pointsize difference or more. This value is currently set to 5 which is shown on the 4th line down. I have this further up the page.
    ema30HS = exponentialaverage[EMAPer1](close)
    ema31HS = exponentialaverage[EMAPer2](close[1])
    
    EMAbuyc = ema30HS-ema31HS>ema30HSema31HSDistance*pointsize
     
    Once ema30HSema31HSDistance = 5
    #193722 quote
    josward1
    Participant
    New
    Do you only recieve help on here if you hand over your work?
    #193730 quote
    GraHal
    Participant
    Master
    trades aren’t taken in situations when the gap is above the distance i have set
    Are you taking into account that code is read at the close / end of a bar and (any resultant) trades are opened / closed at the open / start of the next bar? Is it possible that you are viewing / assessing MA gap on the 1st bar that shows as trade opened? Whereas the MA gap that met strategy conditions occured in the bar before the 1st bar that shows as trade opened? Hope above makes sense?
    #193767 quote
    josward1
    Participant
    New
    Yes this makes sense, I have accounted for this and look for when trends are extended and MA’s are spread out for many candles and see that entrys aren’t taken or taken at the end of a move like this when the MA’s are closing back up or in situations where MA’s are squashed together with smaller gaps trades are taken
    #193796 quote
    GraHal
    Participant
    Master
    Insert below at the bottom of your code and check if Long trades are opened when below is True / = 1 as shown on your chart in a separate section of it’s own (often ends up at the bottom these days! 🙁 ) GRAPH EMAbuyc
    #194035 quote
    robertogozzi
    Moderator
    Master
    This a shifted version of a Moving Average. It can be shifted both horizontally (number of bars to be shifted, + or -) and vertically (% to be shifted, + or -, with decimal digits):
    // Shifted MA
    //
    //ONCE Periods = 200
    //ONCE AvgType = 0
    //ONCE Hshift  = 0
    //ONCE Vshift  = 0.0
    Hshift = min(Hshift,Periods)
    MyMA   = Average[Periods,AvgType](close)
    Result = MyMA + (MyMA * Vshift / 100)
    r      = 0
    g      = 0
    b      = 255
    t      = 0
    IF BarIndex > Periods THEN
       IF Hshift = 0 THEN
          t      = 255
       ELSE
          x1 = BarIndex + (Hshift - 1)
          y1 = Result[1]
          x2 = BarIndex + Hshift
          y2 = Result
          DrawSegment(x1,y1,x2,y2) coloured(0,128,155,255)
       ENDIF
    ENDIF
    RETURN Result AS "MA" coloured(r,g,b,t)
    If you replace line 8 with:
    MyMA   = Rsi[Periods](close)
    you will get a shifted RSI (you can change the variable’s name MyMA, or leave it as is).
Viewing 13 posts - 16 through 28 (of 28 total)
  • You must be logged in to reply to this topic.

EMA with a horizontal and verticle shift


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
josward1 @josward1 Participant
Summary

This topic contains 27 replies,
has 5 voices, and was last updated by robertogozzi
3 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/11/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...