Trade change Long / Short and vice versa.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10519 quote
    Maddin
    Participant
    New

    Hello,

    i want to add an additional rule in my strategy.

    This rule is:

    After a Longtrade only is possible a Shorttrade

    and

    after a Shorttrade only is possible a Longtrade.

    How is the Code for this?

    Thank You for help in advance!

    Maddin

    #11615 quote
    Nicolas
    Keymaster
    Master

    Hi, you only need to flag a variable when you launch a new trade:

    once trade=0
    
    if longconditions and (trade=-1 or trade=0) then 
     buy 1 lot at market 
     trade = 1
    endif 
    
    if shortconditions and (trade=1 or trade=0) then 
     sellshort 1 lot at market 
     trade = -1
    endif 

    Then test this “trade” variable to see if your last trade were a long or a short position.

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

Trade change Long / Short and vice versa.


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Maddin @maddin Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
9 years, 6 months ago.

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