Page 5 of 15 FirstFirst ... 34567 ... LastLast
Results 41 to 50 of 144
  39 39 Attachment(s)    

Thread: EMA Cross EA

  1. #41
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by david9 View Post
    Hello Voltron,

    I think that is a good move. I was thinking it was messing this EA up (keeping it from trading when I thought a trade should be on) but i also was wondering if its better for the EA to have a true /false choice so if it is decided to have something put back on we don't need to bother funyoo.

    Good trading to all,

    David9
    Hi David9,

    I have put this in option.

    Quote Originally Posted by voltron View Post
    ------------------------------
    dear funyoo,

    i've been tested the latest so far its good, the ea follow what its has been program to do accurately. Only when the movement of the 2 line were very closed , then its a very big problems lost lost and lost....

    so to avoid this problem :

    can you make the op to start immidiately when the cross exactly happen and not at the new first bar

    and remain others as usual.

    tq
    Hi voltron,

    Here it is. You have to put Shift=-1. You should get a lot of bad signals.
    Attached Files Attached Files

  2. #42

    Default a very fast one.....

    Quote Originally Posted by funyoo View Post
    Hi David9,

    I have put this in option.



    Hi voltron,

    Here it is. You have to put Shift=-1. You should get a lot of bad signals.
    -----------------------

    hi funyoo

    thanks again, ermm as i sure you would say thats word, if i asking you
    for that kind of option, but thanks very much for the updated

    i wil try it first, if this thing useless, so i have to used the version 3.2
    and a little bit last request from u to put a filter, so far iam not confirmed yet which im going to used, still testing....

    thanks funyoo

  3. #43

    Default THE FINAL - refer to ema cross ea v3.3

    Quote Originally Posted by voltron View Post
    -----------------------

    hi funyoo

    thanks again, ermm as i sure you would say thats word, if i asking you
    for that kind of option, but thanks very much for the updated

    i wil try it first, if this thing useless, so i have to used the version 3.2
    and a little bit last request from u to put a filter, so far iam not confirmed yet which im going to used, still testing....

    thanks funyoo
    ---------------------

    dear funyoo

    yes as you said.... a lot of bad signal....thats mean los los and losssss...

    after what ive seen, the lost happens ...when it came at this condition...please refer to the picture. what ever your ema setting is...this condition will appear...either late or earlier.

    so to solve this problems...can u add this indicator as a filter ( attachment ),

    1. so if u see the 'X' means not supposed to trade, although the SELL cross is there, because indicator shows UPTREND, thats the filter. only trade when the filter and the cross is true

    2. keep others as usual especially the 'stop trading atTP', BY THE WAY...i hope u can look also at this function after adding the filter. especially when it came to (n0.1 condition) stop at TP will remain 'false' am i right

    3. give an option, so can change value :
    - depth
    - gross period

    4. pls refer to version v3.2

    this is the last, i hope you can help pls pls
    Attached Images Attached Images EMA Cross EA-maproblem2-jpg 
    Attached Files Attached Files

  4. #44
    Junior Member
    Join Date
    Jan 2009
    Posts
    8

    Default

    dear funyoo,
    please, can add money management to this old version of ema cross ?
    thanks




    //---- input parameters
    extern double TakeProfit=110;
    extern double StopLoss=100;
    extern double TrailingStop=30;
    extern int ShortEma = 1;
    extern int LongEma = 13;
    extern bool UseStopLoss = false;
    extern double Lots=1;
    //+------------------------------------------------------------------+
    //| expert initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //----

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----

    //----
    return(0);
    }

    bool isNewSumbol(string current_symbol)
    {
    //loop through all the opened order and compare the symbols
    int total = OrdersTotal();
    for(int cnt = 0 ; cnt < total ; cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    //Print( "OrderSymbol = " + OrderSymbol() + ": Symbol = " + current_symbol);
    string selected_symbol = OrderSymbol();
    if (current_symbol == selected_symbol)
    return (False);
    }
    return (True);
    }

    int Crossed (double line1 , double line2)
    {
    static int last_direction = 0;
    static int current_direction = 0;

    //Don't work in the first load, wait for the first cross!
    static bool first_time = true;
    if(first_time == true)
    {
    first_time = false;
    return (0);
    }

    if(line1>line2)current_direction = 1; //up
    if(line1<line2)current_direction = 2; //down

    if(last_direction == 0) //first use
    {
    last_direction = current_direction;
    return(0);
    }

    if(current_direction != last_direction) //changed
    {
    last_direction = current_direction;
    return (last_direction);
    }
    else
    {
    return (0); //not changed
    }
    }

    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //----

    int cnt, ticket, total;
    double SEma, LEma;


    if(Bars<100)
    {
    Print("bars less than 100");
    return(0);
    }
    if(TakeProfit<10)
    {
    Print("TakeProfit less than 10");
    return(0); // check TakeProfit
    }


    SEma = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,0);
    LEma = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,0);


    static int isCrossed = 0;
    isCrossed = Crossed (LEma,SEma);

    total = OrdersTotal();

    if(total < 1 || isNewSumbol(Symbol()))
    {
    if(isCrossed == 1 )
    {

    if(UseStopLoss)
    ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"EMA_CROSS",12 345,0,Green);
    else
    ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point,"EMA_CROSS",12345,0,Green);

    if(ticket>0)
    {
    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("BUY order opened : ",OrderOpenPrice());
    }
    else Print("Error opening BUY order : ",GetLastError());
    return(0);
    }
    if(isCrossed == 2)
    {
    if(UseStopLoss)
    ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+S topLoss*Point,Bid-TakeProfit*Point,"EMA_CROSS",12345,0,Red);
    else
    ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"EMA_CROSS",12345,0,Red);

    if(ticket>0)
    {
    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("SELL order opened : ",OrderOpenPrice());
    }
    else Print("Error opening SELL order : ",GetLastError());
    return(0);
    }
    return(0);
    }


    for(cnt=0;cnt<total;cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    //OrderPrint();
    if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
    {
    if(OrderType()==OP_BUY) // long position is opened
    {
    /*
    // should it be closed?
    if(isCrossed == 2)
    {
    OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
    return(0); // exit
    }*/

    // check for trailing stop
    if(TrailingStop>0)
    {
    if(Bid-OrderOpenPrice()>Point*TrailingStop)
    {
    if(OrderStopLoss()<Bid-Point*TrailingStop)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
    return(0);
    }
    }
    }
    }
    else // go to short position
    {
    /*
    // should it be closed?
    if(isCrossed == 1)
    {
    OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ; // close position
    return(0); // exit
    }*/

    // check for trailing stop
    if(TrailingStop>0)
    {
    if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
    {
    if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
    return(0);
    }
    }
    }
    }
    }
    }
    return(0);
    }
    //+------------------------------------------------------------------+

  5. #45
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by voltron View Post
    ---------------------

    dear funyoo

    yes as you said.... a lot of bad signal....thats mean los los and losssss...

    after what ive seen, the lost happens ...when it came at this condition...please refer to the picture. what ever your ema setting is...this condition will appear...either late or earlier.

    so to solve this problems...can u add this indicator as a filter ( attachment ),

    1. so if u see the 'X' means not supposed to trade, although the SELL cross is there, because indicator shows UPTREND, thats the filter. only trade when the filter and the cross is true

    2. keep others as usual especially the 'stop trading atTP', BY THE WAY...i hope u can look also at this function after adding the filter. especially when it came to (n0.1 condition) stop at TP will remain 'false' am i right

    3. give an option, so can change value :
    - depth
    - gross period

    4. pls refer to version v3.2

    this is the last, i hope you can help pls pls
    Hi voltron,

    Here it is. Note that the DT ZigZig Lauer is repainting.
    Attached Files Attached Files

  6. #46
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by tsf View Post
    dear funyoo,
    please, can add money management to this old version of ema cross ?
    thanks
    Hi tsf and welcome,

    See here : http://www.tradingsystemforex.com/3891-post6.html

  7. #47
    Junior Member
    Join Date
    Jan 2009
    Posts
    8

    Default

    Quote Originally Posted by funyoo View Post

    dear Funyoo,
    thanks for welcome..........
    Have patience, i have an error, "lots" variable not defined
    can you help me please ?
    thanks thanks thanks........


    //+------------------------------------------------------------------+
    //| EMA_CROSS.mq4 |
    //| Coders Guru |
    //| Forex TSD| Metatrader Indicators and Experts Advisors |
    //+------------------------------------------------------------------+

    //+------------------------------------------------------------------+
    //| TODO: Add Money Management routine |
    //+------------------------------------------------------------------+
    //---- input parameters
    extern double TakeProfit=110;
    extern double StopLoss=100;
    extern double TrailingStop=30;
    extern int ShortEma = 1;
    extern int LongEma = 13;
    extern bool UseStopLoss = false;
    extern double Lots=1;

    extern string S2="---------------- Money Management";

    extern double Lots=0.1;//|-----------------------lots size
    extern bool RiskMM=false;//|---------------------risk management
    extern double RiskPercent=1;//|------------------risk percentage

    //+------------------------------------------------------------------+
    //| expert initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //----

    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| expert deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----

    //----
    return(0);
    }

    bool isNewSumbol(string current_symbol)
    {
    //loop through all the opened order and compare the symbols
    int total = OrdersTotal();
    for(int cnt = 0 ; cnt < total ; cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    //Print( "OrderSymbol = " + OrderSymbol() + ": Symbol = " + current_symbol);
    string selected_symbol = OrderSymbol();
    if (current_symbol == selected_symbol)
    return (False);
    }
    return (True);
    }

    int Crossed (double line1 , double line2)
    {
    static int last_direction = 0;
    static int current_direction = 0;

    //Don't work in the first load, wait for the first cross!
    static bool first_time = true;
    if(first_time == true)
    {
    first_time = false;
    return (0);
    }

    if(line1>line2)current_direction = 1; //up
    if(line1<line2)current_direction = 2; //down

    if(last_direction == 0) //first use
    {
    last_direction = current_direction;
    return(0);
    }

    if(current_direction != last_direction) //changed
    {
    last_direction = current_direction;
    return (last_direction);
    }
    else
    {
    return (0); //not changed
    }
    }

    //+------------------------------------------------------------------+
    //| expert start function |
    //+------------------------------------------------------------------+
    int start()
    {
    if(RiskMM)CalculateMM();
    //----

    int cnt, ticket, total;
    double SEma, LEma;


    if(Bars<100)
    {
    Print("bars less than 100");
    return(0);
    }
    if(TakeProfit<10)
    {
    Print("TakeProfit less than 10");
    return(0); // check TakeProfit
    }


    SEma = iMA(NULL,0,ShortEma,0,MODE_EMA,PRICE_CLOSE,0);
    LEma = iMA(NULL,0,LongEma,0,MODE_EMA,PRICE_CLOSE,0);


    static int isCrossed = 0;
    isCrossed = Crossed (LEma,SEma);

    total = OrdersTotal();

    if(total < 1 || isNewSumbol(Symbol()))
    {
    if(isCrossed == 1 )
    {

    if(UseStopLoss)
    ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"EMA_CROSS",12 345,0,Green);
    else
    ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+ TakeProfit*Point,"EMA_CROSS",12345,0,Green);

    if(ticket>0)
    {
    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("BUY order opened : ",OrderOpenPrice());
    }
    else Print("Error opening BUY order : ",GetLastError());
    return(0);
    }
    if(isCrossed == 2)
    {
    if(UseStopLoss)
    ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+S topLoss*Point,Bid-TakeProfit*Point,"EMA_CROSS",12345,0,Red);
    else
    ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"EMA_CROSS",12345,0,Red);

    if(ticket>0)
    {
    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("SELL order opened : ",OrderOpenPrice());
    }
    else Print("Error opening SELL order : ",GetLastError());
    return(0);
    }
    return(0);
    }


    for(cnt=0;cnt<total;cnt++)
    {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    //OrderPrint();
    if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
    {
    if(OrderType()==OP_BUY) // long position is opened
    {
    /*
    // should it be closed?
    if(isCrossed == 2)
    {
    OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
    return(0); // exit
    }*/

    // check for trailing stop
    if(TrailingStop>0)
    {
    if(Bid-OrderOpenPrice()>Point*TrailingStop)
    {
    if(OrderStopLoss()<Bid-Point*TrailingStop)
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
    return(0);
    }
    }
    }
    }
    else // go to short position
    {
    /*
    // should it be closed?
    if(isCrossed == 1)
    {
    OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet) ; // close position
    return(0); // exit
    }*/

    // check for trailing stop
    if(TrailingStop>0)
    {
    if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
    {
    if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
    {
    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Poi nt*TrailingStop,OrderTakeProfit(),0,Red);
    return(0);
    }
    }
    }
    }
    }
    }
    return(0);
    }
    void CalculateMM()
    {
    double MinLots=MarketInfo(Symbol(),MODE_MINLOT);
    double MaxLots=MarketInfo(Symbol(),MODE_MAXLOT);
    Lots=AccountFreeMargin()/100000*RiskPercent;
    Lots=MathMin(MaxLots,MathMax(MinLots,Lots));
    if(MinLots<0.1)Lots=NormalizeDouble(Lots,2);
    else
    {
    if(MinLots<1)Lots=NormalizeDouble(Lots,1);
    else Lots=NormalizeDouble(Lots,0);
    }
    if(Lots<MinLots)Lots=MinLots;
    if(Lots>MaxLots)Lots=MaxLots;
    return(0);
    }
    //+------------------------------------------------------------------+

  8. #48
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by tsf View Post
    dear Funyoo,
    thanks for welcome..........
    Have patience, i have an error, "lots" variable not defined
    can you help me please ?
    thanks thanks thanks........
    At line 17, delete this :

    Code:
    extern double Lots=1;

  9. #49

    Default refer to ema cross ver 3.4

    Quote Originally Posted by funyoo View Post
    Hi voltron,

    Here it is. Note that the DT ZigZig Lauer is repainting.
    -----------------

    dear funyoo, yes certainly its repaint, but this indi filter very well accept its repaint.

    still looking for the best filter

    request again : hope you are not angry...because im still testing on it

    1. can you add auto refresh function to refresh the indicator , with an option to change the timing in 'second' (ema cross ea ver3.4 )

    2. after 'stop lost' can you make the 'trade after tp' still = false, because i dont want it auto open trade, just want it to wait untill the next signal to appear .

    tq

  10. #50
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Quote Originally Posted by voltron View Post
    -----------------

    dear funyoo, yes certainly its repaint, but this indi filter very well accept its repaint.

    still looking for the best filter

    request again : hope you are not angry...because im still testing on it

    1. can you add auto refresh function to refresh the indicator , with an option to change the timing in 'second' (ema cross ea ver3.4 )

    2. after 'stop lost' can you make the 'trade after tp' still = false, because i dont want it auto open trade, just want it to wait untill the next signal to appear .

    tq
    Hi voltron,

    1. I don't know how to do this. You can add RefreshRates(); after start(){ if you want.

    2. See here : http://www.tradingsystemforex.com/2880-post1.html

