Ten Minutes to Close Daily Dow
Forums › ProRealTime English forum › ProOrder support › Ten Minutes to Close Daily Dow
- This topic has 7 replies, 3 voices, and was last updated 2 years ago by
SkySurferBlue.
-
-
10/17/2022 at 12:42 PM #202679
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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647DEFPARAM CumulateOrders = FalseIf Time = 205100 ThenAmplitude10 = Range[1]Amplitude11 = Range[2]Amplitude12 = Range[3]Amplitude13 = Range[4]AverageRange = (Amplitude11+Amplitude12 + Amplitude13)/4Endif//At Close of 20h50 candle set the status of the candle as Bull, Bear or DojiIf Time = 205100 and Close[0] > Open[0]+5 thenBull = 1ElseIF Time = 205100 and Open[0]>Close[0]+5 thenBear = 1ElseDoji = 1EndifEndif//Checks if the 20h50 candle has more momentum 20% in this case compared to the previous candles 45min to 49minIf Amplitude10 > AverageRange *1.2 ThenTrigger = 1Endif//Set the time to execute the tradeIf Time > 205459 and Time < 205600 thenExecute =1ElseExecute = 0EndifIF Bull AND Execute And Trigger THENBUY 1 Contract AT MARKETENDIFIF LONGONMARKET AND (BarIndex - TRADEINDEX) = 4 THENSELL 1 share AT MARKETENDIFIF Bear AND Execute and Trigger THENSELLSHORT 1 Contract AT MARKETENDIFIF SHORTONMARKET AND (BarIndex - TRADEINDEX) = 4 THENEXITSHORT AT MARKETENDIFSet Target PProfit 10010/17/2022 at 1:07 PM #20268710/17/2022 at 1:12 PM #202690Your 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.
10/17/2022 at 1:17 PM #202691Yes 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.
10/17/2022 at 1:24 PM #20269210/17/2022 at 1:42 PM #202696Eventually, 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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950DEFPARAM CumulateOrders = FalseIf Time = 205100 ThenAmplitude10 = Range[1]Amplitude11 = Range[2]Amplitude12 = Range[3]Amplitude13 = Range[4]AverageRange = (Amplitude10+Amplitude11+Amplitude12+Amplitude13)/4Endif//At Close of 20h50 candle set the status of the candle as Bull, Bear or DojiIf Time = 205100 thenBull = 0Bear = 0Doji = 0if Close[0] > Open[0]+5 thenBull = 1Elsif Open[0]>Close[0]+5 thenBear = 1ElseDoji = 1EndifEndif//Checks if the 20h50 candle has more momentum 20% in this case compared to the previous candles 45min to 49minIf Amplitude10 > AverageRange *1.2 ThenTrigger = 1Endif//Set the time to execute the tradeIf Time > 205459 and Time < 205600 thenExecute =1ElseExecute = 0EndifIF Bull AND Execute And Trigger THENBUY 1 Contract AT MARKETENDIFIF LONGONMARKET AND (BarIndex - TRADEINDEX) = 4 THENSELL 1 share AT MARKETENDIFIF Bear AND Execute and Trigger THENSELLSHORT 1 Contract AT MARKETENDIFIF SHORTONMARKET AND (BarIndex - TRADEINDEX) = 4 THENEXITSHORT AT MARKETENDIFSet Target PProfit 10010/17/2022 at 1:55 PM #202698You 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.
12345graph bull as "bull"graph bear as "bear"graph doji as "doji"graph Trigger as "Trigger"graph Execute as "Execute"10/17/2022 at 2:35 PM #202704Thank 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 -
AuthorPosts
Find exclusive trading pro-tools on