US Crude – 1st Day of month

Forums ProRealTime English forum ProOrder support US Crude – 1st Day of month

Viewing 6 posts - 1 through 6 (of 6 total)
  • #89977

    Hi,

    I’m coding a strategy that places two orders on the system based on the value of US crude on the first day of the month. Both can trigger but one is cancelled if the other hits target. The problem I’ve got is that I end up with multiple orders if a trade triggers and hits stop within the same candle. I know there is most probably a simple answer but I’m struggling to see it at the moment….

    Lisa

     

    #89979

    You have to save your STRATEGYPROFIT so that when not OnMarket you can check if it’s different from the previous bar. If is is because a trade was triggered and close in ust one bar.

    You can then check TradeTriggered to take any action you need to take.

    It could be foolished in the very unlikely case a trade is triggered and yields 0.

     

    1 user thanked author for this post.
    #90004

    There is no simple answer. In fact, since the code is only read one time at Close, you cannot interact in the bar to “delete” the other pending order. Bear in mind, that pending orders can’t be canceled, they expire after 1 bar and we need to set them continuously if we want them to still be present.

    So in order to not set them if an order has triggered within the current bar, the best way to do is to use a lower timeframe (with the ease of the TIMEFRAME instruction) to make a simple ‘IF ONMARKET’ test.

    1 user thanked author for this post.
    #90017

    Thank you both; I’ve come up with this version that now checks to see if the last trade was long or short as well as using the strategy profit 🙂 The only times it doesn’t quite work is if the long and short trades are both triggered and hit stop in the same candle…..

    What I think I’ll work on next is to run this on an hourly timeframe so I can check for the trades a bit more accurately and then use the timeframe(daily) to set the levels of the orders and check for the first trading day of the month. Last time I tried using the multiple timeframes I found it worked on my demo account but not on my live account (it wasn’t yet available for live accounts)

     

    #90020

    I’ve not looked closely at your code but why not split the code into two strategies – a long one and a short one?

    I think if you request to have MTF turned on on your live account then it can be done – but do bear in mind that it is still in beta testing which is why everyone does not have it yet!

    #90028

    I did think of that but I need to know if either trade has hit target and then stop the order for the other trade being placed…. the basic rules are :

    Oil Trades

    Daily Chart
    First trading day of the month (Mon-Fri)
    Find the low and high of the day and calculate the daily range

    Stop = ½ range
    Target = range

    Long order 5 pips above the high
    Short order 5 pips below the low

    Cancel 2ndorder when profit is hit on the first order.

    I’ll continue with the code and when I’m happy that it’s working on demo I’ll ask to have MTF switched on 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login