not taking any more trade in one direction until another condition is met?

Forums ProRealTime English forum ProOrder support not taking any more trade in one direction until another condition is met?

Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • #158013

    Hello

    When a condition is met, how to prevent his algo from not taking any more trade in one direction until another condition is met?

    I have an algo that takes trades (buy and sell) with different filters and a trigger on a TF15min, so :

    IF the daily RSI is > 70 and indicates a bearish divergence …
    The algo must not take any more buy (but it can sell) AS SOON AS …
    The daily RSI is > 30

    The difficulty is that when the bearish divergence is no longer active the algo resumes buy trades.
    During and after the divergence, how to prevent it from taking buy trades as long as the RSI is above 30?

    #158015

    Usually a divergence is detected once, not every bar, so it shouldn’t be true for more than one bar!

    Post an example, your description is not clear enough. AS SOON AS doesn’t help much.

     

    #158016

    Hello @robertogozzi, here is an example:
    1. At 1:45 pm, the indicator PRC_AnotherRSIdivergence signals by a red bar a bearish divergence.
    2. From this signal, I want my robot to stop buying as long as the RSI is > 30 (but the robot can sellBut the robot must be able to sell if there is a sell signal)

    In the image you can see the gray area between the beginning of the signal and the moment when the RSI is < 30. If it can be useful I attach the code of the indicator:

    #158021

    Your post is not clear enough and you posted the indicator, instead of the code of the strategy.

    As you can see from your pic:

    • the bearish divergence only lasts one bar, why buying the next bars?
    • it’s a bearish divergence, why buying instead of going short?
    • what has RSI (< 30 or > 30? your two posts have two different operators) to do exactly with the divergence?

    Post the code of your strategy.

     

    #158022

    DO NOT use @ to reference me, I know, it’s just the two of us!

    Use that sign with care and only when there are many people involved.

    Thank you 🙂

     

    #158026

    Ok, I’ll try to explain again:

    – The goal is to create a filter that prevents taking purchases on a smaller TF (15min) as long as there is a downward divergence on a larger TF (daily).

    – This filter will be used in different strategies, so there is no specific strategy, but there is a specific filter:
    .
    – This filter is :
    1. If bearish divergence detected by the indicator PRC_AnotherRSIdivergence (on TF daily)
    2. THEN do not take any more purchase (on TF 15min) AS…
    3. the daily RSI is higher than > 30 (so yes, we will resume purchases when the RSI is lower than 30, it’s logical 😉 )

    For example :

    First picture: filter on large time frame that starts with the report of the downward divergence and ends when the RSI is < 30. Second picture : on a small time frame, the purpose of this filter is to prevent the robot to take the purchases (signal with green arrows) while letting it take the sales (signal with red candles). If you need an example of strategy to code the filter with (I don't use this strategy but it's to have a simple example) :

    #158059

    Ok, you don’t like working examples, so I will post some general suggestions.

    Use a flag (a variable that signals something), in this case TRADEON, which defaults to 1, then is cleared whenever a trade is entered, until the next day or a different divergence occurs. This willmake your 15-minute TF tp enter only once per divergence.

    You can also use BullishDiv and BearishDiv to not enter a trade the opposite direction.

     

    1 user thanked author for this post.
    #158072

    Thank you for your suggestions, they help me understand the process.

    I have coded an algo that uses the purchase conditions of the example above (I have removed the sales to simplify) in TF 15min.

    I added a condition to prevent new trades from being taken, as soon as a bearish divergence is detected (on a TF H1) and until the RSI is below 30 (also on a TF H1).

    But as you can see in the pictures, the robot takes trades in the gray areas, but it shouldn’t take any.

    Can you tell me the mistakes I made in the code?

    #158076

    Add AND TradeON to line 36:

     

    1 user thanked author for this post.
    #158085

    Thank you very much for your help!
    I added TradeON to line 36, and as you can see, there are no more trades in the gray areas.
    I will create new filters and improve my algorithms with your suggestions. Have a nice day 🙂

    1 user thanked author for this post.
Viewing 10 posts - 1 through 10 (of 10 total)

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