How to bring trade to breakeven

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #89848 quote
    garyoaten
    Participant
    Average

    Hi, Id like to know how to automate bringing a trade to breakeven? At present I am aiming for 1/1.3 risk reward but would like it to at breakeven at worse once it has hit 1:1

    Can somebody please point me in the right direction?

    Also is there a way at a certain time you can make it close all open trades that the system has opened? So if it has a trade is open and I want it to close the trade at 1700hr no matter what.

    defparam cumulateorders=false
    
    // --- settings
    ATR = 82 //daily ATR value
    myTarget = 1.3 //target profit coefficient
    Capital = 5000 //capital at starting of the strategy
    Risk = 1 //risk in %
    StartTime = 080000
    EndTime = 163000
    // --- end of settings
    
    //indis
    bollm = ExponentialAverage[20](open)
    bollup = ExponentialAverage[20](open)+2*std[20](open)
    bolldn = ExponentialAverage[20](open)-2*std[20](open)
    tcondition = (time>=StartTime and time<=EndTime) and (opendayofweek>=1 and opendayofweek<=5)
    
    if tcondition then
    //short orders
    if high-bollm>ATR*0.25 and low>bollup and high-close > close-open then
    //money managenemt
    sellentry = low-1*pointsize
    sellstoploss = high+1*pointsize
    StopLoss = sellstoploss-sellentry
    selltarget = StopLoss*myTarget
    equity = Capital + StrategyProfit
    maxrisk = round(equity*(Risk/100))
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
    //pending order
    sellshort PositionSize contract at sellentry stop
    set target profit selltarget
    set stop loss StopLoss
    endif
    
    //long orders
    if bollm-low>ATR*0.25 and high<bolldn and close-low > high-close then
    //money managenemt
    buyentry = high+1*pointsize
    buystoploss = low-1*pointsize
    StopLoss = buyentry-buystoploss
    buytarget = StopLoss*myTarget
    equity = Capital + StrategyProfit
    maxrisk = round(equity*(Risk/100))
    PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
    //pending order
    buy PositionSize contract at buyentry stop
    set target profit buytarget
    set stop loss StopLoss
    endif
    endif
    
    //graph high-ema20>ATR*0.2 and low>bollup
    

     

    Thanks in advance

    Gary

    PRC_GaryOaten01modified.itf
    #89852 quote
    Vonasi
    Moderator
    Master

    garyoaten – Please use the ‘Insert PRT Code’ button when putting code in your posts to make it more readable for others. I have tidied up your post for you 🙂

    #89909 quote
    Nicolas
    Keymaster
    Master
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

How to bring trade to breakeven


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
garyoaten @garyoaten Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Nicolas
7 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/28/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...