help coding Breakeven and Quit

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #139419 quote
    rama
    Participant
    Senior

    I am using the following code which is from the pro real time another post.
    I want to quit my system once it is moved break even.
    I have added the quit code it works sometime and sometimes not.
    just i want to make sure breakeven is set before quit if breakevel level is reached
    *****************

    DEFPARAM CumulateOrders = False
    buy  .2 contract at low[3]+2 stop
    set stop loss 45
    startBreakeven = 11 //how much pips/points in gain to activate the breakeven function?
    PointsToKeep = 1 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
    startBreakeven1 = 11.5
    //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>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice+PointsToKeep*pipsize
    ENDIF
    
    //place the new stop orders on market at breakevenLevel
    IF longonmarket and  breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    
    if close-tradeprice>=startBreakeven1*pipsize then
    quit
    endif
    ENDIF
    
    IF shortONMARKET AND tradeprice-close>=startBreakeven*pipsize THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice-PointsToKeep*pipsize
    ENDIF
    
    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 and shortonmarket then
    exitshort AT breakevenLevel STOP
    
    if  tradeprice-close>=startBreakeven1*pipsize then
    quit
    endif
    ENDIF
    
    #139420 quote
    rama
    Participant
    Senior

    I will be using when trading system is stopped my order will remain open the idea , moved to breakeven and avoid any loss when it is in profit

    #139421 quote
    robertogozzi
    Moderator
    Master

    Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’ (code help in your case).

    Thank you 🙂

    ************************************

    Try adding:

    GraphOnPrice breakevenLevel     coloured(128,0,0,255) as "BreakEven"
    GraphOnPrice (close-tradeprice) coloured(0,255,0,255) as "LongPROFIT"
    GraphOnPrice (tradeprice-close) coloured(0,0,255,255) as "ShortPROFIT"

    at the end of your code to monitor, on the price chart, the three values retained each bar.

    #139424 quote
    rama
    Participant
    Senior

    My code works fine as long I use no quit function

    I wan to quit once order is moved to break even

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

help coding Breakeven and Quit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rama @rama Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/16/2020
Status: Active
Attachments: No files
Logo Logo
Loading...