Only one entry

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

    Hello. Say I want to go long when a>b AND c>d. When both conditions are true I want only ONE entry which stops when take profit or stoploss is hit (or condition changes).
    Problem is: when profit or loss is hit the system goes long AGAIN on the next candle since still a>b AND c>d. I have been suggested to stop this by setting Trend=0 when in position, but I can’t get a code wright for “position means Trend=0”. Also ONMARKET or NOTONMARKET are suggested, but I do not find these in the syntax, I get no results when using these words in the code.
    For example, I tried this code but the part “AND Trend=0” is rejected….
    (sorry for the Dutch in the code 🙂 )

     

    #201448

    You cannot use conditions, nor instructuons, on the same line as BUY, SELL, SELLSHORT and EXITSHORT. Wrirte them on a separate line.
    Moreover, you do not need to exit an open position for a Stop & Reverse, simply execute the contrary instruction. BUY will close any open short postition, then start a LONG one, the other way round for SELLSHORT.

    #201464

    OK Roberto, I understand the exit Long and exit short was not needed. Also I see you just simply put “Trend=0”. To me that is interesting, I was struggeling with conditions etc.

    But, sorry, I have to inform you that this solution is not working. The system still trades on EVERY candle. When I leave “Trend=0” out of the code, the result is exactly the same… also on every candle.

    #201477

    When do you want to restart trading AFTER one entry?

     

    #201490

    Hello Roberto. I want to go long (only once) when RSI >50 AND MACD reaches >50. Then the trade will run until a) RSI <50 OR b) MACD < 0 (this is now not in the code, but is just to give you the whole idea) OR b) stoploss is hit OR c) profit is hit. After this I only want to trade again when there is a NEW situation, a NEW opportunity:  RSI<50 and MACD<0 or a NEW situation where RSI>50 and MACD>0 again.
    I do not know if it is possible to code such a thing. I think ONMARKET/NOTONMARKET will not work because once the stop or te profit is hit the system will conclude: NOTONMARKET and immediately trade again…   Maybe something must de done with Trend = nr a+1 ? Thank you.

    #201505

    There you go:

    1 user thanked author for this post.
    #202781

    Thanks Roberto, this is really great!! I was looking for this for a longtime. (Sorry for late reaction, somehow I did not see the email). It is a simple code. I am even able to understand it!
    I have only one question: is the variable LastTrade something you made up (can one write Apple instead?)  or is it  Syntax? If so – it is not in my syntax….
    Thanks!

    #202812

    It’s not a keyword, so you can name it as best suits you, be itApple, Cat or A3. They cannot start with a digit and cannot have blanks and special characters embedded, though.

     

     

    #202828

    OK Clear Roberto. By the way: the line with Once is not necessary…

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