50 Pips A Day Forex

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #96168 quote
    therookie
    Participant
    Junior

    Hi guys!

    So I am pretty new to coding but I’m trying to learn. I have read about a very simple trading strategy with Forex which I have a hard time writing down in code as it doesn’t involve any indicators.

    The link to the strategy can be found here: https://forextradingstrategies4u.com/50-pips-a-day-forex-trading-strategy/.

    I assume it is a pretty easy code to write if you know what you are doing and I hope someone here could help me to code it for backtesting in ProBacktest.

    TRADING RULES OF THE 50 PIPS A DAY SYSTEM

    1. As soon as the 7 a.m. GMT candlestick closes, you have to place two opposite pending orders:  a buy stop order 2 pips above the high and and sell stop order 2 pips below the low of the 7 am GMT candlestick.
    2. When price activates one of the pending orders, you cancel the other pending order that has not been activated.
    3. You must place a stop-loss order anywhere from 5-10 pips pips above the high/low of the 7 a.m. GMT candlestick after it closes(or has formed) to control your trading risk. If you notice that the 7 a.m. GMT candlestick is too short and that placing the stop loss will be too close to the entry price, then increase your stop loss distance to anywhere from 15-20 pips.
    4. Set your profit target to 50 pips
    5. Once you have entered the trade, let the market do its thing.
    6. If your trade reaches it profit target for the day then awesome! Repeat the same process tomorrow.
    7. If you trade has a floating profit or a floating loss, wait until the end of the day and exit your trade, regardless of if you have a profit or loss.
    50-Pips-A-Day-Forex-Trading-Strategy.png 50-Pips-A-Day-Forex-Trading-Strategy.png
    #96178 quote
    Vonasi
    Moderator
    Master

    Welcome to the forums.

    Not really easy – but possible. From a quick read of the rules it is clear that to place two pending orders on the market and then cancel one if the other is hit that we would need to use multi time frame in the strategy. 1 hour to make the decisions and a fast time frame like maybe 1 second to cancel the other order very quickly. Due to the fast time frame needed available data in PRT for back testing will be very limited.

    The rules are not very precise. They say ‘If you notice that the 7 a.m. GMT candlestick is too short and that placing the stop loss will be too close to the entry price, then increase your stop loss distance to anywhere from 15-20 pips’ but do not specify what ‘too short’ actually is.

    They also say ‘If you trade has a floating profit or a floating loss, wait until the end of the day and exit your trade, regardless of if you have a profit or loss’ but do not clarify what ‘end of the day’ actually means. End of the US session, End of the UK session. Midnight. If midnight then you will be paying (or possibly receiving) overnight fees at 2200 and then closing the trade two hours later when spread is at its largest. The image shown seems to indicate that you hold for 24 hours.

    Sometimes these simple ‘make 50 pips in a day’ type strategies can be very poorly described and so leave the coder somewhat guessing!

    therookie thanked this post
    #96179 quote
    Vonasi
    Moderator
    Master

    The description also says ‘Our main goal for our trading day is to capture 1/3 – 1/2 of the daily trading range of the currency pair of choice’ and also says that you can use it on any forex pair but then specifies a 50 pip take profit. Different pairs move in different ways and have different daily ranges. 50 pips will not suit all forex pairs.

    #96215 quote
    therookie
    Participant
    Junior

    Thank you for your reply Vonasi. Very helpful!

    As you can see I am a beginner and when you describe it like that it makes sense that it is hard to automate trading for a strategy that don’t have very clear set rules. I guess these types of strategies fit manual trading better. But if you set you own clear rules it shouldn’t be impossible to write a code right? I mean even if I want to trade the strategy manually I assume I should back test it first so I get an idea if it’s even worth pursuing this trading strategy.

    I am actually interested in using multi time frame in the strategy as the ”one order cancels the other” type of order is something I want to experiment with. Is it very difficult to write that type of code?

    How would we write code with more precise rules, for example:

    1. As soon as the 7 a.m. GMT candlestick closes, place two opposite pending orders:  a buy stop order 2 pips above the high and and sell stop order 2 pips below the low of the 7 am GMT candlestick. When price activates one of the pending orders, you cancel the other pending order that has not been activated. – This is where the multi time frame comes in I assume
    2. A stop-loss order should be placed 5 pips above the high/low of the 7 a.m. GMT candlestick.
    3. The target profit should be set to 50 pips – if this is reached then close your position.
    4. If you have an open position (or a pending order) still open at 3 p.m. GMT then close the open position/cancel the pending orders.

    Any help would be greatly appreciated!

    #96220 quote
    GraHal
    Participant
    Master

    When price activates one of the pending orders, you cancel the other pending order that has not been activated.

    Would use of If NotonMarket in front of both Orers achieve above … so only one Order would execute ?

    #96237 quote
    Vonasi
    Moderator
    Master

    Would use of If NotonMarket in front of both Orers achieve above … so only one Order would execute ?

    Not with pending orders. Say for example you have a buy above the last high and a sellshort below the last low on a daily candle. You send the two pending orders to the market at the open of the next day and the long one gets hit. You cannot cancel the short one or know that you are onmarket until the daily candle has closed and in this time price could move down and trigger the short order too. By placing the orders every second you can check every second whether you are on market and so stop placing orders.

    GraHal thanked this post
    #96246 quote
    Vonasi
    Moderator
    Master

    Here is a first quick go at it. This version actually doesn’t use MTF and in backtesting does not ever open a long and a short at the same time. I am trying to get clarification as to whether if you use two pending orders and DEFPARAM CUMULATEORDERS = FALSE together then three orders get sent to your broker – one long one short and one to cancel any orders if one is hit. Either way it works in back testing at the moment on a 1 hour chart.

    There are three variables:

    SL = the initial stop loss added or subtracted from the 0700 high and low.

    ShortCandle = the definition of a short candle. I have just used when the range is less than the average range of the last 200 candles but you can set it to anything – a quantity of pips or a percentage of ATR or whatever.

    ExtraSL = The extra stop loss distance used when a short candle is detected.

    defparam cumulateorders = false
    
    sl = 15 //10 to 15
    shortcandle = range < average[200](range)
    extrasl = 20 //15 to 20
    
    if opentime = 070000 then
    sell at market
    exitshort at market
    longentryprice = high + 2
    shortentryprice = low - 2
    longstopprice = low - sl
    shortstopprice = high + sl
    if range < shortcandle then
    longstopprice = low - sl - extrasl
    shortstopprice = high + sl + extrasl
    endif
    tradeon = 0
    endif
    
    if not onmarket and tradeon = 0 then
    buy 1 contract at longentryprice stop
    sellshort 1 contract at shortentryprice stop
    sell at longstopprice stop
    exitshort at shortstopprice stop
    endif
    
    if longonmarket then
    tradeon = 1
    set stop ploss tradeprice - longstopprice
    endif
    
    if shortonmarket then
    tradeon = 1
    set stop ploss shortstopprice - tradeprice
    endif
    
    set target pprofit 50
    

    STOP PRESS! While posting this I had clarification that in real life this version of the strategy will not behave like it does in the back test. I will re-code it as MTF. Whatever you do do not put this strategy live as you will end up with a long and a short on the market at the same time!

    #96249 quote
    therookie
    Participant
    Junior

    You’re awesome. Thank you for the warning not to go live with it. May I ask what MTF stands for?

    #96250 quote
    Vonasi
    Moderator
    Master

    MTF = multi time frame.

    Here is a MTF version that can be run on a 1 second chart.

    It seems that my first code can be used to backtest on more data on a 1 hour chart and so see how the strategy might perform. The MTF version is the correct one for live trading but I still wouldn’t go live with it!

    Images from EURUSD.

    defparam cumulateorders = false
    
    timeframe (hourly,updateonclose)
    sl = 15 //10 to 15
    shortcandle = range < average[200](range)
    extrasl = 20 //15 to 20
    
    if opentime = 070000 then
    longentryprice = high + 2
    shortentryprice = low - 2
    longstopprice = low - sl
    shortstopprice = high + sl
    if range < shortcandle then
    longstopprice = low - sl - extrasl
    shortstopprice = high + sl + extrasl
    endif
    endif
    
    timeframe (1 second)
    once tradeon = 1
    
    if opentime = 075959 then
    sell at market
    exitshort at market
    tradeon = 0
    endif
    
    if not onmarket and tradeon = 0 then
    buy 1 contract at longentryprice stop
    sellshort 1 contract at shortentryprice stop
    sell at longstopprice stop
    exitshort at shortstopprice stop
    endif
    
    if longonmarket then
    tradeon = 1
    set stop ploss tradeprice - longstopprice
    endif
    
    if shortonmarket then
    tradeon = 1
    set stop ploss shortstopprice - tradeprice
    endif
    
    set target pprofit 50
    
    //graphonprice longentryprice
    //graphonprice shortentryprice
    
    Screenshot_1-hour.png Screenshot_1-hour.png Screenshot_1-second.png Screenshot_1-second.png
    #96253 quote
    therookie
    Participant
    Junior

    Thank you so much. I will read and try to understand this code later during the day and I will of course only run it on a demo account before I ever try to run it on a live account.

    #96254 quote
    Vonasi
    Moderator
    Master

    I have just noticed that if there is not a candle on the 1 second chart at 075959 then the conditions will not be met to exit trades and reset the tradeon variable. This is a pain. I will have a think about it.

    #96256 quote
    therookie
    Participant
    Junior

    I didn’t know it would be so hard to put the strategy down in code as it’s simple when described in plain English and I am definitely way over my head in trying to code this.

    Your help is much appreciated though and I am learning a lot by just reading your codes.

    Thank you!

    #96257 quote
    Vonasi
    Moderator
    Master

    My first solution is to change line 22 to:

    if opentime >= 075900 and opentime < 080000 then

     

    This way you only need one  1 second candle to be present in the last minute before 0800 for the conditions to be met. If you want you can reduce the time window but the shorter it is the bigger the chance of there being no candles and you being left with trades still on the market.

    Not perfect but it puts the train back on the track (as Nicolas would say!)

    #96258 quote
    Vonasi
    Moderator
    Master

    Not quite back on track as now we have multiple trades opening after 0759. I’ll work on it and post a new code!

    therookie thanked this post
    #96260 quote
    Vonasi
    Moderator
    Master

    Hopefully this is it! I just needed to make our exit minute after 0800 rather than before.

    defparam cumulateorders = false
    
    timeframe (hourly, updateonclose)
    sl = 15 //10 to 15
    shortcandle = range < average[200](range)
    extrasl = 20 //15 to 20
    
    if opentime = 070000 then
    longentryprice = high + 2
    shortentryprice = low - 2
    longstopprice = low - sl
    shortstopprice = high + sl
    if range < shortcandle then
    longstopprice = low - sl - extrasl
    shortstopprice = high + sl + extrasl
    endif
    endif
    
    timeframe (1 second)
    
    once tradeon = 1
    
    if opentime >= 080000 and opentime < 080100 then
    sell at market
    exitshort at market
    tradeon = 0
    endif
    
    if not onmarket and tradeon = 0 then
    buy 1 contract at longentryprice stop
    sellshort 1 contract at shortentryprice stop
    sell at longstopprice stop
    exitshort at shortstopprice stop
    endif
    
    if longonmarket then
    tradeon = 1
    set stop ploss tradeprice - longstopprice
    endif
    
    if shortonmarket then
    tradeon = 1
    set stop ploss shortstopprice - tradeprice
    endif
    
    set target pprofit 50
    
    //graphonprice longentryprice
    //graphonprice shortentryprice
    
Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

50 Pips A Day Forex


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
therookie @prophet85 Participant
Summary

This topic contains 20 replies,
has 3 voices, and was last updated by therookie
6 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/11/2019
Status: Active
Attachments: 5 files
Logo Logo
Loading...