Expert advisor moving average crossover strategy how can we set lot size and time frame

Salmanali9200

Trader
Apr 2, 2021
3
0
6
43
MQL4:
void OnTick()
  {
   // current chart, current period, 10,candles, no shift, simple, close price
      double SlowMovingAverage = iMA(NULL, 0,10,0, MODE_EMA,PRICE_CLOSE,0);
 
      // current chart, current period, 10,candles, no shift, simple, close price
      double LastMovingAverage = iMA(NULL, 0,10,0, MODE_EMA,PRICE_CLOSE,1);
 
      // current chart, current period, 10,candles, no shift, simple, close price
      double FastMovingAverage = iMA(NULL, 0,5,0, MODE_EMA,PRICE_CLOSE,0);
 
      // current chart, current period, 10,candles, no shift, simple, close price
      double LastFastMovingAverage = iMA(NULL, 0,5,0, MODE_EMA,PRICE_CLOSE,1);
 
      // if the fast EMA is now above
      if ((LastMovingAverage < LastFastMovingAverage)
         &&(FastMovingAverage > SlowMovingAverage))
 
      // Chart output for but Signal
         Comment ("Buy");
 
      if ((LastMovingAverage > LastFastMovingAverage)
         &&(FastMovingAverage < SlowMovingAverage))
 
       // if the fast EMA is now below
         Comment ("Sell");
 
       // Ask Price
        { Comment("Current Ask price is ", Ask); }
 
        // Bid Price
        { Comment("Current Ask price is ", Bid); }
 
 
 
    }
 
Last edited by a moderator:

Salmanali9200

Trader
Apr 2, 2021
3
0
6
43
Attaching the entire .mq4 file as a file attachment would be more helpful.
From what I see in your code, the EA will work with the timeframe you attach it to.
It doesn't open any trades, so there is no position size to control.
dear Evid i did not design himself i just write down by watch other video

Enivid now can it work

i have one more file i want remove sliipage and extra coomands and want use only for gold trading after resetting moving average as my required
 

matfx

Active Trader
dear Evid i did not design himself i just write down by watch other video

Enivid now can it work

i have one more file i want remove sliipage and extra coomands and want use only for gold trading after resetting moving average as my required
The Youtuber only show how the Moving Average Crossover work to generate buy or sell based on MA cross over but the code not a completed EA for real trading. Enivid has shared a MA crossover template that can be put to real trading. You can search in Expert Advisor in this forum.

Regards

matfx
 
  • 👍
Reactions: Enivid