Check of previous candles

Viewing 15 posts - 1 through 15 (of 32 total)
  • Author
    Posts
  • #75916 quote
    Marc
    Participant
    Average

    Hi together,

    I need some help regarding checking of previous candles in different periods.

    I’m working with a trend following systems which cheks if the previuos months open is higher or lower. Than it checks if the last months candle is higher or lower.

    If previous moth and previous week candles are in the same direction than the systems checks the previous days candle (except monday). If previous days candle is in the opposite direction of previos month and week than an order will be set either on the high or the low of previous days candle.
    Example:
    Month: bullish = open < close
    Week: bullish = open < close
    Day: bearish = open > close
    Set a buy order at high of bearish candle

    Month: bearish= open > close
    Week: bearish = open > close
    Day: bullish = open < close
    Set a sell order at low of bearish candle

    Each friday evening non executed orders will be deleted.
    Monday is not a trading day
    SL an TP are ATR(2)
    If sell /buy stop order is not filled within the next day and on the curent day the previous days candle is still in the opposite direction of compared monthly and weekly candle than buy stop and sell stop must be amended to previous days high / low.

    I hope that anyone can help me with this system. In my opninion this should generate good trades with mostly positive results.

     

    Thank you in advance
    Marc

    #76290 quote
    Marc
    Participant
    Average

    Anybody there who can help?

    #76294 quote
    robertogozzi
    Moderator
    Master

    Please do not duplicate posts in different topics and languages, this won’t help and will shatter replies among different topics making it more difficult to retrieve. Thank you.

    Which one do you prefer to keep, the english or german one?

    #76295 quote
    robertogozzi
    Moderator
    Master


    I’m working with a trend following systems which checks if the previous month’s open is higher or lower. Then it checks if the last month’s candle is higher or lower.

    What do you mean with the BLUE sentence, shall OPEN be higher than…. what?

    What do you mean with the RED sentence, shall the …what?… of the CANDLE be higher/lower than… what again?

    #76559 quote
    Marc
    Participant
    Average

    Ciao Roberto,

     

    I’d like to keep / collect all information in the english version.
    1st of all thank you for your reply.

    I made a mistake while describing the system in the first sentence. It should be read as follows:
    The System shall recognize if the previous months direction is bullish (close > open) or bearish (close < open). Afterwards the system shall recognize if the previous week is bullish (close > open) or bearish (close < open). If both previous monthly and weekly candle moves in the same direction (either both directions are bearish or bullish) then the system checks on tuesday if the monday candles direction is opposite (close < open) compared with monthly and weekly candle.

    This means if previous month and week are bullish than the rules set a pending order on high of mondays candle incl. slippage and spread (order must be set on tuesday because mondays candle hasn’t finished until this candle close due to change of date). If on Tuesday the order is not triggered, but the tuesdays candle also moves in the opposite direction of previous month and week candle the current pending order has to be amended to high of tuesdays candle and so on. If order was’t triggered within this week all pending orders will be deleted on Friday Evening.

    For bearish set up above rules must be used vice versa.
    Currently there is no TP and SL mentioned in the system which would be necessary if basic of this system works.

    I hope I clarified the rules of this system.

     

    Thank you in advance

    Marc

    #76636 quote
    robertogozzi
    Moderator
    Master

    Try this code, I just run it to check syntax and if it opened any trades:

    DEFPARAM CumulateOrders = false
    
    TIMEFRAME (Monthly, updateonclose)
    IF close > open THEN
       MyMonth = 1              //BULLish
    ELSE
       MyMonth = -1             //BEARish
    ENDIF
    
    TIMEFRAME (Weekly, updateonclose)
    IF close > open THEN
       MyWeek  = 1              //BULLish
    ELSE
       MyWeek  = -1             //BEARish
    ENDIF
    
    TIMEFRAME (Daily, updateonclose)
    ONCE AlreadyTraded = 0
    IF close > open THEN
       MyDay   = 1              //BULLish
    ELSE
       MyDay   = -1             //BEARish
    ENDIF
    ThisDay = OpenDay
    IF ThisDay = 1 AND Not OnMarket AND AlReadyTraded = 0 THEN     //Monday
       GoLong  = MyMonth = 1  AND MyWeek =  1 AND MyDay = -1
       GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay = 1
       IF GoLong THEN
          EntryPrice = high
          BUY 1 CONTRACT AT EntryPrice LIMIT
       ELSIF GoShort THEN
          EntryPrice = low
          SELLSHORT 1 CONTRACT AT EntryPrice LIMIT
       ENDIF
       Sl = AverageTrueRange[2](close)
       Tp = Sl
       SET Stop   Loss   Sl
       SET Target Profit Tp
    ENDIF
    
    IF ThisDay = 2 AND Not OnMarket AND AlReadyTraded = 0 THEN     //Tuesday
       GoLong  = MyMonth = 1  AND MyWeek =  1 AND MyDay[1] = -1 AND MyDay = -1
       GoShort = MyMonth = -1 AND MyWeek = -1 AND MyDay[1] = 1  AND MyDay = 1
       IF GoLong THEN
          EntryPrice = high
          BUY 1 CONTRACT AT EntryPrice LIMIT
       ELSIF GoShort THEN
          EntryPrice = low
          SELLSHORT 1 CONTRACT AT EntryPrice LIMIT
       ENDIF
       Sl = AverageTrueRange[2](close)
       Tp = Sl
       SET Stop   Loss   Sl
       SET Target Profit Tp
    ENDIF
    
    IF ThisDay = 1 AND Not OnMarket THEN
       AlreadyTraded = 0
    ENDIF
    IF OnMarket THEN
       AlreadyTraded = 1
    ENDIF
    My-System-MARC.itf
    #76650 quote
    Marc
    Participant
    Average

    Hi Roberto,

    thank you very much for your help. I will try this code and hope that it will work the way I trade currently 🙂

    Rgds

    Marc

    #76651 quote
    Marc
    Participant
    Average

    Cheers Roberto,

    I receive an information that in Line 3 word ‘monthly’ doesn’t work. Please see file attached

    Neue-Bitmap.jpg Neue-Bitmap.jpg
    #76653 quote
    Marc
    Participant
    Average

    Hi Roberto,

    when hiding the hole code for timeframe monthly I receive the same issue for weekly and Daily.

    Rgds Marc

    #76654 quote
    robertogozzi
    Moderator
    Master

    My system works perfectly, the attached screenshot is for DAX daily, but it works on any instrument.

    There must be an error in the first 2 lines.

    Did you import the file?

    x-9.jpg x-9.jpg
    #76662 quote
    Vonasi
    Moderator
    Master

    Are you trying to run it on PRT Live. With TIMEFRAME it will only currently work on demo platforms?

    #76669 quote
    Marc
    Participant
    Average

    Hi Roberto I tried to import the file and it worked well, but I receive the same error when start testing

    #76671 quote
    Marc
    Participant
    Average

    Ciao Vonasi,

    I use IG Markets with a Real Account and not a demo platform.

    This can be the reason.


    @roberto
    : Are you using a demo platform?

    Rgds
    Marc

    #76672 quote
    robertogozzi
    Moderator
    Master

    Yes, it only works on demo accounts. You’ll have to wait a few months to be able to run it, then!

    I’ll work on trying to make it work on Real accounts, removing TIMEFRAME and using FOR…NEXT loops to scan past weeks and months, but I fear it’ll be a time-consuming code, if I can code it!

    I’ll let you know.

    #76673 quote
    Marc
    Participant
    Average

    Hi Roberto,

     

    thank you very much for your help. I really appreciate it 🙂

    I’ll try my best on using it onb a demo account too

    Rgds
    Marc

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

Check of previous candles


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Marc @mast83 Participant
Summary

This topic contains 31 replies,
has 3 voices, and was last updated by Marc
7 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/13/2018
Status: Active
Attachments: 4 files
Logo Logo
Loading...