Trade change Long / Short and vice versa.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10519 quote
    MaddinMaddin
    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
    NicolasNicolas
    Keymaster
    Legend

    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.
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

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 NicolasNicolas
10 years, 1 month ago.

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