2 trading bot into a single 1?

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

    Hello, I want to incorporate 2 robots, 1 mean reversion algorithm and 1 breakout algorithm, in 1 single robot.
    I want the robot that if one robot is a triggered trade, the algo can continue to take trades only from the other one.

    Example, the mean reversion algo takes one trade.
    As long as this trade is not closed, it will not be able to resume a trade if a mean reversion signal is triggered.
    On the other hand the robot will be able to take a trade if a breakout signal appears.
    How can I do this, I tried but without any result ?

    DEFPARAM CumulateOrders = True
    
    // Conditions pour ouvrir une position acheteuse
    
    BBH = BollingerUp[20](close)
    SMA7 = Average[7](close)
    SMA20 = Average[20](close)
    
    
    // Mean reversion bot
    RobotA = (SMA7 < SMA20) AND (close < SMA7) and (close > high[1])
    
    // Breakout bot
    RobotB = (close > high[1])
    
    
    
    // THE 4 FLAG
    
    If Not LongOnMarket AND RobotA then
    Flag = 1
    endif
    
    // The condition to be avoided for RobotA once a trade from RobotA has been triggered
    If  LongOnMarket AND RobotA  then
    Flag = 2
    endif
    
    If Not LongOnMarket  AND RobotB  then
    Flag = 3
    endif
    
    // The condition to be avoided for RobotB once a trade from RobotB has been triggered
    If LongOnMarket  AND RobotB  then
    Flag = 4
    endif
    
    
    IF  (RobotA AND NOT 2) OR  (RobotB AND NOT 4)   THEN
    Buy 1 lot AT MARKET
    ENDIF
    
    
    // Stops et objectifs : entrez vos stops et vos objectifs ici
    SET STOP $LOSS 1000
    SET TARGET $PROFIT 500

    2nd way to launch orders :

    IF ( (RobotA and 1) OR  (RobotA AND 3) OR (RobotA and 4) ) 
    OR ( (RobotB and 1) OR (ROBOTB AND 2) OR (ROBOTB AND 4) )
    Then
    Buy 1 lot AT MARKET
    ENDIF
    #158616 quote
    robertogozzi
    Moderator
    Master

    This should work, but you won’t be able to enter again until both trades are exited, because once both strategies have opened a trade, it’s very difficult to know which one closes.

    You could do this by keeping track of each TRADEPRICE, but it’s not that straightforward!

    DEFPARAM CumulateOrders = True
    
    If not OnMarket Then
       FlagA = 0
       FlagB = 0
    Endif
    
    // Conditions pour ouvrir une position acheteuse
     
    BBH = BollingerUp[20](close)
    SMA7 = Average[7](close)
    SMA20 = Average[20](close)
     
     
    // Mean reversion bot
    RobotA = (SMA7 < SMA20) AND (close < SMA7) and (close > high[1])
     
    // Breakout bot
    RobotB = (close > high[1])
     
     
     
    // THE 2 FLAGS
    
    IF  RobotA AND FlagA = 0 THEN
       Buy 1 lot AT MARKET
       FlagA = 1
    ENDIF
    
    IF  RobotB AND FlagB = 0 THEN
       Buy 1 lot AT MARKET
       FlagB = 1
    ENDIF
    
     
    // Stops et objectifs : entrez vos stops et vos objectifs ici
    SET STOP $LOSS 1000
    SET TARGET $PROFIT 500
    Midlanddave and Oliviertrader2020 thanked this post
    #158677 quote
    Oliviertrader2020
    Participant
    Average

    Thank you, I learn a lot with your advices and your codes. Indeed TRADEPRICE seems complicated to set up, if I can already take one trade from each robot at the same time it’s a very good point that suits me.

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

2 trading bot into a single 1?


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Oliviertrader2020
5 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/20/2021
Status: Active
Attachments: No files
Logo Logo
Loading...