Changeset 2


Ignore:
Timestamp:
Apr 29, 2008, 8:37:39 AM (16 years ago)
Author:
george
Message:

Přidáno: Omezení zákmitů transakcí.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Test.mq4

    r1 r2  
    1414extern double MovingPeriod       = 14;
    1515extern double MovingShift        = 0;
     16extern double MinDerivation      = 0.0002;
    1617
    1718int MathSign(double Value)
     
    2930  static double LastDerivation;
    3031  double Derivation;
     32  static bool LastChangeDirection = false;
     33  static int SameDirectionCount = 0;
    3134 
    3235  // Go trading only for first tiks of new bar
     
    3639  MovingAverage = iMA(NULL, 0, MovingPeriod, MovingShift, MODE_SMA, PRICE_CLOSE, 0);
    3740  Derivation = MovingAverage - LastMovingAverage;
    38    
     41  Print("Derivation: " + Derivation); 
     42  Comment("SameDirectionCount: " + SameDirectionCount); 
     43  if(MathSign(LastDerivation) == MathSign(Derivation)) SameDirectionCount++;
     44  else {
     45    LastChangeDirection = true;
     46    SameDirectionCount = 0;
     47  }
     48
    3949  // Sell conditions
    40   if(MathSign(LastDerivation) != MathSign(Derivation)) 
     50  if(LastChangeDirection && (SameDirectionCount > 2)) 
    4151  {
    42     Print("Derivation: " + Derivation); 
    43     Comment("Derivation: " + Derivation); 
    4452    if(MathSign(Derivation) == -1) res = OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, 0, 0, "", MAGICMA, 0, Red);
    4553    if(MathSign(Derivation) == 1) res = OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, 0, "", MAGICMA, 0, Blue);
     54    LastChangeDirection = false;
    4655  }
    4756  LastMovingAverage = MovingAverage;
Note: See TracChangeset for help on using the changeset viewer.