Add a second trade

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

    Hi guys,

    Want to ask you if you can help me out, Im struggling with two strategies for two different robots

    1. place a second larger trade if the current trade is profitable
    2. place a second trade in the same direction as the current trade if the current trade have moved against me for x pips or $
    #33992 quote
    MazMaz
    Participant
    Veteran

     

    // Something like this...
    inProfit = positionPerf > 0
    
    if inProfit then
     // we are in profit
     // buy largetPosition shares at market
    endif
    
    // ------------------------
    
    if longOnMarket then
      pointDrawdown = tradePrice - close
    elsif shortOnMarket then
      pointDrawdown = close - tradePrice
    else
      pointDrawdown = 0
    
    // note pointDrawdown expressed as above is a POSITIVE number and if you are in profit it will be a -ve number
    // so then...
    
    if pointDrawdown >= myMaxPointDrawdown then
     // we reached our threshold
    // buy at market
    endif
    
    // ps careful with averaging down :-)
    
    
    
    Nicolas and Fredrik thanked this post
    #34881 quote
    FredrikFredrik
    Participant
    New

    Thanks!

    #34884 quote
    FredrikFredrik
    Participant
    New

    Hi again,

    so to add a second larger position if the current one is profitable I will use the code:

    inProfit = positionPerf > 0
    
    if inProfit then
    buy x contract at market
    endif

    How can one distinguish that it will add to a specific position if I have multiple? lets say I have 2 long positions and 3 short positions, does one add a label to the trades ? I mean I would need one more for sell on market and how does the script decide which one to use?

    for instance…

    // Buy condition
    if c1 then
    buy 1 contract at market
    endif
    
    // Add a second buy trade if first one is profitable
    inProfit = positionPerf > 0
    
    if inProfit then
    buy 1 contract at market
    endif
    
    
    // Sell condition
    if c1 then
    sellshort 2 contract at market
    endif
    
    
    // Add a second sell trade if first one is profitable
    inProfit = positionPerf > 0
    
    if inProfit then
    sellshort 1 contract at market
    endif
Viewing 4 posts - 1 through 4 (of 4 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

Add a second trade


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Fredrik @fredrik Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/29/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...