TAKE PROFIT when 2 EMA crosses

Forums ProRealTime English forum ProOrder support TAKE PROFIT when 2 EMA crosses

Viewing 9 posts - 1 through 9 (of 9 total)
  • #182355

    Hi everyone, I’m new with coding and I would appreciate your support.

    I have defined a rule to buy/sell based on some conditions:

    IF NOT LongOnMarket and plage and condition1 THEN
    BUY 1 CONTRACTS AT MARKET

    ENDIF

    I would like to add that Take Profit will be done as soon as 2 EMAs are crossing under

    AND

    I would like to define the Stop Loss at the most recent Lowest price

     

    Could you help ?

    Thanks a lot,

    Patrice.

    #182363

    For the SL, the most recent low is that of the current bar, when the strategy places the opening order of an operation:

    TP can be detected at this bearish crossover:

     

    #182367

    Thanks. I have tried the following but it is not behaving at all as expected.

    Instead of Average I would like as well to work with exponential average.

    Here is the code I used which is not working correctly:

    // Conditions pour ouvrir une position acheteuse
    IF NOT LongOnMarket and condition THEN
    BUY 1 CONTRACTS AT MARKET
    IF average[8](close) CROSSES UNDER average[20](close) THEN
    SELL AT MARKET
    ENDIF
    ENDIF

    // Conditions pour ouvrir une position en vente à découvert
    IF NOT ShortOnMarket and condition THEN
    SELL 1 CONTRACTS AT MARKET
    IF average[8](close) CROSSES OVER average[20](close) THEN
    BUY AT MARKET
    ENDIF
    ENDIF

     

    Thanks a lot for your help

    #182368

    this will give you EMA

    #182369
    JS

    EMA => Average[8,1](Close) or Average[20,1](Close)

    For short positions use SellShort instead of Sell

    Sell will only close a long (Buy) position

    Buy versus Sell

    SellShort versus ExitShort

    #182371

    Thanks to all working fine now 🙂

    #182636

    Hi

    I have still an issue with my code. The code enter the market according to the condition defined. no problem.

    Stop loss is ok but Target profit is not taken based on the condition. Could you help ? Many thanks

    indicateur2= ExponentialAverage[20](close)

    indicateur5= ExponentialAverage[8](close)

    c9short= (indicateur5 < indicateur2)

    // Conditions pour ouvrir une position acheteuse
    IF NOT LongOnMarket and plage and c1long and c1longbis and c1longtiers and c4long and c8long and c9long and c10long THEN
    BUY 1 CONTRACTS AT MARKET
    SET STOP LOSS 20
    IF c9short THEN
    SELL 1 CONTRACTS AT MARKET
    ENDIF
    ENDIF

    Thanks again

    #182640

    Move the last ENDIF to immediately BEFORE IF c9short THEN.

    #182642

    many thanks 🙂

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

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