linking 2 or more trading systems

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

    hi,

    is there a way i can link 2 or more systems trading the same instrument. example:

    trading system 1

    if not onmarket then
    buy 2 contract at market
    endif
    

    trading system 2

    if longonmarket then
    sellshort 1 contract at market
    endif
    

    the trading system 2 cannot detect if there a longs on the market.

    #161756 quote
    robertogozzirobertogozzi
    Moderator
    Legend
    #161761 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I’m afraid that link doesn’t work, that’s a copy of that post:

    You can assembly all of your strategies into a bigger file.

    “DEFPARAM CumulateOrders = false” will do the hard job!

    Of course you may need to name variables in different ways, say, a1s1 or cond1s1 for the first strategy, then a2s1/cond2s1….. a1s2/cond1s2 for the second strategy etc….

    You may name a variable StrategyID = 0 when NOT ONMARKET, then set it to any number you want each buy/sell is executed so you know which strategy was triggered.

    Example:

    DEFPARAM CumulateOrders = False                                 //Only 1 trade at a time
     
    IF NOT OnMarket THEN                                            //Make sure you reset this variable to ZERO when not trading
       StrategyID = 0
    ENDIF
    //-----------------------------------------------------------------------------------------------------------------
    IF (StrategyID = 0) OR (StrategyID = 1) THEN					//Strategy 1
       s1.... = ......
       .
       .
    ENDIF
    //-----------------------------------------------------------------------------------------------------------------
    IF (StrategyID = 0) OR (StrategyID = 2) THEN					//Strategy 2
       s2Avg = Average[20](close)
       s2Rsi = Rsi[14]
       .
       .
       .
       //************************************************************************
       //                                 LONG
       //************************************************************************
       IF close CROSSES OVER s2Avg  THEN
          StrategyID = 2
          SET TARGET PPROFIT 20
          SET STOP PLOSS     10
          BUY nLots CONTRACT AT MARKET
       ENDIF
       //************************************************************************
       //                                 SHORT
       //************************************************************************
       IF close CROSSES UNDER s2Avg  THEN
          StrategyID = 2
          SET TARGET PPROFIT 20
          SET STOP PLOSS     10
          SELLSHORT nLots CONTRACT AT MARKET
       ENDIF
       .
       .
       .
       .
    ENDIF
    //-----------------------------------------------------------------------------------------------------------------
    IF (StrategyID = 0) OR (StrategyID = 3) THEN					//Strategy 3
       s3.... = ......
       .
       .
       .
    ENDIF

     

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

linking 2 or more trading systems


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kevin12345 @kevin12345 Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/17/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...