Jump to content

asgard2

Members
  • Posts

    167
  • Joined

  • Last visited

Posts posted by asgard2

  1. People, there are good reasons why this works on a demo and not on a live account. A demo is already a slave of a real broker server and there is a micro delay between the demo and the real server.

     

    Brokers being brokers, can see the orderflow of the underlying orders. Not only do they know who's orders are coming in but they also know where most of the limit or stop orders are. If they think the price is going up (they have a pretty good idea) because they see where all the pending orders are, each broker can move its platform about 2pips in anticipation of the move. However if then next tick is less than anticipated it will move back immediately with a gap (if you look at the minute chart).

     

    It is not necessarily a genuine move in price just an action by the broker than does not always register on the brokers slave. In addition, most broker demo platforms have less slippage and far less re-quotes than a real account. In my opinion the latency between real data flows of each broker, is unlikely to yield any meaningful consistency.

  2. Re: Building your own EA G/08.

     

    (An artificial intelligence system designed to predict the future flow of the price action in a span of one week and less accuracy averages 79% so far) We've been trying to shrink the model to make it predict m15 and hourly data (main problem is time since a single calculation takes around 5 hours I can post the translated article about it)

    Philippe.T

     

    Hmm, 5 hours is a long time..surely a good trade entry has been and gone?

     

    I calculate the next price this way.. and it if any future predicting type systems are good, then this will be about the same.

     

    double Hour4MA8Shift=(iMA(NULL,240,5,0,MODE_EMA,PRICE_LOW,2)-iMA(NULL,240,5,0,MODE_EMA,PRICE_LOW,1)) / 0.0001; // How far did the MA drop between the last price and previous price
    double PriceCalc = iMA(NULL,240,3,0,MODE_EMA,PRICE_LOW,1)- Hour4MA8Shift * 0.0001; //take that drop and apply it to the current angle to find a calculated next price. 
    

     

    If you set it up, correctly you can optimise it to find the best combination for your pair. The idea is that it should filter out the market noise and minor retracements

  3. Re: Building your own EA G/08.

     

    I'm highly skeptical about anything that could "predict the future", I'm sure it'll be pretty interesting :)

     

    LOL.. Well if God and Santa are true, then I am skeptical of nothing and anything is possible :)

     

    Just incase either of the above not true or not they are not helping.. I think we better stack the deck in our favour somewhat.

     

    I would rather trade on the situation at hand right now, than the one that passed yesterday.

     

    Meaning there are various things you can do with solid data that is coming in right now in the form of price, tick action, spread and last candles combined with trading style that will minimise risk.

     

    For Example if the last day closed a dojie, you will know 1 second after it did, you will also know if the Market is High..This is data coming in this second, that will help you avoid a bad trade.

     

    You can never predict a good trade, you can only avoid bad ones. Avoid enough bad ones and the good ones will be of a higher proportion. Risk is about so much more than percentage of your account vs stoploss level.

     

    Trend is the biggest killer (along with the saying Trend is your friend)..who can predict where or when one will start or stop? These days I give little weight to trend. One thing is certain, anyone who bought at the end of a trend, bought way over price.

  4. Re: Building your own EA G/08.

     

    the most important thing is

    how to avoid to get caught on reversal little up when it is big down trend.

     

    At the end of the day.. I think we will always have losses. The thing at the moment is to get entry and exit it as accurate as possible before we introduce the stoploss.

     

    Try this code, it works like a dynamic stop and it still makes a fair profit.. I must pass on my candle rules, which are not in the code I gave you so far because I am still testing them for best profit.

     

    
    OrderStoppedOut=false;
    
      if (MayOpenOrder){// Time Delay between buy stops or any closed order ........ //added the line about order stopped out
            total = OrdersHistoryTotal();
            for(i = total - 1; i >= 0; i--){
            OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);
            if(OrderSymbol() != Symbol())  continue;  {
           if (OrderType() == OP_BUY && OrderClosePrice() - OrderOpenPrice() < TakeProfitB && OrderCloseTime() ==TimeCurrent()) bool OrderStoppedOut=True; 
    if ((type==OP_BUY) && ((TimeCurrent() - OrderOpenTime())/60) < NextBuyStop_Order_Minutes) OpenBuy=0;
            if ((type==OP_SELL) && ((TimeCurrent() - OrderOpenTime())/60) < NextSellStop_Order_Minutes) OpenSell=0; 
              }} }
           
    //added all of the below code.
    if (OrderStoppedOut==True){ 
         
            total = OrdersTotal();
            for(i = total - 1; i >= 0; i--) {
            OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
            if(OrderSymbol() == Symbol()) CloseOrder();
            }} 
              

     

    That makes for an interesting visual but it would not be my preference ordinarily.

     

    With your coding skills I am certain you could come up with a better solution. This is what I think but I have no idea yet how to make it happen.

     

    If the second order is stopped out, close the first order with a higher open price in Just in case the market is going backwards. If it is going backwards it will simply buy at a lower price to replace the order it closed. If the market rebounds, it is the least profitable order to loose since the risk on the first order is the lowest risk.

  5. Re: Building your own EA G/08.

     

    Just a note..

     

    I shared this file with 4 others here, so far and before I deleted it, it had 18 downloads.

     

    I have the "little red hen" thing going... Just because it is right and fair.

     

    So if you have it, I don't mind and I did not ask those I gave it too, not to share it.

     

    However if you care for a copy of the final, then please come up with some ideas or code as well.

     

    I will get around to making a vid of this as soon as I get a pc capable of running "every tick" backtests again.

     

    Right now DD is around 10% starting from Feb 09 though to Yesterday... with RD at around 48 something. Net Profit just barely exceeds the mill.

     

    Still haven't started on the sell logic and still cannot get through Dec08 or January09 without degrading profitability unacceptably.

     

    If it can get though DEC 08 with Buy enabled.. should about get through anything. :-?

  6. Re: Building your own EA G/08.

     

    Looks to me like all the do it yourself people quit once again :( Sad but true...

     

    LOL.. what do you mean?

     

    I think we are all here... I am working on lots of ideas at the moment and I have some better results from the Developing EA.

     

    If anyone cares I can post them but it takes a while to get something good.

     

    If anyone wants to share their progress results, it would be great to see.

     

    Somedays I think it will never work, otherdays I make a breakthrough and amaze myself at the improved results of a simple idea.

     

    So every idea needs coding and testing and then if it works.. well, is it curve fitted?.. lots more checks to see if I am kidding myself.

     

    Here is a couple of unusual ideas that improved performance and DD since I last posted.

     

    When an order stops out, close all other orders of the same type or set breakeven.

     

    When bear tick count is greater than 18 close buy orders. This can only be optimised of course on each tick. My PC is Dead.

     

    Right now, I have just bought a new PC and I am waiting for it to arrive.. don't let anyone tell you you can't wear out your processor:)

     

    I am also playing with modes and early warning systems.

     

    Example below that is self explanatory.

     

    
    if (MA4_P6_Close > MA4_P6_Open){
           if  (iOpen(NULL,PERIOD_M15,0) < iMA(NULL,0,iMA_BuyPeriod,0,MODE_EMA,PRICE_LOW,0) && iMA(NULL,0,iMA_BuyPeriod,0,MODE_EMA,PRICE_LOW,0) - PricePoint *Point > Bid ) OpenBuy=1; }
    
    

     

    This works well but it is still four hours short of perfect.

  7. Re: Building your own EA G/08.

     

     

    You need to consider learning and sticking with manual trading systems.

     

    Hmm, that's a wee bit presumptuous..LOL

     

    I have been trading full time now for 2 years and I make just as many mistakes as my EA's. Only difference it that the EA's do it quicker.

     

    Edit: Happy New Year to you also and may it be prosperous for us all here.

  8. Re: Building your own EA G/08.

     

    For those with the developing EA, full control point backtest here.

     

    http://rapidshare.com/files/328262516/FxPro_-Real.rar

     

     

    The EA needs more developing before it is a live proposition. It needs at least another month of work.

     

    So far the logic only works on retracement but I will try going with the trend as well in separate logic

     

    The sell logic is not added yet and the EA will not be complete until it is.

     

    If you like it, I will keep you all posted on the progress

     

     

    Edit: happy New Year to all.. hope you don't get too sick

  9. Re: Building your own EA G/08.

     

    Lots are not limited or regulated since i like to see large numbers in the end of my backtests ...

    This is january to september

     

    Hi Cyrillic.. looks like a great job.. LOL so how many lots is that? What pair do you run?

     

    I only ever run maximum 8 lots.. I am not game enough

     

    Actually.. I run this just to keep me safer :)

     

    if (OrdersTotal() == 0) Risk=0.1;

    if (OrdersTotal() == 1) Risk=0.2;

    if (OrdersTotal() == 2) Risk=0.3;

  10. Re: Building your own EA G/08.

     

    well People, I thought this thread was dead..

     

    Actually.. I did not get Greezly quite right and it failed on me sometime after my last post.

     

    To tighten it up anymore was leaving me with a mediocre profit level, so I started a different one from scratch.

     

    So far, so good.

     

    Let me chase up the Greezly I modified and you can try it yourself.. If nothing else it was great for learning coding and trimming up my trading style.

     

    For the last three posters here, if you want the new EA (no Name yet), I will upload it and PM you the address if you want it.

     

    It is not finished but it has a few original ideas in the code.

     

    I am running control points at this time because its still in development. The image is about 8 months of trading

     

    http://img200.imageshack.us/img200/8120/7801.gif

  11. Re: Building your own EA G/08.

     

    ok.. I am no coder but I am not sure why your code multiplies by 10..

     

    the computer would see, for example say your stop-loss is set at 50 points. 50 * 10 is 500 where it needs to be (I would think) 50 * 0.0001 or 0.005 of the currency price.

     

    Although it is hard to tell what else you have in there.. maybe it is possible it is seeing it as 500 times the base currency?

     

    I have a bunch of snippets.. here is one that is complete and I believe would work for the calculations. Or you could just use *Point

     

    int      digit=0;
    double   point;
    
    
    //+-------------------------------------------------------------------------------------------+
    //| expert initialization function                                                            |
    //+-------------------------------------------------------------------------------------------+
    
    int init()
     {
    //----
    
      if (Digits == 3 || Digits == 5) {
         if (Digits == 3)
            point = 0.01;
         else
            point = 0.0001;
      }
      else point = Point;
    
    //----
      return(0);
     }
     
     //+-------------------------------------------------------------------------------------------+
    //| expert start function                                                                     |
    //+-------------------------------------------------------------------------------------------+
    
    int start()
    {
    //----
    digit  = MarketInfo(Symbol(),MODE_DIGITS);
    
    

  12. Re: Building your own EA G/08.

     

    to get rid of your errors..

     

    paste these in to your EA under init

     

      
      if(TakeProfitB  != 0)  TakeProfitB  = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), TakeProfitB);
      if(TakeProfitS  != 0)  TakeProfitS  = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), TakeProfitS);
      if(StopLossB    != 0)  StopLossB    = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), StopLossB);
      if(StopLossS    != 0)  StopLossS    = MathMax(MarketInfo(Symbol(), MODE_STOPLEVEL), StopLossS);
    
    

  13. Re: Building your own EA G/08.

     

    Here is some break even code.. to change the digits on either lots of code, I just take remove a digit from the settings... e.g 600 on a five digit broker is 60 on a four digit broker.

     

    BTW.. I am not sure this break-even code works I didn't try it.

     

    
        if(UseBreakeven)
      {
      for(int i=0;i<OrdersTotal();i++)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)        break;
         if(OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
         
         if(OrderType() == OP_BUY)
          
         if(breakeven>0)  
                 {                
                  if(Bid-OrderOpenPrice() > (Point*breakeven))
                    {
                     if(OrderStopLoss() != OrderOpenPrice() && OrderStopLoss() < OrderOpenPrice())
                       {
                        OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
                        //Print("Moved Buy to Breakeven");
                        return(0);
                       }
                    }
                 } 
                        
         if(OrderType()==OP_SELL)
    
         if(breakeven>0)  
                 {                 
                  if((OrderOpenPrice()-Ask)> (Point*breakeven))
                    {
                     if(OrderStopLoss() != OrderOpenPrice() && OrderStopLoss() > OrderOpenPrice())
                       {
                        OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
                        //Print("Moved Sell to Breakeven");
                        return(0);
                       }
                    }
                 }     
        } 
        }
        
    

  14. Re: Building your own EA G/08.

     

    I had to resurrect some of the Greezly code because I had too many pieces related that I didn't know about until I ran it through its tests. I found some functionally missing and one important part.. the Limit Distance wasn't working. I only used the high low limit for the logic though. The flat, iAC and speed indicators were gone.

     

    here is the code that I used for my trailing stop.

     

    
    extern double BuyTrailingStop               = 320;
    extern double SellTrailingStop              = 380;     // How far into the trade the trailing stop should be set.
    extern double StepTrailingStop              = 40; 
    
    
           if(BuyTrailingStop > 0)  total = OrdersTotal();
             {
              for(i = 0; i < total; i++){
              OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
              if(OrderSymbol() != Symbol())  continue;   //
              if(OrderType() == OP_BUY){
              if(Bid > (OrderOpenPrice() + Point * BuyTrailingStop)){
              if((OrderStopLoss() == 0) || (OrderStopLoss() < (Bid - Point * (BuyTrailingStop + StepTrailingStop)))){
              OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * BuyTrailingStop, OrderTakeProfit(), 0);}}}}
             }      
                 
           if(SellTrailingStop > 0) total = OrdersTotal();
             {
              for(i = 0; i < total; i++){
              OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
              if(OrderSymbol() != Symbol())  continue;   //
              if(OrderType() == OP_SELL){       
              if(Ask < (OrderOpenPrice() - Point * SellTrailingStop)){
              if((OrderStopLoss() == 0) || (OrderStopLoss() > (Ask + Point * (SellTrailingStop + StepTrailingStop)))){
              OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * SellTrailingStop, OrderTakeProfit(), 0);}}}}
              } 
    
    

  15. Re: Building your own EA G/08.

     

    Actually I've been working on an EA of my own for a while. It's based off the Steinitz Fractal Breakout indicator (except it doesn't rely on the indicators). It's hugely profitable... on any timeframe on any currency, except that I can't quite get the rules working right. I could use some help. Maybe I will borrow somew of the ideas introduced here.

     

    Great stuff when you get it going, why don't you post a backtest or vid for us? So pleased to see someone doing something different.

     

    We have a saying where I come from.. if you do what everyone else does, you will get what everyone else gets. If you do something outstanding, you will get what everyone else wants.

  16. Re: Building your own EA G/08.

     

    Ok this is where I ended up when I put in all the rules.. actually it has a loss of 80c in there somewhere on a spike, so only 190 wins but not too bad overall.

     

    [center:1plw25c8]http://img14.imageshack.us/img14/5356/finalfj.gif[/center:1plw25c8]

     

    Full backtest is here http://rapidshare.com/files/298104702/final.rar

     

    Last post on this subject unless someone wants to know something..

     

    Food for thought though.. those rules would be good for any EA that is halfway profitable to begin with.

  17. Re: Building your own EA G/08.

     

    Ok.. this is where I ended up about 3 or 4 days ago with the greezly logic in a new EA with only the first three rules posted here.

     

    I threw out everything in the logic except the high/low limits.

     

    Since that time I have introduced my rules to lower drawdown with fair sucess. I have one rule to go and I will post the results.

     

    The addition of the rules lowers the profit level to around 600,000 but also lowers the draw down to around 18% so far. I am trying to improve it and I have some ideas and I still need to tweak the rules after I have finished adding them.

     

    I will post the results as soon as I get the drawdown to under 10% and the profit over 700. Hopefully that will be soon.

     

    http://img16.imageshack.us/img16/1781/1000000d.gif

     

    There are only six rules so far and 3 of them I have posted already.

     

    Here are two more.. you might need to tweek them a bit cause I will. They are somewhat rough but very effective (and costly). If you have not managed to get though the last few months.. these will do it for you.

     

               if (BearDAY && MarketHigh) // Rule 4. If last day is a bearish Engulfing pattern do not buy for this day. Set Time of The pattern
               static int SetEventTime;   
               static bool EnglufEvent=false;  
               {
               if ((HiLowDelta_0 + (iHigh(NULL,PERIOD_D1,1)-iOpen(NULL,PERIOD_D1,1)) > 200*0.0001) && (HiLowDelta_0 >= HiLowDelta_1) && (DifBullClsBearOpn <= 0.002))
                    {
                    if (type == _OP_BUY) MayOpenDeferOrder = false; 
                     if (!EnglufEvent)   EnglufEvent=true; SetEventTime=Time[0]; 
                    }
               }
               
    
              if (EnglufEvent)  //Rule 4a While the time since the last Bear Engulf is recent. Set trade hour to Midday. 
               {                 //Set buy price lower than normal. While each day low is lower than the previous by more than 30 points, don't buy.
               if(((TimeCurrent()-SetEventTime)/60/60)>= hours)EnglufEvent=false;
               if (EnglufEvent ==true) BuyDistance = 700; //if (EnglufEvent ==true && (Ask + BuyStopLevel) > iLow(NULL,PERIOD_D1,1)) MayOpenDeferOrder = false;
               if ((EnglufEvent ==true)&&(DayOfWeek()==1) && (Hour() <= 12) && MathAbs(iOpen(NULL,PERIOD_D1,0) - iClose(NULL,PERIOD_D1,1)) > 0) MayOpenDeferOrder = false;
               if ((EnglufEvent ==true) && (iHigh(NULL,PERIOD_D1,2)- iClose(NULL,PERIOD_D1,1) > 0.003)) MayOpenDeferOrder = false; 
               if (EnglufEvent ==false)BuyDistance = 1500; }
               
              // if (BearDAY && HiLowDelta_1 > 200 *Point) { 
              // if (HiLowDelta_0 < 35*Point && (DifBullClsBearOpn <= 0.002) && (iLow(NULL,PERIOD_D1,1)-iClose(NULL,PERIOD_D1,1) > HiLowDelta_0 *4)) BuyTrailingStop = 20 * Point} 
               
               if (type == _OP_BUY)           
               static int SetDojieTime;   // provide a "Declare Event Time"
               static bool DojieEvent=false; 
               double DayAngle= (iMA(NULL,0,1440,0,MODE_EMA,PRICE_CLOSE,1)-iMA(NULL,0,1440,0,MODE_EMA,PRICE_CLOSE,5));
                 {
                  if ((MarketHigh && (iHigh(NULL,PERIOD_D1,2) < iHigh(NULL,PERIOD_D1,1) && HiLowDelta_0 < 20 *0.0001))
                 ||((DayAngle < 0 && BullDAY) && (iHigh(NULL,PERIOD_D1,2) < iHigh(NULL,PERIOD_D1,1) && HiLowDelta_0 < 20 *0.0001)))
                  {
                    MayOpenDeferOrder = false; //Prevent any buy orders for the day
                     if (!DojieEvent)   DojieEvent=true; SetDojieTime=Time[0]; }}
                     
              if (DojieEvent)  //Rule 5// If it is not false, 
               { 
               if(((TimeCurrent()-SetDojieTime)/60/60)>= hours)DojieEvent=false;
               if (DojieEvent ==true) BuyDistance = 700; //if (EnglufEvent ==true && (Ask + BuyStopLevel) > iLow(NULL,PERIOD_D1,1)) MayOpenDeferOrder = false;
               if ((DojieEvent ==true)&&(DayOfWeek()==1) && (Hour() <= 12) && MathAbs(iOpen(NULL,PERIOD_D1,0) - iClose(NULL,PERIOD_D1,1)) > 0) MayOpenDeferOrder = false;
               if ((DojieEvent ==true) && (iHigh(NULL,PERIOD_D1,2)- iClose(NULL,PERIOD_D1,1) > 0.003)) MayOpenDeferOrder = false;     
               if (DojieEvent ==false)BuyDistance = 1500; }// Print ("EnglufEvent is true");
               
    

     

    If you have any questions on how these work.. just ask and I will be happy to answer.

     

    A summary is that.. first rule is a "day bear engulfing pattern" if such an event is true, dont trade for that day and set a timer.

    After that day and while the timer is active. Don't buy as high and change the tradehour to midday. If the market is still droping at more than 300 points per day don't buy.

    When the timer expires set things back to normal

    Second rule.. says the same thing except it applies for a dojie pattern.

     

    Hope this is helpful.

     

    Hopefully.. a dojie arrives before the bear... very often the case. If I was trading manually and I saw these patterns, I would wait... my EA should do the same.

     

      
         bool   BullDAY =           (iClose(NULL,PERIOD_D1,2)>= iOpen(NULL,PERIOD_D1,2));
         bool   BearDAY=            (iOpen(NULL,PERIOD_D1,1) >= iClose(NULL,PERIOD_D1,1));
         double Highest5DayOpn=     iOpen(NULL, 1440, iHighest(NULL, 1440, MODE_OPEN,5,1)); 
         double HiLowDelta_1=       MathAbs(iOpen(NULL,PERIOD_D1,2)-iClose(NULL,PERIOD_D1,2));
         double HiLowDelta_0=       MathAbs(iClose(NULL,PERIOD_D1,1)-iOpen(NULL,PERIOD_D1,1));
         bool   MarketHigh =        (lastOpen >= Highest5DayOpn);
      

  18. Re: TOO GOOD TO BE TRUE???, PLEASE HELP EDUCATE non scalper!!!

     

    This is the code.. just paste it into notepad and save is as induk.mq4.

    I didn't try it but is should work now.

    The other file is fine.

     

    /*
      Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
      Website: [url]http://purebeam.biz[/url]
      E-mail : [email][email protected][/email]
    */
    #property copyright "Copyright © 2009, Igor Kuzmin"
    #property link      "[email protected]"
    #property library
    
    int gi_76;
    int gi_84;
    int g_file_88;
    int gia_92[];
    double gda_96[];
    double gda_100[];
    
    int init() {
      double ld_4;
      double ld_12;
      double ld_20;
      g_file_88 = FileOpenHistory(Symbol() + Period() + ".hst", FILE_BIN|FILE_READ);
      gi_76 = (FileSize(g_file_88) - 148) / 44;
      ArrayResize(gia_92, gi_76);
      ArrayResize(gda_96, gi_76);
      ArrayResize(gda_100, gi_76);
      FileSeek(g_file_88, 148, SEEK_SET);
      for (int l_index_0 = 0; l_index_0 < gi_76; l_index_0++) {
         gia_92[l_index_0] = FileReadInteger(g_file_88, LONG_VALUE);
         ld_4 = FileReadDouble(g_file_88, DOUBLE_VALUE);
         gda_100[l_index_0] = FileReadDouble(g_file_88, DOUBLE_VALUE);
         gda_96[l_index_0] = FileReadDouble(g_file_88, DOUBLE_VALUE);
         ld_12 = FileReadDouble(g_file_88, DOUBLE_VALUE);
         ld_20 = FileReadDouble(g_file_88, DOUBLE_VALUE);
         if (GetLastError() == 4099/* END_OF_FILE */) break;
      }
      return (0);
    }
    
    int signal(int &aia_0[]) {
      int li_16;
      int li_20;
    /*
      if (!IsTesting()) {
         Alert("This version is for testing ONLY!");
         return (0);
      } */
      int li_4 = aia_0[0] + aia_0[1] + aia_0[2] + aia_0[3] + aia_0[4] + aia_0[5];
      if (li_4 < 10) li_4 = 10;
      int l_timeframe_8 = Period();
      if (l_timeframe_8 < PERIOD_D1 && l_timeframe_8 > 0) li_4 = NormalizeDouble(li_4 * MathLog(4320 / l_timeframe_8), 0);
      if (IsTesting()) {
         for (int li_12 = gi_84; li_12 < gi_76; li_12++) {
            if (gia_92[li_12] >= Time[0]) {
               gi_84 = li_12;
               break;
            }
         }
         li_16 = ArrayMaximum(gda_96, 2 * li_4, MathMax(gi_84 - li_4, 0));
         li_20 = ArrayMinimum(gda_100, li_4 * 2, MathMax(gi_84 - li_4, 0));
         if (gi_84 == li_16 && gi_84 < gi_76 - 3) {
            aia_0[6] = -1;
            return (-1);
         }
         if (gi_84 == li_20 && gi_84 < gi_76 - 3) {
            aia_0[6] = 1;
            return (1);
         }
      }
      double l_istochastic_24 = iStochastic(NULL, 0, aia_0[0], aia_0[1], aia_0[2], aia_0[3], aia_0[4], MODE_MAIN, 0);
      return (0);
    }
    
    

  19. Re: Building your own EA G/08.

     

    OK.. here is some code I wrote.. Not working as it is supposed to, so if anyone knows why.. I would be pleased to hear the solution.

     

    This is a bearish engulfing pattern on a timer.. The timer works great and I was really happy with it..

     

    What does not work great is the code that is supposed to kick in at a market high..

     

    It kicks in anytime it feels fit and not necessarily at a market high.. :huh:

     

    In addition.. it sees each Monday zero bar as a bear bar when it may not be.. so I am stumped.

     

     

         extern int   EnglufSleepHours               =39;
         extern double EngulfingBarsize              =40; 
    
         bool   MarketHigh =        (lastOpen >= Highest5DayOpn);
         bool   Bar4Bear =          (iOpen(NULL,PERIOD_H4,1) >= iClose(NULL,PERIOD_H4,1));
         bool   Bar4Bull =          (iClose(NULL,PERIOD_H4,1)>= iOpen(NULL,PERIOD_H4,1));
         double Delta4HL_0 =        MathAbs(iClose(NULL,PERIOD_H4,1)-iOpen(NULL,PERIOD_H4,1));
         double Delta4HL_1 =        MathAbs(iOpen(NULL,PERIOD_H4,2)-iClose(NULL,PERIOD_H4,2));
         double Dif4ClsOpn =        ((iClose(NULL,PERIOD_H4,2)-0.0002)-iOpen(NULL,PERIOD_H4,1));
    
    
    
       if (Bar4Bear && iHigh(NULL,PERIOD_H4,1) > iHigh(NULL,PERIOD_H4,2)) int xz=EngulfingBarsize; 
         {
           static int EngulfTime; static bool Engulfed=false;
           if  ((MarketHigh) &&((Delta4HL_0 + (iHigh(NULL,PERIOD_H4,1)-iOpen(NULL,PERIOD_H4,1))) > 
           xz*Point) && (Delta4HL_0 >= Delta4HL_1) && (Dif4ClsOpn <= 0.0004)&& !Engulfed){             
           EngulfTime = iTime(NULL,PERIOD_H4,0); Engulfed = true;
           if (Engulfed) Print("Buy is Sleeping Util : " + TimeToStr(EngulfTime,TIME_DATE|TIME_MINUTES)); }   //Note the string needs fixing 
           if(((TimeCurrent()-EngulfTime)/60/60)<EnglufSleepHours && Engulfed) UseBuy=0; UseSell=1;
           if(((TimeCurrent()-EngulfTime)/60/60)>=EnglufSleepHours)Engulfed=false;
          }  
          
       if (!Engulfed) 
         {
          UseBuy=1; UseSell=0;
         }
    
    

     

    Anyway.. if anyone feels like using it.. you will need to solve that problem and I would appreciate an update if you get it going. Else when I find out what I have done wrong.. I will post the solution.

×
×
  • Create New...