Announcement

Collapse
No announcement yet.

Negative numbers in EFS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Negative numbers in EFS

    I am trying to set-up my strategy to stop trading if a maximum loss is exceeded and I am having trouble getting this to happen . I can get my program to stop trading if a profit target is reached so I know I am making some wrong assumptions about the sign of numbers . Here is what I have :

    // these declared global above pre-main
    var MaxProfit = 100;
    var MaxLoss = -100;
    var Profit = 0;

    // in main when trade is exited

    if target_hit
    {Profit = Profit + (expression to calculate profit of this trade)}

    if stop_hit
    {Profit = Profit - (expression to calculate loss of this trade)}

    if ((Profit <= MaxLoss) || (Profit >= Profit))
    // stop trading here and stop taking new signals

    I do print statements that show profit of -120 for example and it keeps on trading but if I get a profit of 120 is stops dead in it's tracks and goes to sleep .

    Any tips appreciated .

    Thanks Bill

  • #2
    if ((Profit <= MaxLoss) || (Profit >= Profit))

    s/b

    if ((Profit <= MaxLoss) || (Profit >= Maxgain))?

    Comment


    • #3
      Yes - sorry for the type

      Comment


      • #4
        I would add a debugPrintln for Profit, maxgain and maxloss to see where the problem lies

        Comment


        • #5
          Thanks Dave . Sometimes it takes a fresh mind to get one unstuck from a problem . I had set MaxLoss to the wrong value at one point but was getting too blind to see it .

          Comment

          Working...
          X