Amps

Showing posts with label forex mt4 indicator. Show all posts
Showing posts with label forex mt4 indicator. Show all posts

Sunday, June 17, 2018

Best Forex Trading Strategies on EMA

Best Forex Trading Strategies on EMA

BladeRunner Trading Method

Document from forexfactory

This example is for a long entry. The opposite rules apply for a short entry

Indicator Use EMA 8/21/89
MACD Color TF H4 (5,13,1)
MACD Color TF H1 (8,13,1)

Buy Example

On TF H4
price closing above the 8EMA with the 8/21EMA starting to separate

Access TF H1
Enter long on the next 1 hour close that turns the MACD histogram back to green as long as the close is above the 8EMA on the 1 hour.
Place a 10 pip stop loss at the low of the bar you entered on. Progressively move the stop loss up on all positions to the new stop loss. In other words, all long positions will be closed out at the same price.
Note: 1 pip = 10 point

The highlighted area of the 1 hour chart below shows every long entry (vertical
line) that would have been entered before being stopped out after entry #10.

The short black horizontal bars show where your stop loss would have been moved up after each entry.

This method is best suited for strong trending markets.Refer to daily charts to get a larger picture of what the longer term trend is.

Trade breakdown with spread. Stop loss is at 10 pips below the low of the entry:
1) Buy at 1.4263 with a stop at 1.4237
2) Buy at 1.4280 move stop to 1.4245
3) Buy at 1.4320 move stop to 1.4282
4) Buy at 1.4325 move stop to 1.4302
5) Buy at 1.4338 move stop to 1.4014
6) Buy at 1.4363 move stop to 1.4314
7) Buy at 1.4379 move stop to 1.4350
8) Buy at 1.4388 move stop to 1.4354
9) Buy at 1.4410 move stop to 1.4498
10) Buy at 1.4425 move stop to 1.4402
All ten positions stopped out at 1.4402

If price closes below the 8EMA on the 1 hour charts, it may be the start of the trend slowing down.
If price closes below the 8EMA on the 4 hour charts your positions may all get stopped out.

Tuesday, February 23, 2016

Moving Average EA Example Step Conclusion

Moving Average EA Example Step Conclusion



Moving Average Activate Open and Close order Function MQL4

Moving Average Activate Open and Close order Function MQL4

Basic Function Moving Average Multi order EA Example MQL4

bool IsTradeAllowed
string symbol
datetime Time to check status

Full code on this part OnTick

//+------------------------------------------------------------------+
//| OnTick function                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- check for history and trading
   if(Bars<100 || IsTradeAllowed()==false)
      return;
//--- calculate open orders by current symbol
   if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
   else                                    CheckForClose();
//---
  }
//+------------------------------------------------------------------+

Finish Moving Average EA coding MQL4

Auto Close Order Moving Average EA MQL4

Auto Close Order Moving Average EA MQL4

This part very useful because this part we able to use protect the Take profit and Stop Loss, which would make us live in Forex Trading and got best profit and minimum loss.

MQL4 Basic function used Close Order Moving Average EA MQL4

Table Function OrderSelect MQL4


bool OrderSelect It returns true if the function succeeds The order must be previously selected by the OrderSelect() function
Int index Order index or order ticket depending on the second parameter
Int select
SELECT_BY_POS index in the order pool
SELECT_BY_TICKET index is order ticket
int pool=MODE_TRADES
MODE_TRADES (default) order selected from trading pool(opened and pending orders)
MODE_HISTORY order selected from history pool (closed and canceled order)
int OrderMagicNumber(); Returns an identifying (magic) number of the currently selected order

string  OrderSymbol() Returns symbol name of the currently selected order.

Table Function Order Type MQL4

int OrderType();
Returned value Should specific when we using
OP_BUY
OP_SELL
OP_BUYLIMIT
OP_BUYSTOP
OP_SELLLIMIT
OP_SELLSTOP
double Open[] contains open prices of each bar of the current chart
double Close[] contains close prices for each bar of the current chart

Table Function Order Close MQL4

bool OrderClose Closes opened order
Int ticket Unique number of the order ticket
Double lots Number of lots
Double price Closing price
Int slippage Value of the maximum price slippage in points
color arrow_color Color of the closing arrow
long Volume[] contains tick volumes of each bar of the current chart

