Multitimeframe Order Exit

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #177989 quote
    Amr600
    Participant
    New

    Hey guys!

    I just made some multitimeframe systems and I want them to exit the trade at the open of the next bar in the bigger timeframe.

    Can you help me out?

     

    For Example:

    timeframe (5 minutes)

    // Bedingungen zum Triggern von Long-Positionen
    indicator1 = xxx
    c1 = (close < indicator1)

    // Bedingungen zum Triggern von Short-Positionen
    indicator3 = xxxx
    c3 = (close > indicator3)

     

    //Bedingugngen zum Einstieg in Long-/Shortpostitionen
    timeframe (10 seconds)
    if not longonmarket and c1 then
    buy 1 contract at indicator1 stop
    endif

    if not shortonmarket and c3 then
    sellshort 1 contract at indicator3 stop
    endif

    // GET OUT RULES??????

    Exit trade when a new candle opens in TF 5   ( WHAT IS THE CODE FOR THAT)

     

     

     

    THank you!

    #177990 quote
    Amr600
    Participant
    New

    I tried this:

     

    IF BarIndex – TradeIndex = x Then
    Sell at Market
    ExitShort at Market

     

    But if I write it under timeframe (5 Minutes) it doesnt exit anyway.

    If i write it under timeframe (10 seconds) it exits after a specific amount of bars, but not at the open of the new candle in the 5 min tf.

    #177992 quote
    GraHal
    Participant
    Master

    You need to use below …

     

    timeframe (5 minutes, updateonclose)
    #177995 quote
    Amr600
    Participant
    New

    what will that change for the closing of my order?

     

    this just delays my entry…..

    #177996 quote
    GraHal
    Participant
    Master

    See if attached does what you want it to ?

    I used 1 min (in place of 5 min) because 1 min produced more trades.

    Amr-EMAx-DJI-M1-v1.itf
    #178000 quote
    Amr600
    Participant
    New

    my problem is no the buying or how much trades the system produces. — I am opening orders in the 10 second timeframe,

     

    My proplem are the exits. —  I want to exit in the 5 minute timeframe.

     

     

    No matter when my trade is opened, i want to end it as soon as the next 5 minute bar opens.

    #178001 quote
    Amr600
    Participant
    New

    the code must be something like:

    for longpositions:

    if longonmarket then sell next bar at open in timeframe (5 minutes)

    for shortpositions:

    if shortonmarket then exitshort next bar at open in timeframe (5 minutes) 

    #178004 quote
    robertogozzi
    Moderator
    Master

    Strategies are only executed when a bar closes. At that time you will be able to open or close any trade, no choice.

    To be able to close, in a 5-minute TF, when the, say, 080000 candle opens, you need to place the exit order when the 075500 candle closes.

    Another solution could be to use a 1-second TF so that you close the trade at the closing of the 080000 1-second TF, that is at 080001.

    #178019 quote
    Amr600
    Participant
    New

    I know. I think you dont understand me.

     

    My system is buying in the 10 second chart when a buysignal is given in the 5 min chart.

    And my problem is: I want the system to sell when a new candle is opened in the 5 min chart. And i dont have the code for that.

    #178025 quote
    Amr600
    Participant
    New

    I need the code for:

     

    timeframe (5 minutes)

    EXIT = ………………………………           <————– what is the condition to sell next bar at open in the 5 minute timeframe?

     

    timeframe (10 seconds)

    If longonmarket and EXIT then
    sell at market
    endif

    If shortonmarket and EXIT then
    exitshort at market
    endif

    #178031 quote
    robertogozzi
    Moderator
    Master

    To exit when a candle opens you have to exit when the previous bar closes.

    To exit at 080000 you have to exit at the closing of the 075500 candle.

    IF Time = 080000 THEN
       // exit here
    ENDIF

    in the 5-minute TF (in the 10-second TF you should use 075550).

    #178034 quote
    Amr600
    Participant
    New

    But i dont know when my system is opening a trade.. so how should i know the exact time when to close it?

    #178038 quote
    Amr600
    Participant
    New

    I want the system to be flat, everytime a new candle opens in the t5 minute time frame.

    #178043 quote
    robertogozzi
    Moderator
    Master

    That’s easy, just exit as the beginning of your code. It will ALWAYS close any open trade:

    Timeframe (5 minutes, updateonclose)
    SELL AT Market
    EXITSHORT AT Market
    

    there’s no need to check if already OnMarket, as if it’s not the two instructions are ignored. And if you are in a Long position EXITSHORT will be ignored (and the opposite for SELL).

    Amr600 thanked this post
    #178044 quote
    Amr600
    Participant
    New

    THANK YOU!

     

    Thats what i was looking for, thank you VERY MUCH!!!!!!

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

Multitimeframe Order Exit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Amr600 @amr600 Participant
Summary

This topic contains 19 replies,
has 3 voices, and was last updated by Amr600
4 years, 5 months ago.

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