EXIT TRADING UNTIL TOMORROW – HOW TO CODE

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #19720 quote
    GraHal
    Participant
    Master

    Hi Guys

    Anybody know how best to code an ‘exit for today’ / Exit Trades until Tomorrow please?

    I’ve got as far as below, but can’t think how to code the line EXIT MARKET UNTIL TOMORROW

    Many Thanks
    GraHal

    If POSITIONPERF(3) + POSITIONPERF(2) + POSITIONPERF < - x THEN
    Sell at Market
    Exitshort at Market
    EXIT MARKET UNTIL TOMORROW 
    EndIf
    #19764 quote
    Elsborgtrading
    Participant
    Veteran

    Hi grahal. I’m on the phone txting so it will be short. Try and look at my last post and how I count intradaybarindex perhaps you can reuse some ideas there. IF intradaybarindex>X then exit or somerhing

    cheers Kasper

    GraHal thanked this post
    #19766 quote
    Nicolas
    Keymaster
    Master

    Save the current Date when closing your orders, and test if the current Date is different from this saved variable when you want to launch new orders.

    GraHal thanked this post
    #19832 quote
    GraHal
    Participant
    Master

    Mmm sounds easy when you say it Nicolas 🙂

    I’ve spent some time thinking and trying, but how do I Save the current Date when closing orders please.

    Thank You
    GraHal

    #19834 quote
    Nicolas
    Keymaster
    Master

    You can do it easily with your previous code:

    If POSITIONPERF(3) + POSITIONPERF(2) + POSITIONPERF < - x THEN
     Sell at Market
     Exitshort at Market
     savedate = Date
    EndIf

    And then when you want to initiate new orders, put a condition to verify if the current Date is not the previously saved one:

    if buycondition and Date<>savedate then 
     BUY 1 SHARE AT MARKET 
    endif

    It may be not the next day (tomorrow as you refer to it), but not the same day as your last closure. Don’t know if it’s important or not.

    #19877 quote
    GraHal
    Participant
    Master

    Embarrasingly easy when watching the Master 🙂  I was over-complicating the Date<>SaveDate.

    Results confused me at first. I worked on it (using GRAPH Function) until it made sense. Profit (optimised) almost same as without Date<>Savedate, but profit profile not as good … bigger drawdown.

    I’ll run Bot on Demo and if proves good I’ll put on here.

    Many Thanks Nicolas
    GraHal

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

EXIT TRADING UNTIL TOMORROW – HOW TO CODE


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by GraHal
9 years, 2 months ago.

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