moving average EA close order conditions:

Close Buy when Candle open price over MA reference and close candle price under ma
Open[1]>ma && Close[1]<ma
Close Sell when Candle open price under MA reference and close candle price over ma
Open[1]<ma && Close[1]>ma

Full code moving average close order

//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void CheckForClose()
  {
   double ma;
//--- go trading only for first tiks of new bar
   if(Volume[0]>1) return;
//--- get Moving Average 
  //original ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
  //new
  ma=iMA(NULL,TimeFrameUsed,MovingPeriod,MovingShift,EMA_method1,Applied_Price1,0);
//---
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
      //--- check order type 
      if(OrderType()==OP_BUY)
        {
         if(Open[1]>ma && Close[1]<ma)
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
      if(OrderType()==OP_SELL)
        {
         if(Open[1]<ma && Close[1]>ma)
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
     }
//---
  }

This EA prepare example for activate open and close order, next chapster we would find out how to.

Moving Average EA Open Order with Modify Take profit and Stop Loss

Moving Average EA Open Order with Modify Take profit and Stop Loss

In previous chapter we guide moving average properties. In this chapster we would coding Moving Average EA MQL4 for modify take profit and Stop Loss.
Mention to Forex Broker have the exchange digits show 3,5 and 4 digits, which modify Take profit and Stop Loss that depend on broker we trading.

Refer to properties code in this part are:












extern string TP_SL = " --- TP and Stop Loss ---";
extern bool Broke3_5Digits = True;
extern double My_TP = 10;
extern double My_SL = 10;

And Moving Average Properties part we would always change as below
//Add extern parameter as Label
extern string MovingAvr = " --- Moving Average parameter ---";
//Change from original
extern int    MovingPeriod  =12;
extern int    MovingShift   =6;
//Add properties
extern ENUM_TIMEFRAMES TimeFrameUsed = PERIOD_CURRENT;
extern ENUM_MA_METHOD   EMA_method1 = MODE_SMA;
extern ENUM_APPLIED_PRICE Applied_Price1 = PRICE_CLOSE;

In checking the open order we would add the condition to design broker digits using as follow

void CheckForOpen()
  {
   double ma;
   int    res;

// calculate TP and Stop Loss   
   double BrokerTPSell,BrokerTPBuy;
   double BrokerSLSell,BrokerSLBuy;
 if(Broke3_5Digits=True)
 { 
   if (My_TP!=0)
   {
    BrokerTPSell = Bid-((My_TP*Point)*10);
    BrokerTPBuy = Ask+((My_TP*Point)*10);
   }
   
   if (My_TP==0)
   {
    BrokerTPSell = 0;
    BrokerTPBuy = 0;
   }
   
   if (My_SL!=0)
   {
    BrokerSLSell = Bid+((My_SL*Point)*10);
    BrokerSLBuy = Ask-((My_SL*Point)*10);
   }
   
   if (My_SL==0)
   {
    BrokerSLSell = 0;
    BrokerSLBuy = 0;
   }
   
 }
 if(Broke3_5Digits=False)
 { 
   if (My_TP!=0)
   {
    BrokerTPSell = Bid-(My_TP*Point);
    BrokerTPBuy = Ask+(My_TP*Point);
   }
   
   if (My_TP==0)
   {
    BrokerTPSell = 0;
    BrokerTPBuy = 0;
   }
   
   if (My_SL!=0)
   {
    BrokerSLSell = Bid+(My_SL*Point);
    BrokerSLBuy = Ask-(My_SL*Point);
   }
   
   if (My_SL==0)
   {
    BrokerSLSell = 0;
    BrokerSLBuy = 0;
   }
   
 }

So the open order we would put the value from Moving Average EA as below

//--- go trading only for first tiks of new bar
   if(Volume[0]>1) return;
//--- get Moving Average 
  // original ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);
  //new
  ma=iMA(NULL,TimeFrameUsed,MovingPeriod,MovingShift,EMA_method1,Applied_Price1,0);
//--- sell conditions
   if(Open[1]>ma && Close[1]<ma)
     {
      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,BrokerSLSell,BrokerTPSell,"",MAGICMA,0,Red);
     
      return;
     }
//--- buy conditions
   if(Open[1]<ma && Close[1]>ma)
     {
      res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,BrokerSLBuy,BrokerTPBuy,"",MAGICMA,0,Blue);
      return;
     }
