Code Summation and Stop Loss

Forums ProRealTime English forum ProOrder support Code Summation and Stop Loss

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

    Hello all,

     

    I have 2 questions I’m not able to solve. I thought to have undertood how to use summation but probably something is missing. If I want the condition:

    C=Close<ExponentialAverage[20] and Close[1]<ExponentialAverage[20] and Close[2]<ExponentialAverage[20] and Close[3]<ExponentialAverage[20] and Close[4]<ExponentialAverage[20] and Close[5]<ExponentialAverage[20]

    I want the price to be under EMA 20 for the last 5 candle, why PRT does not give correct to use:  C=Summation [5]((Close<ExponentialAverage[20])=5)

    what is wrong?

    Second question, about stop loss:

    c5= highest[5](high)

    //condizione per entrare Long
    IF NOT longonmarket and my condition then
    BUY 1 CONTRACT AT (c5+0.0001*c5) STOP
    longstoploss = (close – lowest[5](low) + 0.002)/pipsize
    set stop ploss longstoploss

    So when my condition is triggered, I want to buy when price goes over at stop limit at the highest of the last 5 candle, and stop loss at the lowest of the same 5 candles. it works sometimes but more often it opens and close position immediately.

    someone can help me, please?

    thank’s in advance

    Alessio

     

     

    #214355

    why PRT does not give correct to use:  C=Summation [5]((Close<ExponentialAverage[20])=5)

    Are you saying you get a syntax error message?

    Try GRAPH C to see when C does occur over 1oK bars or more?

     

     

    #214356

    more often it opens and close position immediately.

    Have you used GRAPH and Cursor Details on your Conditions to easily see what is happening?

    Also, in my experience, PRT can give odd results when 0.0001 of a value is used?

    Try using  different / higher values to get the code working okay then decrease to what values you really want to use to then see at what value the code stops working correctly?

    #214378

    As to the first question, the code seems correct, try placing parenthesis differently:

    As to the second question, (c5+0.0001*c5) can also be written as (c5*1.0001) and

    can also be written as

    The above examples are intended to only show different ways to achieve the same goal and to use or not conversions. Both original code snippets are correct.

    The issue is usually due to not abiding by the broker’s rule to set pending orders at some distance (which may vary during the day).

    Check if between the current price and your entry price there’s enough distance

     

     

     

    1 user thanked author for this post.
    #214418

    hi Grahal,

    I’ve graphed it and it gives always a line=0

    this is the code:

    now I try to modify just like roberto suggests.

    #214434

    I’ve graphed it and it gives always a line=0

    Try below and you will get C7 = True on many occasions (DJI, 1 min TF over 1200K bars).

    Your code is good, but Condition C7 does not occur 5 times in 5 bars etc?

     

     

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