01. Count "X" Times and then pass.
input int count = 50; // Set the counting limit as an input int Counter; // counter variable // Expert Initializing -------------------- int OnInit() { return(INIT_SUCCEEDED); } // Expert DeInitializing ------------------- void OnDeinit(const int reason) { } // Expert OnTick -------------------------- void OnTick() { Counter ++; // add 1 to the counter on each tick. Comment("Current Count -:", Counter); if(Counter == count) // Count "X" times and pass | This block Executed only once per each count. { // Your code goes here...... Alert(count," Times counted"); Counter = 0; // Reset the counter at the end of your code block. This is must. } } // OnTick End <<----------------------
02. Pass "X" times and then Wait "X" times then pass.
this method can be use as like wait and pass, pass and wait.
input int count = 50; // Set the counting limit as an input input int wait = 50; // Set the waiting limit as an input int Counter; // counter variable default value is "0" int Waiter; // Waiting variable default value is "0" // Expert Initializing -------------------- int OnInit() { return(INIT_SUCCEEDED); } // Expert DeInitializing ------------------- void OnDeinit(const int reason) { } // Expert OnTick -------------------------- void OnTick() { Comment("Counted Ticks -: ", Counter, "\n", "Waited Ticks -: ", Waiter); if(Counter < count) // Pass "X" times { Counter++; // update the counter // Your code goes here. } else if(Waiter < wait) // Wait for "X" times { Waiter++; // update the waiter // Your code goes here. } if(Waiter == wait) // Waiting Limit is reached { Counter = 0; // reset counter Waiter = 0; // reset waiter } } // OnTick End <<---------------------- //+------------------------------------------------------------------+
Special -:
You can code the "Pass X times and stop" by modifying the above code by removing the waiting code block. Then it will count for specific number and stop works until the counter is rested. You can reset it anywhere in your code if you create these variables in global scale. (global variables)
Basic GridManager Library
This is a basic library to create and manage grids.
A Code block to detect A "New Candle/Bar" using bars history (very effective way)
If you only want to execute your code blocks "only once per bar" it's important to check if there is new bar arrived or not.
Simple Yet Effective Breakout Strategy
A simple yet effective donchian channel breakout strategy. This strategy is timeless!
QuickTradeKeys123
QuickTradeKeys 123 is a user-friendly Expert Advisor (EA) for MetaTrader 5, enabling traders to execute buy and sell operations quickly by simply pressing the numbers '1' and '2' on their keyboard. Pressing '3' closes all open positions. This EA is ideal for swift trading and testing purposes where manual intervention is required without using the mouse.