//---
  }

In next chapster we would detail for auto close order

Wednesday, January 13, 2016

EA MA Optimal Lot or Trading Money Management

Optimal Lot or Trading Money Management

Money Management that nessary for our trading because this would protect our loss could be happen all the time, so this part should have in our Expert Advisor.

The MQL4 function used for this module detail as below.

Function Feature
double NormalizeDouble Return Value of double type with preset accuracy
double value Value with a floating point
int digits Accuracy format, number of digits after point (0-8)
double AccountFreeMargin(); Free margin value of the current account.
double OrderProfit() Returns profit of the currently selected order The net profit value (without swaps or commissions)
int OrdersHistoryTotal(); The number of closed orders in the account history loaded into the terminal. The history list size depends on the current settings of the "Account history" tab of the terminal

Meaning of Moving Average Money Management MQL4 code

double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//--- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//Calculate account free margin from Maximum risk, which specified in EA properties

//--- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
           {
            Print("Error in history!");
            break;
           }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
            continue;
         //---
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1)
         lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }


//This function decrease lot size depend on order pending got loss
//DecreaseFactor would got specified on EA properties

//if(DecreaseFactor>0) would do the lot optimization if specified number greater than 0 
//in EA properties
//----- in DecreaseFactor Function----
//if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
//Check order false status and report

//if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
//            continue;
//order success check
//if(OrderProfit()>0) break;
//if order got profit not do the lot optimization
// if(OrderProfit()<0) losses++;
//     }
//      if(losses>1)
//        lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
//     }

// if order have loss do the lot optimization or decrease lot to next order
//----- end of DecreaseFactor check condition

//--- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }

//---- end of  

Test Run Moving Average EA on youtube
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//--- select lot size
   lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,1);
//Calculate account free margin from Maximum risk, which specified in EA properties

//--- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
           {
            Print("Error in history!");
            break;
           }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
            continue;
         //---
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1)
         lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }


//This function decrease lot size depend on order pending got loss
//DecreaseFactor would got specified on EA properties

//if(DecreaseFactor>0) would do the lot optimization if specified number greater than 0 
//in EA properties
//----- in DecreaseFactor Function----
//if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)
//Check order false status and report

//if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL)
//            continue;
//order success check
//if(OrderProfit()>0) break;
//if order got profit not do the lot optimization
// if(OrderProfit()<0) losses++;
//     }
//      if(losses>1)
//        lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
//     }

// if order have loss do the lot optimization or decrease lot to next order
//----- end of DecreaseFactor check condition

//--- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }

//---- end of  

Test Run Moving Average EA on youtube


Monday, December 21, 2015

Visual Back Test EA and Indicator MT4

Visual Back Test EA and Indicator MT4 

2 step Fastest Test Expert Adviser and Forex Indicator MT4

1. Select MT4 Expert Adviser Tester set properties and parameter TF for back testing click at Visual

Click the Start testing slide bar at visual mode to slowest position and then go to step 2


2. Drag the indicator want to check to the visual chart

Saturday, September 26, 2015

Attach MT4 indicators


Attach MT4 indicators and Save to the template

Select Indicator pasted into Chart


Example MT4 Moving Average Trend Indicators 10, 50, 200



Average Directional Movement Index with put Moving average to the ADX chart




Stochastic Oscillator and MACD and save template to use in next time and other currency pair photo show as below



First Setting up mt4 trading screen

MT4 Setting indicators and Template

MT4 Chart Setting

Right click on the Symbol currency pair we want to make a trading => Select Popup Chart Windows

Default chart would show in Time Frame H1 (60 minutes)
The time frame selection would found on small icon
  • m1 = 1 minute/candle
  • m5 = 5 minute/candle
  • m15 = 15 minute/candle
  • m30 = 30 minute/candle
  • H1 = 1 hours/candle
  • H4 = 4 hours/candle
  • D1 = 1 day/candle
  • W1 = 1 week/candle
  • MN= month/candle



Right click on the chart tick select chart style and colour of candles


On the Common page tick to Show Ask Line


After finish Setting screen would show like this