Automated trading with Pivot Points and Dojis

Viewing 15 posts - 61 through 75 (of 85 total)
  • Author
    Posts
  • #71173 quote
    cgraubner
    Participant
    Junior

    Thank you, it is good to know, that the code is actually working, but it is just not working on my pc. What could be a reason for that, since my picture shows a different result?

    example-1.png example-1.png
    #71184 quote
    robertogozzi
    Moderator
    Master

    I can’t be of any help about this, maybe it’s because you deal with Futures while I trade CFDs, or maybe you are using end-of-day data.

    I have no further clues.

    cgraubner thanked this post
    #71259 quote
    cgraubner
    Participant
    Junior

    Once again, when I use the following code with the euro dollar mini chart, the trade does not close when a new lower low forms. This exact code is working at different markets, like DAX or DOW JONES. The picture shows thursday 20.07.2017, and I backtested 100000 units.

    Do I have to consider something special when using the euro dollar mini chart? Thank you!:)

    // EURO DOLLAR MINI 15 min
    DEFPARAM CumulateOrders = false
    DEFPARAM FlatBefore = 000000
    DEFPARAM FlatAfter = 234500
    
    
    
    
    if OpenDayOfWeek = 1 then
    
    Pivot = (DHigh(2) + DLow(2) + DClose(2)) / 3
    //R1 = 2*Pivot - DLow(2)
    //S1 = 2*Pivot - DHigh(2)
    //rR2 = Pivot + (DHigh(2) - DLow(2))
    S2 = Pivot - (DHigh(2) - DLow(2))
    //R3 = R1 + (DHigh(2) - DLow(2))
    //S3 = S1 - (DHigh(2) - DLow(2))
    
    endif
    
    if OpenDayOfWeek = 2 then
    
    Pivot = (DHigh(1) + DLow(1) + DClose(1)) / 3
    //R1 = 2*Pivot - DLow(1)
    //S1 = 2*Pivot - DHigh(1)
    //rR2 = Pivot + (DHigh(1) - DLow(1))
    S2 = Pivot - (DHigh(1) - DLow(1))
    //R3 = R1 + (DHigh(1) - DLow(1))
    //S3 = S1 - (DHigh(1) - DLow(1))
    
    endif
    
    if OpenDayOfWeek = 3 then
    
    Pivot = (DHigh(1) + DLow(1) + DClose(1)) / 3
    //R1 = 2*Pivot - DLow(1)
    //S1 = 2*Pivot - DHigh(1)
    //rR2 = Pivot + (DHigh(1) - DLow(1))
    S2 = Pivot - (DHigh(1) - DLow(1))
    //R3 = R1 + (DHigh(1) - DLow(1))
    //S3 = S1 - (DHigh(1) - DLow(1))
    
    endif
    
    if OpenDayOfWeek = 4 then
    
    Pivot = (DHigh(1) + DLow(1) + DClose(1)) / 3
    //R1 = 2*Pivot - DLow(1)
    //S1 = 2*Pivot - DHigh(1)
    //rR2 = Pivot + (DHigh(1) - DLow(1))
    S2 = Pivot - (DHigh(1) - DLow(1))
    //R3 = R1 + (DHigh(1) - DLow(1))
    //S3 = S1 - (DHigh(1) - DLow(1))
    
    endif
    
    if OpenDayOfWeek = 5 then
    
    Pivot = (DHigh(1) + DLow(1) + DClose(1)) / 3
    //R1 = 2*Pivot - DLow(1)
    //S1 = 2*Pivot - DHigh(1)
    //rR2 = Pivot + (DHigh(1) - DLow(1))
    S2 = Pivot - (DHigh(1) - DLow(1))
    //R3 = R1 + (DHigh(1) - DLow(1))
    //S3 = S1 - (DHigh(1) - DLow(1))
    
    endif
    
    
    
    dojisizes2d = 10
    dojis2d = Range >= ABS(Open[1] - Close[1]) * dojisizes2d
     
    
    bullishs2d = (dojis2d and low[1] <= s2+abstl2d and low[1] >= s2-abst2d and close>high[1] and low>low[1])
    
    
    abst2d = 8*pipsize
    abstl2d = 2*pipsize
    size = 4
    
    if bullishs2d then
    
    ldbs2d = low[1]-2
    Buy size Contract at Market
    endif
    
    
    
    if longonmarket and ldbs2d then
    sell at ldbs2d stop
    endif
    
    
    if longonmarket and (close <low[1]) then
    sell at market
    endif
    
    euro-dollar.png euro-dollar.png
    #71262 quote
    robertogozzi
    Moderator
    Master

    Once again, when I use the following code with the euro dollar mini chart, the trade does not close when a new lower low forms.

    It simply DOES what you wrote. At line 95 you wrote to exit a LONG trade when a CLOSING price is lower THAN the previous low, not when it makes a lower low!

    #71265 quote
    Vonasi
    Moderator
    Master

    I’ve not really been following this thread but thought I would test the code you have given. I think I have the same section of chart as you and mine works fine.

    [attachment file=71266]

    I do notice a couple of things in your code that are unrelated. You have declared the variable values after they are used in a condition so as code is processed from top to bottom the value in the condition will be zero rather than your desired value:

    bullishs2d = (dojis2d and low[1] <= s2+abstl2d and low[1] >= s2-abst2d and close>high[1] and low>low[1])
    
    abst2d = 8*pipsize
    abstl2d = 2*pipsize

    Also you give a value to a variable at time of market entry and then use it as a condition to set a sell stop which is unnecessary as just being on the market is sufficient conditions to set the sell stop.

    if bullishs2d then
    
    ldbs2d = low[1]-2
    Buy size Contract at Market
    endif
    
    if longonmarket and ldbs2d then
    sell at ldbs2d stop
    endif

    Also you should consider that when a position is opened the Sell Stop will not be set until one bar later as at the time of entry the condition of OnMarket is not being met so you should put the Sell Stop in at the same time as the market entry is made or use a Set Stop Loss at time of entry and then add the Sell Stop one bar later.

    if bullishs2d then
    ldbs2d = low[1]-2
    Buy size Contract at Market
    sell at ldbs2d stop
    endif
     
    if longonmarket and close < low[1] then
    sell at market
    endif
    robertogozzi and cgraubner thanked this post
    Screenshot_2-2.png Screenshot_2-2.png
    #71270 quote
    Vonasi
    Moderator
    Master

    Once again, when I use the following code with the euro dollar mini chart, the trade does not close when a new lower low forms.

    It simply DOES what you wrote. At line 95 you wrote to exit a LONG trade when a CLOSING price is lower THAN the previous low, not when it makes a lower low!

    Yes but in the picture he attached it does not adhere to that rule. The arrowed candle should be the decision to exit.

    [attachment file=71271]

    cgraubner thanked this post
    Screenshot_3-3.png Screenshot_3-3.png
    #71273 quote
    cgraubner
    Participant
    Junior

    Once again, when I use the following code with the euro dollar mini chart, the trade does not close when a new lower low forms.

    It simply DOES what you wrote. At line 95 you wrote to exit a LONG trade when a CLOSING price is lower THAN the previous low, not when it makes a lower low!

    Isn’t that the same?:)

    #71274 quote
    cgraubner
    Participant
    Junior

    I don’t get it why it sometimes works and sometimes it doesn’t work, this is very frustrating:( But apparently it always works with your computers. Maybe I do have to get some updates on my computer or something.

    #71275 quote
    Vonasi
    Moderator
    Master

    Isn’t that the same?:)

    No.

    Decisions are made at the close of a bar and so at that time the low could be lower than the previous bar but the close higher – or both the low and the close could be lower.

    #71276 quote
    Vonasi
    Moderator
    Master

    What spread have you set for the backtest?

    #71277 quote
    cgraubner
    Participant
    Junior

    The spread was 2.

    #71278 quote
    Vonasi
    Moderator
    Master

    The spread was 2.

    OK – that shouldn’t be the issue then.

    I’ve taken the liberty of tidying up your code a little but I cannot explain why it closes the position at the wrong time on your chart. Which broker are you using?

    // EURO DOLLAR MINI 15 min
    DEFPARAM CumulateOrders = false
    DEFPARAM FlatBefore = 000000
    DEFPARAM FlatAfter = 234500
    
    if OpenDayOfWeek = 1 then
    Pivot = (DHigh(2) + DLow(2) + DClose(2)) / 3
    S2 = Pivot - (DHigh(2) - DLow(2))
    endif
     
    if OpenDayOfWeek = 2 or OpenDayOfWeek = 3 or OpenDayOfWeek = 4 or OpenDayOfWeek = 5 then
    Pivot = (DHigh(1) + DLow(1) + DClose(1)) / 3
    S2 = Pivot - (DHigh(1) - DLow(1))
    endif
     
    dojisizes2d = 10
    dojis2d = Range >= ABS(Open[1] - Close[1]) * dojisizes2d
     
    abst2d = 8*pipsize
    abstl2d = 2*pipsize
    size = 4
    
    bullishs2d = (dojis2d and low[1] <= s2+abstl2d and low[1] >= s2-abst2d and close>high[1] and low>low[1])
     
    if bullishs2d then
    ldbs2d = low[1]-2
    Buy size Contract at Market
    sell at ldbs2d stop
    endif
     
    if longonmarket then
    sell at ldbs2d stop
    endif
     
    if longonmarket and (close <low[1]) then
    sell at market
    endif
    
    cgraubner and Gianluca thanked this post
    #71279 quote
    robertogozzi
    Moderator
    Master

    Adding

    GRAPH dojis2d
    GRAPH bullishs2d
    GRAPH ldbs2d
    GRAPH close
    GRAPH low[1]

    helped me to spot that ldbs2d is negative because it subtracts 2 from 1.14793. Try with line 84 replaced by

    ldbs2d = low[1]-2*pipsize

    Now the trade you outlined will end at the closing of the candle with a closing price < low[1] (ProOrder will display a cross above the next bullish candlestick).

    cgraubner thanked this post
    x-4.jpg x-4.jpg
    #71281 quote
    cgraubner
    Participant
    Junior

    This code solved another big mystery I was going to post in here:) Thank you very much!!!

    #71282 quote
    cgraubner
    Participant
    Junior

    The spread was 2.

    Which broker are you using?

    I’m using firefox and I just downloaded a java update, but nothing changed. I will try internet explorer now.

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

Automated trading with Pivot Points and Dojis


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
cgraubner @cgraubner Participant
Summary

This topic contains 84 replies,
has 5 voices, and was last updated by robertogozzi
7 years, 9 months ago.

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