how to code to calculate an average of two inputs

Forums ProRealTime English forum ProOrder support how to code to calculate an average of two inputs

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

    hello, I ask you for help please

    How can the bot recalculate the profit when I do two inputs at differentt price?

     

    that is, after putting a second entry, how can I code so that the bot can calculate the average of both entries leaving the initial stoploss of the first entry and have a positive exit?

     

     

    #194952

    The average price of orders open price is POSITIONPRICE

    So for 2 buy orders, the profit is positive above POSITIONPRICE.

    1 user thanked author for this post.
    #194954

    I explain myself better. The code makes an entry (it is executing a stoploss) if it is placed in the opposite direction to the entry, how can I make it make a second entry and do the average between the first and the second and the operation comes out positive? that without modifying the initial stoploss

    #194958

    Sorry I dont get it 🙂

    1. Do you want to cover your floating loss with an opposite order?
    2. The second order is of the same type of the first one?
    3. When the second order is opened, the first one is still at market or triggered its stoploss already?
    1 user thanked author for this post.
    #194969

    1. Do you want to cover your floating loss with an opposite order? NO

    2. Is the second order of the same type as the first? YES

    3. When the second order is opened, is the first one still in the market or has it already triggered its stoploss? Stay in the market and follow the stop of the initially open position

    I give an example: I buy at 12100 (stop at 12090) and it falls to 12000, increase the position bot (buy again and the stop remains at 12090). Once you have opened the second position take an average of both positions and recalculate a positive exit again.

    #195011

    Ok here is a dummy strategy that simulate that behavior (averaging down the first order only 1 time, and exit if the profit is positive)

     

    1 user thanked author for this post.
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