again a question to the pivot

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #190024 quote
    f1_maik
    Participant
    Junior

    again, a question to the pivot.
    Sometimes I scare myself with how little my programming skills are.

    I would like to do the following on a daily basis:
    Once the pivot points are known (00.00?) open a trade that has the target the pivot point.
    For the calculation of the pivot for Monday, the data from Friday should be taken.

    How do I program this correctly?

    A big thank you in advance

    #190026 quote
    robertogozzi
    Moderator
    Master

    There you go:

    DEFPARAM CumulateOrders = False
    //
    // Predefined PRT calculation  (H+L+C)/3
    //
    p       = 1
    IF OpenDayOfWeek = 1 THEN
       p    = 2
    ENDIF
    Pivt    = (DHigh(p) + DLow(p) + DClose(p))/3                             // - Pivot
    //Res4  = (2 * Pivt) + Dhigh(p) - (3 * Dlow(p))                          //Res4
    //Res3  = DHigh(p)+(2*(Pivt-DLow(p)))                                    //Res3
    //Res2  = Pivt+(DHigh(p)-DLow(p))                                        //Res2
    //Res1  = (2*Pivt) - DLow(p)                                             //Res1
    //Sup1  = (2*Pivt) - DHigh(p)                                            //Sup1
    //Sup2  = Pivt-(DHigh(p)-DLow(p))                                        //Sup2
    //Sup3  = DLow(p)-(2*(DHigh(p)-Pivt))                                    //Sup3
    //Sup4  = (2 * Pivt) + Dlow(p) - (3 * Dhigh(p))                          //Sup4
    //MidR1 = (3*((DHigh(p) + DLow(p) + DClose(p))/3)-DLow(p))/2             //MidR1
    //MidR2 = 3*(((DHigh(p) + DLow(p) + DClose(p))/3)+DHigh(p))/2-DLow(p)    //MidR2
    //MidR3 = DHigh(p)+3*(((DHigh(p) + DLow(p) + DClose(p))/3)-DLow(p))/2    //MidR3
    //MidS1 = (3*((DHigh(p) + DLow(p) + DClose(p))/3)-DHigh(p))/2            //MidS1
    //MidS2 = 3*(((DHigh(p) + DLow(p) + DClose(p))/3)-DLow(p))/2-DHigh(p)    //MidS2
    //MidS3 = DLow(p)+3*(((DHigh(p) + DLow(p) + DClose(p))/3)-DHigh(p))/2    //MidS3
    IF close > Pivt THEN
       BUY 1 CONTRACT AT Market
       SET TARGET pPROFIT abs(close - Pivt)
    ELSIF close > Pivt THEN
       SELLSHORT 1 CONTRACT AT Market
       SET TARGET pPROFIT abs(close - Pivt)
    ENDIF
    f1_maik thanked this post
    #190029 quote
    robertogozzi
    Moderator
    Master

    Sorry, in line 24 the “>” relational operator should be replaced by “<“.

    Actually you did not tell when to enter Long or Short, so I just guessed.

    f1_maik thanked this post
    #190049 quote
    f1_maik
    Participant
    Junior

    Dear man.

    Thank you very much for the code.
    I will look into it and get back to you.

    lg

    #190191 quote
    f1_maik
    Participant
    Junior

    Hello .

    I had to deal with other things the whole days and only now got to look at the code.

    I have rewritten the code a bit, simplified it a bit.
    It looks like if set cumulateorders = true, the TP is cleared and set new each day. How can I change this?

    DEFPARAM CumulateOrders = true
    
    p       = 1
    IF OpenDayOfWeek = 1 THEN
    p    = 2
    ENDIF
    
    Pivt    = (DOpen(p) + DHigh(p) + DLow(p) + DClose(p))/4                  // - Pivot
    //Res4  = (2 * Pivt) + Dhigh(p) - (3 * Dlow(p))                          //Res4
    //Res3  = DHigh(p)+(2*(Pivt-DLow(p)))                                    //Res3
    //Res2  = Pivt+(DHigh(p)-DLow(p))                                        //Res2
    //Res1  = (2*Pivt) - DLow(p)                                             //Res1
    //Sup1  = (2*Pivt) - DHigh(p)                                            //Sup1
    //Sup2  = Pivt-(DHigh(p)-DLow(p))                                        //Sup2
    //Sup3  = DLow(p)-(2*(DHigh(p)-Pivt))                                    //Sup3
    //Sup4  = (2 * Pivt) + Dlow(p) - (3 * Dhigh(p))                          //Sup4
    //MidR1 = (3*((DHigh(p) + DLow(p) + DClose(p))/3)-DLow(p))/2             //MidR1
    //MidR2 = 3*(((DHigh(p) + DLow(p) + DClose(p))/3)+DHigh(p))/2-DLow(p)    //MidR2
    //MidR3 = DHigh(p)+3*(((DHigh(p) + DLow(p) + DClose(p))/3)-DLow(p))/2    //MidR3
    //MidS1 = (3*((DHigh(p) + DLow(p) + DClose(p))/3)-DHigh(p))/2            //MidS1
    //MidS2 = 3*(((DHigh(p) + DLow(p) + DClose(p))/3)-DLow(p))/2-DHigh(p)    //MidS2
    //MidS3 = DLow(p)+3*(((DHigh(p) + DLow(p) + DClose(p))/3)-DHigh(p))/2    //MidS3
    
    If time = 080000 then
    If close < Pivt then
    buy at market
    Endif
    Endif
    
    SET TARGET pPROFIT abs(close - Pivt)
    set stop %loss 10
    
    #190192 quote
    f1_maik
    Participant
    Junior

    Addendum.

    Perhaps for the better understanding.

    Every started trade should keep its “own” pivot as target.

    #190193 quote
    robertogozzi
    Moderator
    Master

    Nope, when accumulating positions an average price is calculated at any new position taken and TP and SL are adjusted accordingly.

    This cannot be changed.

    f1_maik thanked this post
    #190198 quote
    f1_maik
    Participant
    Junior

    pity

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

again a question to the pivot


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
f1_maik @f1_maik Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by f1_maik
3 years, 10 months ago.

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