Results 1 to 6 of 6
 3 Attachment(s)    

Thread: Sorry Funyoo I Have A Problem

  1. #1

    Default Sorry Funyoo I Have A Problem

    Hi Funyoo
    sorry but I can't do to code the situation that I attach you.
    If the EMA 40 is below EMA 80 I go only short. I attempt the WPR should be above the level -20 (warning signal). When it falls back below the level of -20 I put an order SELLSTOP 5 pips below the close of the candle.
    This is my code:

    double Ema80=iMA(Symbol(),0,Ema1Period,0,Ema1Method,Ema1P rice,shift);
    double Ema40=iMA(Symbol(),0,Ema2Period,0,Ema2Method,Ema2P rice,shift);

    double WPR=iWPR(Symbol(),0,WPRPeriod,shift);
    double WPRa=iWPR(Symbol(),0,WPRPeriod,shift+1);

    int trend = 0;
    if (Ema40>Ema80) trend = 1;
    if (Ema40<Ema80) trend = 2;

    bool ipercomprato = FALSE;
    if(WPR<-20) ipercomprato = TRUE;

    bool ipervenduto = FALSE;
    if(WPR>-80) ipervenduto = TRUE;

    int masignal=0;
    if(trend==1 && ipervenduto)masignal=1;
    if(trend==2 && ipercomprato)masignal=2;

    But for me there is a mistake but I don't know where it is.

    And this is the code for pending order:

    bool buy=false;bool sell=false;

    if(masignal==1){
    if(WPRa>-80 && WPR<-80)if(reversesignals)sell=true;else buy=true;}

    if(masignal==2){
    if (WPRa<-20 && WPR>-20)if(reversesignals)buy=true;else sell=true;}

    if(sell && tpb<tradesperbar && IsTradeAllowed()){
    while(IsTradeContextBusy())Sleep(3000);
    if(hidestop==false&&sellstop>0){sl=Bid+sellstop*pt ;}else{sl=0;}
    if(hidetarget==false&&selltarget>0){tp=Bid-selltarget*pt;}else{tp=0;}
    if(martingale)ilots=NormalizeDouble(lots*martingal efactor(),2);else ilots=lots;
    if(ilots<minlot)ilots=minlot;if(ilots>maxlot)ilots =maxlot;
    RefreshRates();ticket=OrderSend(Symbol(),OP_SELLST OP,ilots,Bid-5*pt,slippage*mt,sl,tp,comment+". Magic: "+DoubleToStr(magic,0),magic,expire,Red);
    if(ticket<=0){Print("Error Occured : "+errordescription(GetLastError()));}
    else{tpb++;Print("Order opened : "+Symbol()+" Sell @ "+Bid+" SL @ "+sl+" TP @"+tp+" ticket ="+ticket);}
    }
    }
    I used your template, of course.......
    Thanks for your help.

    Davide
    Attached Files Attached Files

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

    Default

    Hi paciola,

    You should maybe replace this :

    Code:
    bool ipercomprato = FALSE;
       if(WPR<-20) ipercomprato = TRUE;
       
       bool ipervenduto = FALSE;
       if(WPR>-80) ipervenduto = TRUE;
    by :

    Code:
    bool ipercomprato = FALSE;
        if(WPRa>-20 WPR<-20) ipercomprato = TRUE;
        
        bool ipervenduto = FALSE;
        if(WPRa<-80 && WPR>-80) ipervenduto = TRUE;
    Then for the sl and tp, don't forget to replace Bid by Bid-5*pt. You should replace 5 by gap (as an integer) and then set the gap depending on your broker's stoplevel.

  3. #3

    Default

    Many thanks Funyoo but it doesn't work and I don't Know why.
    When you have time, can you see the code please?
    I tell you which is the strategy.
    First of all we determine the trend through the EMA's.
    When EMA 40 is above the EMA 80 we go ONLY long, and when the EMA 40 is below the EMA 80 we go ONLY short.
    The input signal is given by the WPR 21 periods.
    Example;
    if the trend is long we attempt that WPR goes in the oversold area (this is tha alert moment).
    Then we attempt that WPR goes out to the oversold area (but can pass three or four o five candle in oversold area) and when the candle is closed we place to BUYSTOP order 5 pips up the close of last candle.
    TP is 30 pips and stop loss 50 pip fix.

    For sell order is the opposite situation.

    There isn't any error in the code or in the journal, but the EA don't open any order.
    Can you see it please?

    Thanks Davide

  4. #4

    Default

    Sorry I attached you the code of my EA
    Attached Files Attached Files

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

    Default

    Quote Originally Posted by paciola View Post
    Sorry I attached you the code of my EA
    Hi paciola,

    Here is the EA.
    Attached Files Attached Files

  6. #6

    Default

    Thank you Funyoo now I study your code.
    Many thanks

    Davide

Similar Threads

  1. Help- SL problem
    By shabeer.a100 in forum Softwares
    Replies: 1
    Last Post: 09-12-2013, 15:00
  2. Problem with an ea
    By stotzman in forum MQL programming
    Replies: 1
    Last Post: 07-08-2013, 12:57
  3. Help- SL problem
    By shabeer.a100 in forum MQL programming
    Replies: 6
    Last Post: 11-23-2012, 03:37
  4. Help- SL problem
    By shabeer.a100 in forum Scripts and other tools
    Replies: 0
    Last Post: 11-21-2012, 13:57
  5. Problem with my EA
    By veon87 in forum Ideas for expert advisors
    Replies: 0
    Last Post: 09-16-2010, 20:39

Tags for this Thread

broker, candle, funyoo, level, magic, martingale, pips, sells, signal, slippage, strategy, study, thank you, time, trend

Posting Permissions

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