placing an order when predefined levels achieved.

Forums ProRealTime English forum ProScreener support placing an order when predefined levels achieved.

Viewing 15 posts - 1 through 15 (of 20 total)
  • #169015

    Hi

    If you look at the attached I need to know how to code this example.

    lets assume CURRENT  price is ABOVE level A and B.

    Price needs to achieve a price less than A but not less than B (a -10 pips) , then place an order to BUY when the 9 EMA crosses 26 EMA .

    If price achieves level B (a -10 pips) then no order is placed for the EMA cross over .

    Is this possible?

    Obviously if you could elaborate  on the reverse example , i.e placing a code when the current price is lower than a fictions level A and B (which are higher levels)  and the code would place a sell order for a EMA cross under.

     

    Many thanks.

    #169030

    There you go:

     

    #169031

    At lines 15 and 20 you can change the way to calculate the A-B range. I used the lowest and the highest prices within the last P bars.

     

     

    #169055

    Thank you Roberto ,

     

    so just to clarify if i wanted a level broken below for a buy at 2100 i would amend line 15 to :

    Long  A = 2100

    and if I wanted a level broken above for a sell at 3800 i would amend line 20 to :

    Short A = 3800.

     

    so would i still need line 2 P= 4 ? As not sure how that relates…..

     

    and assuming a long trade ie trigger level is 2100 (market is dropping and looking for reversal) ( but not 10 pips lower ) and entry is a 9/26 cross over , if the 926 cross over happens outside the range of 2100-2090 which is very likely the entry will still work  as 2100 was achieved 2090 was not (which invalidates the trade) – it then retraces to more than 2100 to cross over 926 (ie reversal happened) for example 2120 and then enters the trade as the 926 crosses over for a buy ?

    The code will cope with this ?

     

     

    Many thanks for clarification.

    #169056

    You don’t need line 2 anymore as it was only used by HIGHEST and LOWEST.

    As to your question “and assuming a long trade ie trigger level is 2100 (market is dropping and looking for reversal) ( but not 10 pips lower ) and entry is a 9/26 cross over , if the 926 cross over happens outside the range of 2100-2090 which is very likely the entry will still work as 2100 was achieved 2090 was not (which invalidates the trade) – it then retraces to more than 2100 to cross over 926 (ie reversal happened) for example 2120 and then enters the trade as the 926 crosses over for a buy ?“, it already entered a LONG trade, do you want to accumulate another position if the same 2100 level is crossed over again?

     

     

    #169057

    Hi roberto

     

    No did not want to enter again – was just clarifying that once it hits the initial trigger of 2100 it places an order for a 926 cross over , and even if this 926 does not happen for a while it will maintain that order until its complete or becomes invalid if subsequently price  crosses line B (+-10 depending on direction ) ?

    #169073

    Yes, that’s exactly what it’s doing now.

    It is either triggered or invalidated.

     

    #169254

    Hi Roberto

     

    Code looks fantastic but a problem …..

    I ran the code this morning on the FTSE – so i amended line 20 to read SHORT A = 7154 removed the line 2 P reference and just set LONG A = 0

    I loaded the code up at 0900 am and it triggered on the 926 cross under (2 minutes) but it should not have as SHORT A was never reached at 7154.

    It had previously hit 7154 earlier but even if this is the error and it noted the level was hit before the code was activated it should have been an invalid trade as it breached 10 pips higher at 7164 ?

     

    Am i missing something ?

     

    attached screen shot and actual code used on the FTSE this morning on 2 minutes timeframe .

     

    #169260

    Ok, I modified it so that it starts ONLY when you run it, ignoring whatever happened before:

     

    #169361

    Hi Roberto

     

    great seems to have fixed that , but code seems to be ignoring line 4 ONCE PIPS = 5 x PIPSIZE, and line 35 LONGB = LONG A – PIPS

    so long A is trigger point to look for a 926 cross over on 2 minutes , but if LONG B is hit no trade should action for the day .

    In the attached example it entered at the 926 cross over great ! but it ignored the fact LINE B was breached by a lot , and as I read the code line B was 5 pips below line A as soon as this is hit no 926 should be looked for and trade is invalid for the day ?

    attached is a back test but it performed exactly the same in real time yesterday ?

     

    attached code which has a flag statement added but that’s it. what am I missing ?

    Thanks for your help.

    #169422

    It’s not ignoring any lines.

    It enters AFTER a crossover has occurred at the closing of the candle (and prior to that, price had sit in the range a-B).

     

    #169432

    Hi Roberto

    maybe I didn’t explain it correctly .

    level A triggers looking for an EMA cross over .

    if BEFORE this cross over occurs it breaches level B Then the trade is invalid and no trade must occur .

    you can clearly see from the screen shot that code is placed live then level A is hit  then level B is breached before an EMA cross over so no trade should happen .

    You are correct the cross over is in the range a-b but that should be irrelevant – the cross over CAN occur even above level A if price retraces after hitting level A as long as level B is not breached before the ema cross over.

    The key is AFTER the code is activated – the first action is level A must be hit – this activates looking for the ema cross over .

    if level b is breached BEFORE the ema cross over the trade is cancelled for the day . this is very important as it can retrace which is what it did in the screen shot – but the trade is no longer valid .

    you will see from the screen shot – level B was breached after level A was hit and before the ema cross over  therefore it should not trade .

    In the screenshot it did subsequently retrace and crossed over on the ema and traded but it should not as level B was breached before the ema cross over so it must cancel the trade / deactivate the code . Once level B is breached it should stop looking for a trade or any ema cross over .

    it’s probably easier to look at the possible options

    …………………………………………………………..,,
    The possible option are ONLY  2 .

    price is falling so this is the sequence of events in order :

    OPTION 1

    1.level A is hit

    2.it starts to look for ema cross over

    3.ema cross over happens a trade is placed – this cross over can be at ANY level below A OR above A but NOT  below B ( note the cross over can happen at ANY level >B and <or > A AFTER level A is activated FIRST triggering it looking for this ema cross over – which is step 1 above   )

    (B)

    1. level A hit

    2.it starts to look for ema cross over

    3.no ema cross over happens

    4.level B hit so trade/code cancelled . It no longer looks for any cross over or any trade the breach of level B basically turns the code off .

    obviously the reverse for a sell.

    does that help explain it better by looking at the only 2 possible sequences of events ?

     

     

    #169452

    I could find the glitch.

    I had forgotten to disable trading for the day on a levelB breach. Now as breach occurs, trading will be disabled (for the chosen direction) for the day and willbe resumed at the start of the new day (when IntraDayBarIndex = 0).

    I also added comments where you can replace CLOSE with LOW (for Long trades) or HIGH (for Short trades), if you want to use, as price trigger before the crossover, just a “touch” of the price, rather than the closing price.

    1 user thanked author for this post.
    #169455

    You may have seen an email about a post that I almost immediately deleted because it was not a working correction.

     

    #169462

    Many many thanks Roberto , I will test it today.

Viewing 15 posts - 1 through 15 (of 20 total)

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