break even/trailing function on manually put pending order

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #99273 quote
    Flow
    Participant
    New

    Hello everyone,

    i got this code from here:  https://www.prorealcode.com/blog/learning/breakeven-code-automated-trading-strategy/

    defparam cumulateorders = false
    
    startBreakeven = 30 //how much pips/points in gain to activate the breakeven function?
    PointsToKeep = 5 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
    
    c1 = RSI[14] crosses over 50
    
    if c1 then
    BUY 1 LOT AT MARKET
    SET STOP PLOSS 50
    endif
    
    //reset the breakevenLevel when no trade are on market
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    
    // --- BUY SIDE ---
    //test if the price have moved favourably of "startBreakeven" points already
    IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
    ENDIF
    
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF
    // --- end of BUY SIDE ---
    

    Here is my question:

    Is it possible to to get the break even function started when no condition, for example “crossing RSI”, is met?

    I want to open a position with an manually put pending limit- or stop-order. After the pending order turns into a open position

    the break even function should start.

    Would it work if i use this conditon?

    c1 = LONGONMARKET
    
    if c1 then
    BUY 0 LOT AT MARKET
    SET STOP PLOSS 0
    endif

    Thanks

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

break even/trailing function on manually put pending order


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Flow @flow Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/23/2019
Status: Active
Attachments: No files
Logo Logo
Loading...