Similar Threads

  1. Ea Sma Cross
    By haba in forum Expert advisors backtesting
    Replies: 2
    Last Post: 04-20-2016, 13:50
  2. ADX Cross EA
    By funyoo in forum Expert advisors backtesting
    Replies: 0
    Last Post: 07-29-2010, 21:24
  3. EMA cross only
    By szmvscla in forum Ideas for expert advisors
    Replies: 7
    Last Post: 03-19-2010, 04:11
  4. ST MA Cross EA
    By eforex in forum Ideas for expert advisors
    Replies: 12
    Last Post: 12-01-2009, 00:07
  5. EA 2 cross ema
    By il_valentino_forever in forum Ideas for expert advisors
    Replies: 1
    Last Post: 10-14-2009, 16:10

Tags for this Thread

100, advisor, adx, alpari, analysis, average, backtest, broker, brokers, change, closing, coding, color, crossover, demo, ea works, eur, eurjpy, expert, expert advisor, experts, forex, gbpjpy, guide, heiken ashi, high, how to, indicator, indicators, live, low, macd, magic, magic number, main, manual, martingale, maxorder, metatrader, moving average, mq4, mql, no repaint, profit, profit factor, profitable, programmer, programming, real, repaint, request, robot, rsi, scalp, scalping, scalping ea, signal, signals, simple, sma, stoch, stochastic, stop, stop ea, stoploss, strategy, study, support, system, test, time, trading, trailing, trailingstop, trend, usd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •