HELP! I need to control opposite actions

 

Dear All,

My MQL skills is too limited so please help and advice.

My EA uses EachTick as a signal mode.

There're always Three predefined zones as following:

double Level_CC = Close[0]; // The current price

double Level_HH, Level_HL;  // Calculated limits of the higher zone (ZoneH)
double Level_MH, Level_ML;  // Calculated limits of the middle zone (ZoneM)
double Level_LH, Level_LL;  // Calculated limits of the lower zone  (ZoneL)

bool   ZoneH = (Level_HH >= Level_CC) && (Level_CC >= Level_HL);
bool   ZoneM = (Level_MH >  Level_CC) && (Level_CC >  Level_ML);
bool   ZoneL = (Level_LH >= Level_CC) && (Level_CC >= Level_LL);

Now, I need my code to identify the price movement in terms of only one of the following two cycles:

  • Cycle A: The price is moving across ZoneM-ZoneH-ZoneL-ZoneM
  • Cycle B: The price is moving across ZoneM-ZoneL-ZoneH-ZoneM

Taking into considerations that:

  1. When the current price (Level_CC) enters the ZoneH it should tells the control that; The Cycle A is dominant and get ready to detect the next ticks for Cycle A to be completed. ALSO,
  2. When the current price (Level_CC) enters the ZoneL it should tells the control that; The Cycle B is dominant and get ready to detect the next ticks for Cycle B to be completed.
  3. When the current price (Level_CC) enters the ZoneM it should resets the control and get ready to the next cycle and so on.

For each zone (ZoneH & ZoneL), there're two different cases or operators (per each) to be controlled as following:

if(CycleA_is_Dominanet) {ZoneH_Default_Actions = True;  ZoneH_Alternative_Actions = False; ZoneL_Default_Actions = False; ZoneL_Alternative_Actions = True; }

if(CycleB_is_Dominanet) {ZoneH_Default_Actions = False; ZoneH_Alternative_Actions = True;  ZoneL_Default_Actions = True;  ZoneL_Alternative_Actions = False;}

Actually, I got lost with if-else and switch operators, and there's interference when using if-else operator and I'm not sure how to regulate them properly.


The following illustrative FIG shows that:

  • When the current price (Level_CC) exits the ZoneH just slightly above, it will be allocated in the next new ZoneL, so that; ZoneL_Alternative_Actions to be used.
  • When the current price (Level_CC) exits the ZoneL just slightly below, it will be allocated in the next new ZoneH, so that; ZoneH_Alternative_Actions to be used.

FIG. Price movement control using dynamic coordinates

 
OmegaFX:


... My EA uses EachTick as a signal mode ....

https://www.mql5.com/en/forum/139608
Reason: