5 EMA Stratergy

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

    Hi All,

    Need some help with 5 EMA statergy that Im developing. Made some attempts but doesnt yield correct results but i think im quite close.

    Short Conditions
    1. Timeframe is 5 minutes for short trades
    2. Plot 5 EMA on candles.
    3. candles which are above 5 EMA (shouldnt even be touching 5 EMA at all. We call these as alert candle.
    4. It is perfectly possible to have more than 1 alert candle, in case the next candle becomes alert candle and we ignore the previous ones.
    5. Candle which breaks alert candle low, We should take a short.
    6. Stop Loss becomes one of the previous alert candles high. This could be last 3,4,5 candles
    7. target is going to be 3X of Stop loss.
    8. When we reach 80% of target we want to close 75% of position size and trail 25% with last 3 candles low

    Long Conditions
    1. Timeframe is 15 minutes for Long trades
    2. Plot 5 EMA on candles.
    3. candles which are below 5 EMA (shouldnt even be touching 5 EMA at all. We call these as alert candles.
    4. It is perfectly possible to have more than 1 alert candle, in case the next candle becomes alert candle and we ignore the previous ones.
    5. Candle which breaks alert candle High, We should take a short.
    6. Stop Loss becomes one of the previous alert candles Low. This could be last 3,4,5 candles
    7. target is going to be 3X of Stop loss.
    8. When we reach 80% of target we want to close 75% of position size and trail 25% with last 3 candles High

    5EMA-Short.png 5EMA-Short.png
    #204068 quote
    nitinvijayrane
    Participant
    New
    //5EMA
    //05.11.2022
    //Nitin
    
    DEFPARAM CumulateOrders = False
    DEFPARAM PreloadBars    = 200
    
    PositionSize  = 1
    
    //5 minute TF (get the trend of the 5 minute chart)
    //timeframe(5 minutes,updateonclose)
    MyEma5 = ExponentialAverage[5]
    
    AlertCandleShort = (Low > MyEma5)
    
    if AlertCandleShort then
    if AlertCandleShort and Low < Low[1] then
    sellshort positionsize contracts at market
    endif
    endIf
    
    
    stoplosslong = abs(close-Low[1])-5*pointsize
    Longtgt = stoplosslong * 3
    if longonmarket then
    set stop loss stoplosslong
    set target profit Longtgt
    endif
     
    stoplosshort = abs(close-High[1])+5*pointsize
    Shorttgt = stoplosshort * 3
    if shortonmarket then
    set stop loss stoplosshort
    set target profit Shorttgt
    endif
    

     

    5EMA-15-min-long.png 5EMA-15-min-long.png
    #204187 quote
    robertogozzi
    Moderator
    Master

    There you go:

    DEFPARAM CumulateOrders = False
    //---------------------------------------------------
    // Short Timeframe
    //
    Timeframe(5mn,UpdateOnClose)
    Ema5mn5      = average[5,1](close)
    ShortAlert   = low > Ema5mn5
    IF ShortAlert THEN
       BreakLow  = low
    ENDIF
    ShortTrigger = close < BreakLow
    IF OnMarket THEN
       ShortAlert   = 0
       BreakLow     = 0
       ShortTrigger = 0
    ENDIF
    IF ShortTrigger THEN
       SELLSHORT 1 CONTRACT AT Market
       StopPriceS    = highest[3](high)
       TargetSizeS   = (StopPriceS - close) * 3
       TargetPriceS  = close - TargetSizeS
       FirstExitS    = close - (TargetSizeS * 0.8)
       SET STOP   Price StopPriceS
       SET TARGET Price TargetPriceS
       TrailStartS   = 0
    ENDIF
    IF ShortOnMarket THEN
       IF (close <= FirstExitS) AND (TrailStartS = 0) THEN
          EXITSHORT abs(CountOfPosition) * 0.75 CONTRACTS AT Market
          TrailStartS   = lowest[3](low)
       ENDIF
       IF TrailStartS THEN
          TrailStartS   = lowest[3](low)
          SET STOP Price TrailStartS
       ENDIF
    ENDIF
    //---------------------------------------------------
    // Long  Timeframe
    //
    Timeframe(15mn,UpdateOnClose)
    Ema15mn5     = average[5,1](close)
    LongAlert    = high < Ema15mn5
    IF LongAlert THEN
       BreakHigh = high
    ENDIF
    LongTrigger  = close > BreakHigh
    IF OnMarket THEN
       LongAlert    = 0
       Breakhigh    = 0
       LongTrigger  = 0
    ENDIF
    IF LongTrigger  THEN
       BUY 1 CONTRACT AT Market
       StopPriceL    = lowest[3](low)
       TargetSizeL   = (close - StopPriceL) * 3
       TargetPriceL  = close + TargetSizeL
       FirstExitL    = close + (TargetSizeL * 0.8)
       SET STOP   Price StopPriceL
       SET TARGET Price TargetPriceL
       TrailStartL   = 0
    ENDIF
    IF LongOnMarket THEN
       IF (close >= FirstExitL) AND (TrailStartL = 0) THEN
          SELL abs(CountOfPosition) * 0.75 CONTRACTS AT Market
          TrailStartL   = highest[3](high)
       ENDIF
       IF TrailStartL THEN
          TrailStartL   = highest[3](high)
          SET STOP Price TrailStartL
       ENDIF
    ENDIF
    //---------------------------------------------------
    //IF ShortOnMarket THEN
    //GraphOnPrice StopPriceS coloured("Red")
    //GraphOnPrice TrailStartS coloured("Blue")
    //ELSIF LongOnMarket THEN
    //GraphOnPrice StopPriceL coloured("Red")
    //GraphOnPrice TrailStartL coloured("Blue")
    //ENDIF
    nitinvijayrane thanked this post
    #204192 quote
    nitinvijayrane
    Participant
    New

    Thanks Guys this is really helpful, appreciate your help

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

5 EMA Stratergy


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

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

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