Positionprofit(1) < 400 or marketposition(1) = 1 or barssinceexit(1) > 100

Discussion in 'Strategy Building' started by travis, Jan 9, 2004.

  1. travis


    If Positionprofit(1) < 400 or marketposition(1) = 1 or barssinceexit(1) > 100

    Then...(trade long)

    This should be the code to say to my system to only trade long if one of these three conditions happen. Either the profit of the previous trade was less than 400 points, or the previous trade had a big gain, but it was long trade, or (if it was not) 100 bars have passed since that trade.

    And yet it doesn't work. Can anyone help me with this?
  2. abogdan


    If (Positionprofit(1) < 400) or (marketposition(1) = 1 and Positionprofit(1) >= 400) or (barssinceexit(1) > 100 and marketposition(1) <> 1) Then Begin

    Buy Next Bar on Open;

  3. travis


    Thank you, but this code you just gave me returns identical results as the previous one I was using, and it makes sense logically that it would. However, thanks and please suggest me something else.

    This code here:

    (Positionprofit(1) < c * Pr_Profit)
    or (Positionprofit(1) >= c * Pr_Profit and marketposition(1) = 1)
    or (Positionprofit(1) >= c * Pr_Profit and marketposition(1) <> 1 and barssinceexit(1) > Bars_to_wait);

    is identical to this one (in both results and logic):

    (Positionprofit(1) < c * Pr_Profit)
    or (marketposition(1) = 1)
    or (barssinceexit(1) > Bars_to_wait);

    I'll tell you why. Because with the "or" thing, we don't need the system to only satisfy one of the options. It can safisfy all of them. All that matters is that if one of them is satisfied it will allow the trade to take place.

    Line 1 - If we make less than x amount from previous trade, you can accept long trades, no matter what. So far so good.

    Line 2 - If the previous position was a long, you can accept the next signal no matter what. Doesn't matter to mention that the profit was high or low. Because if it was low, it already had allowed the trade on line one. And if two conditions are satisfied the system is not gonna mind I don't think.

    Line 3 - If 100 bars have passed from the previous trade, you can also accept the long trade no matter what the profit of the previous trade was, or what the previous position was.

    So the problem must be somewhere else, maestro, but thanks for helping me. There is a problem and I can't understand what it is.

    No, wait, something is clear. This code doesn't create any problems and it executes perfectly:

    (Positionprofit(1) < c * Pr_Profit) or (barssinceexit(1) > Bars_to_wait)

    the problem arises when I insert marketposition(1):

    (Positionprofit(1) < c * Pr_Profit) or (marketposition(1) = 1) or (barssinceexit(1) > Bars_to_wait)

    I gotta focus on those few inches of code, right there. Maybe even on the "=1" part of it.
  4. abogdan


    They are not the same. In your logic any of the listed conditions would trigger the buy. But in your description you sad you want to add some other criteria. So these criteria can only be added through additional "AND" statements. If you would like me to help you write the logic in plain english I'll program it for you.
  5. travis


    Hm, I am sure you know plenty, but I don't understand how they are different, especially since the results I get are exactly the same.

    I will explain it in plain English, even though that is what I have done until now. Should I quote what I wrote or write it all over again? I'll write it all over again. Excuse me if I repeat myself.

    Dear System,

    I want you to not take any long trades if you JUST (<100 periods) had a BIG (>400) win that was a short trade, and viceversa.

    Thank you for your help.
  6. abogdan


    I have to go home now, I'll get back to you tomorrow. But I already see your problem
  7. TGregg


    A better definition of "doesn't work" would enable folks to look at the code and differentiate that from what you expected.
  8. TGregg


    I see one problem. Read your English then compare it to your code. If a or (y and z) or b then. . . but that's not what your code says. :D
  9. travis


    Yes, you are right (about your first post). I could send you the system privately, to show you what it doesn't do. I will do that. To summarize the problem, "it doesn't work" means it doesn't wait 100 bars to trade. Say it gets a profit of > 400 from a short trade, well, immediately after that, it still takes a long trade, whereas I am trying to keep it from doing that and to wait 100 periods.

    Your second post, I didn't understand exactly what you meant, but I am sure there was a misunderstanding, because I don't think there could be anything so...ridiculous about it. Probably I wasn't clear, but read the code in the later posts, and there shouldn't be any misunderstandings.
  10. TGregg


    Relax kido, I'm not laughing at you. That's a Big Grin icon. Although it is a bit funny that you did a good job of reducing the problem to smaller pieces, but missed the problem with your simplified bits. But of course, that's why one looks for aid. Anyway, count the conditions in your English statement:

    Points < 400
    Points >= Big Trade and last position long
    bars since I bailed > 100

    Then compare it to the conditions in your code:

    Points < 400
    last position long
    bars since I bailed > 100

    And it's pretty obvious what is missing. Indeed, this is merely a long explanation of my earlier post about how your English read If a or (x and y) or b then. One would be well advised to carefully review any post of mine to be sure one understands it completely, as I tend to post ideas in summation. I do like high baud rates.
    #10     Jan 9, 2004