Ten Minutes to Close Daily Dow

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #202679 quote
    SkySurferBlue
    Participant
    New

    Hi I have been coding the following strategy to read the 10th last 1min candle of the Real Trading Hours in the Dow and to then take a scalp trade to the close if that candle also shows more Momentum than its preceding candles.

    However my code did not result in a long trade on Friday as I expected it to. SO it seems my code is not successful in classifying the 20h50 (UK Time candle) as a Bull candle.

    Can someone please assist me with what I am doing wrong?

    Here is the code

    DEFPARAM CumulateOrders = False
    
    If Time = 205100  Then
    Amplitude10 = Range[1]
    Amplitude11 = Range[2]
    Amplitude12 = Range[3]
    Amplitude13 = Range[4]
    AverageRange = (Amplitude11+Amplitude12 + Amplitude13)/4
    Endif
    
    //At Close of 20h50 candle set the status of the candle as Bull, Bear or Doji
    If Time = 205100 and Close[0] > Open[0]+5 then
    Bull = 1
    Else
    IF Time = 205100 and Open[0]>Close[0]+5 then
    Bear = 1
    Else 
    Doji = 1
    Endif
    Endif
    
    //Checks if the 20h50 candle has more momentum 20% in this case compared to the previous candles 45min to 49min
    If Amplitude10 > AverageRange *1.2 Then
    Trigger = 1
    Endif
    
    //Set the time to execute the trade
    If Time > 205459 and Time < 205600 then
    Execute =1
    Else
     Execute = 0
    Endif
    
    IF Bull AND Execute And Trigger THEN
    BUY 1 Contract AT MARKET
    ENDIF
    IF LONGONMARKET AND (BarIndex - TRADEINDEX) = 4 THEN
    SELL 1 share AT MARKET
    ENDIF
    IF Bear AND Execute and Trigger THEN
    SELLSHORT 1 Contract AT MARKET
    ENDIF
    IF SHORTONMARKET AND (BarIndex - TRADEINDEX) = 4 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    Set Target PProfit 100
    Dow-20221014-20h50.jpg Dow-20221014-20h50.jpg
    #202687 quote
    GraHal
    Participant
    Master

    Are you running on a 1 min (or less) Timeframe?  You need to to detect a Time of 205100.

    #202690 quote
    JC_Bywan
    Moderator
    Master

    Your average range in line 8 doesn’t feel right, you probably forgot amplitude10 in it because you divide by 4 (or if you did want just these 3 values used then the /4 would be /3 ). It subsequently impacts lines 23 and 24 to have trigger true or not, which impacts lines 34 and 35 for a long trade.

    #202691 quote
    SkySurferBlue
    Participant
    New

    Yes I am running on 1minute and the reading of the candle was set to 205100 as you recommended but it traded short instead of long.

    #202692 quote
    JC_Bywan
    Moderator
    Master

    Also, you never set doji, bull and bear to zero, so if they have been true once in history, then remain true ever after, instead of “becoming” true only at relevant 205100’s, so impacts on lines 34 and 40

    #202696 quote
    JC_Bywan
    Moderator
    Master

    Eventually, even if averagerange is fixed and bear, bull, doji are reset to 0 each day, the trade for friday should remain short as if I read the relevant candle from my timezone, open is 29663.7 and close is lower by more than 5 at 29649.2, so bear=1 bull=0 for it.

    Edit: doh, read the wrong candle, forget text striked through

    DEFPARAM CumulateOrders = False
    
    If Time = 205100 Then
    Amplitude10 = Range[1]
    Amplitude11 = Range[2]
    Amplitude12 = Range[3]
    Amplitude13 = Range[4]
    AverageRange = (Amplitude10+Amplitude11+Amplitude12+Amplitude13)/4
    Endif
    
    //At Close of 20h50 candle set the status of the candle as Bull, Bear or Doji
    If Time = 205100 then
    Bull = 0
    Bear = 0
    Doji = 0
    if Close[0] > Open[0]+5 then
    Bull = 1
    Elsif Open[0]>Close[0]+5 then
    Bear = 1
    Else
    Doji = 1
    Endif
    Endif
    
    //Checks if the 20h50 candle has more momentum 20% in this case compared to the previous candles 45min to 49min
    If Amplitude10 > AverageRange *1.2 Then
    Trigger = 1
    Endif
    
    //Set the time to execute the trade
    If Time > 205459 and Time < 205600 then
    Execute =1
    Else
    Execute = 0
    Endif
    
    IF Bull AND Execute And Trigger THEN
    BUY 1 Contract AT MARKET
    ENDIF
    IF LONGONMARKET AND (BarIndex - TRADEINDEX) = 4 THEN
    SELL 1 share AT MARKET
    ENDIF
    IF Bear AND Execute and Trigger THEN
    SELLSHORT 1 Contract AT MARKET
    ENDIF
    IF SHORTONMARKET AND (BarIndex - TRADEINDEX) = 4 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    Set Target PProfit 100
    #202698 quote
    JC_Bywan
    Moderator
    Master

    You can use the graph command added at end of code to see what’s going on in more details, and reading (this time) the right candle translated into my timezone, it seems “trigger” is the one not true for friday night preventing the trade.

    graph bull as "bull"
    graph bear as "bear"
    graph doji as "doji"
    graph Trigger as "Trigger"
    graph Execute as "Execute"
    #202704 quote
    SkySurferBlue
    Participant
    New

    Thank you very much.

    It is working now except for the average error. I have corrected this now to below. I will run it for a bit and see if it is robust.

    Good learning for me and thank you again for taking the time to help and teach me a bit more functions.

    If Time = 205100 Then
    Amplitude10 = Range[0]
    Amplitude11 = Range[1]
    Amplitude12 = Range[2]
    Amplitude13 = Range[3]
    Amplitude14 = Range[4]
    AverageRange = (Amplitude14+Amplitude11+Amplitude12+Amplitude13)/4

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

Ten Minutes to Close Daily Dow


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/17/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...