3 Min EURUSD RSI

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #63580 quote
    BarneyBarney
    Participant
    Senior

    A simple RSI code that works ok.

    However, is not completely satisfied with the stop.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    
    // Conditions to enter long positions
    indicator1 = RSI[14](close)
    c1 = (indicator1 < 30)
    
    indicator2 = RSI[14](close)
    c2 = (indicator2 > 86)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    IF c2 THEN
    sellshort 1 CONTRACT AT MARKET
    ENDIF
    
    
    
    
    
    //     trailing stop function
    trailingstep      = 6    //5    trailing step to move the "stoploss" after BreakEven
    startBreakeven    = 2     //5    pips in gain to activate the breakeven function
    PointsToKeep      = 2     //3    pips to keep in profit above/below entry price when the breakeven is activated
    //
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL          = 0
    breakevenLevel = 0
    ENDIF
    //******************************************************************************************************
    // ----- BREAKEVEN code
    //
    //reset the breakevenLevel when no trade are on market
    // --- LONG  side
    IF LONGONMARKET AND (close - tradeprice(1)) >= (startBreakeven * pipsize) AND breakevenlevel = 0 THEN
    breakevenLevel = tradeprice(1) + (PointsToKeep * pipsize)                         //calculate the breakevenLevel
    ENDIF
    // --- SHORT side
    IF SHORTONMARKET AND (tradeprice(1) - close) >= (startBreakeven * pipsize) AND breakevenlevel = 0 THEN
    breakevenLevel = tradeprice(1) + (PointsToKeep * pipsize)                         //calculate the breakevenLevel
    ENDIF
    //Set new Stop Loss
    IF breakevenLevel > 0 THEN
    newSL = BreakEvenLevel
    ENDIF
    //******************************************************************************************************
    // ----- TRAILING STOP code
    //
    //manage long positions
    IF LONGONMARKET AND BreakEvenLevel THEN
    //next moves after BreakEven
    IF newSL > 0 AND ((close - newSL) >= (trailingstep * pipsize)) THEN
    newSL = newSL + (trailingstep * pipsize)
    ENDIF
    ENDIF
    //manage short positions
    IF SHORTONMARKET AND BreakEvenLevel THEN
    //next moves after BreakEven
    IF newSL > 0 AND ((newSL - close) >= (trailingstep * pipsize)) THEN
    newSL = newSL - (trailingstep * pipsize)
    ENDIF
    ENDIF
    //stop order to exit the positions
    IF newSL > 0 THEN
    SELL      AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    EURUSD-3-min.jpg EURUSD-3-min.jpg
    #63591 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Breakeven after 2 pips with 2 pips to keep dordn’t leave the strategy room to jigsaw a bit!
    I guess that trailingstep is rarely beneficial.

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

3 Min EURUSD RSI


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Barney @rickardktm Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
8 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/22/2018
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...