Indicator Question - page 8

 
heelflip43:

I think your trouble is in you haven't reset val1 and val2. So once you've found the high and last low you need to reset them:

Hopefully that will help.
Ahhh, I'll try it once I boot to windows later today, thanks

I thought that if the first if(statement) was true, then it would have restarted the start() again and reset from the top of the code and thus reset val1 and val2 again

Well, the way I was thinking about it was - if(first statement) true then prints, and then moves to text the next if(second) likely false then goes back to the top of the start again and resets val1 and val2

I'm getting the correct prints and values but just prints continuously.

Now that I think of it I really never figured this out for any if(statement) even the simplest of EMA crosses produces continuous printings

I'll test your code you posted but I would be surprised if I added print statements to print those variables and it did not also print continuously

I'll try it out later today

Thanks
 
Ok yes resetting val1 and val2 will give me back A high's but still printing everything continuously, not as many as before.
I'm sure I have to do something with currentTime and iTime to get this fixed, I'll have to review it some more.

Seems like there should already be an ABCD scheme in the code base to learn from but this seems to be something that is not available except for based on ZigZag which I am reviewing now to see if this gives me any clues. But again this is also an indicator

Anyhow if I add && macd or something it only prints them once, which is really throwing me off
 
I think I have it, after some more thoughts on it and working through it a bit more

How about this:

//+------------------------------------------------------------------+
//|                                                  Agent86_5min.mq4 |
//|                                                    Unfinished POS |
//|                                    
//+------------------------------------------------------------------+
#property copyright "Unfinished POS by Agent86"


//---- input parameters
extern double    TakeProfit=20.0;
extern double    Lots=0.1;
extern double    StopLoss=10.0;
extern int MagicNumber=123486;

double val1;
double val2;
bool traded = false;
bool A = false;

//++++ These are adjusted for 5 digit brokers.

int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)

    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if (Digits == 5 || Digits == 3)
   {    // Adjust for five (5) digit brokers.
      pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
   } 
   else 
    {    
      pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; 
    }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
     
   
    
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
    
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   
        
   int i=0;
   int ticket,total,result;
   total = OrdersTotal();                 
   val1=iFractals(NULL, 0, MODE_UPPER,3);
   val2=iFractals(NULL, 0, MODE_LOWER,3); 


     
     if(val1 > 0 && traded == false && val2==0)
      { 
      // in the absence of an && indicator above I get continous print statements
      // also does not print A high this is not desired
      // with indicator added && indicator above, then it prints A and B once as it should ???
      // I need to work this out so it won't print all the time aka trade all the time
      // A and B first values seems to initialize the whole block
      // just a reminder that they time stamps coordinate after this FYI
      // now work on C retrace and possibly signals
      // add options for user to select some candle patterns
      // add options to select indicators
      // add bells and whistles to make things fun
      // alerts,sounds,maybe poppup video animation or something
      
      double B = val1;
      Print(B, " B high");
         if(val2==0)
            {
            for (i=0; val2==0; i++)
               {
               val2=iFractals(NULL, 0, MODE_LOWER, i);
               double A = val2;
                  if(A!=0)
                     {
                     Print(A, " A low");
                     }
               }
             }  
      traded=true;
      }
     
     val1=iFractals(NULL, 0, MODE_UPPER,3);
     val2=iFractals(NULL, 0, MODE_LOWER,3); 
     
     if(val2 > 0 && traded == true && val1 == 0)
      {
      B = val2;
      Print(B, " B low");
         if(val1==0)
            {
            for (i=0; val1==0; i++)
               {
               val1=iFractals(NULL, 0, MODE_UPPER, i);
               A = val1;
                  if(A!=0)
                     {
                     Print(A, " A high");
                     }
               }
             }  
      traded=false;
      }
     
                    
                
   return(0);
  }    

//+------------------------------------------------------------------+


      

This only prints once when adding

if(val1 > 0 && traded == false && val2==0)

and

if(val2 > 0 && traded == true && val1 == 0)


So I'm getting a little closer naw I can evaluate it some more.

Thanks for the help all, this was a giant help because it game me the ideas to fix this and expanded my knowledge a bit more about resetting things too.
I have to keep that in my back pocket

Thanks

 

I'm not getting the problem most of the time. It seems that it only happens when there is a upper and lower fractal in the same bar which happens in uncertain markets sometimes. The only way around this is only run the calculation once a bar so:

static datetime currTime;
if(Time[0]!=currTime){
currTime = Time[0];
// Rest of code
}

That should mean that it won't get false traded on fractals going both ways.

 
Now I can start working through the rest of it, I just wish I was experienced enough to understand the conversion of an iCustom indicator to an EA then I would probably have already had this worked out a long time ago.

The way I'm doing it now will be more complicated because I still have to add iCustom indicators along side of my code logic; and all the bells and whistles instead of using an already working iCustomer indicator as my code logic

Anyhow thanks again great news for the day.
 
Or your solution would work as well, I was in the middle of testing my theory and didn't see your post.
 
heelflip43:

I'm not getting the problem most of the time. It seems that it only happens when there is a upper and lower fractal in the same bar which happens in uncertain markets sometimes. The only way around this is only run the calculation once a bar so:

That should mean that it won't get false traded on fractals going both ways.

I need to learn how this part works a little better I've seen it before and other similar versions but only understanding partly

I need to study this some more. This may be where I'm loosing most of my codes due to the continuous print statements when testing.

I'm sure there is other ways around it and yet I do plan to also create the indicator for this and draw the lines from AtoB etc.

I'll study some more
 
Here is some progress I made so far

Maybe someone can make good use of it, I'm sure it can be revised better by a guru

Anyhow it's printing what I want and I added some extern values for fibo levels so the users can select which levels they might want

My first code contribution to the forums LOL

Anyone have a better way to occomplish this task I already anticipate doubling down on code due to adding iCustom indicators to show what my code is doing but this means sort of double coding for an array buffer etc. and then using iCustom

Anyhow here is what I got

//+------------------------------------------------------------------+
//|                                          Unfinished_POS_slate.mq4 |
//|                                                    Unfinished POS |
//|                                    
//+------------------------------------------------------------------+
#property copyright "Unfinished POS slate by Agent86"


//---- input parameters
extern double    TakeProfit=20.0;
extern double    Lots=0.1;
extern double    StopLoss=10.0;
extern int MagicNumber=123486;
extern double fibo_retrace=0.500; //this is C retracement level
extern double fibo_extension=1.618;  // coming soon, D extention 


double val1;
double val2;
bool traded = false;


//++++ These are adjusted for 5 digit brokers.

int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)

    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if (Digits == 5 || Digits == 3)
   {    // Adjust for five (5) digit brokers.
      pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
   } 
   else 
    {    
      pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; 
    }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
     
   
    
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
   
    
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   
        
   int i=0;
   int ticket,total,result;
   total = OrdersTotal();                 
   val1=iFractals(NULL, 0, MODE_UPPER,3);
   val2=iFractals(NULL, 0, MODE_LOWER,3); 

     
     if(val1 > 0 && val2 == 0 && traded == false)
      { 
      double B = val1;
      Print(B, " B high");
      if(val2==0)
         {
         for (i=0; val2==0; i++)
            {
            val2=iFractals(NULL, 0, MODE_LOWER, i);
            double A = val2;
            if(A!=0)
              {
              Print(A, " A low");
              }
            }
          }
       double C = B-(B-A)*fibo_retrace; //retrace 50% no fractal
       Print(C, " UP ABC retrace level");
       if(Bid <= C)
         {
         Print (Bid, " UP ABC C Retrace Hit");
         }  
      
      
      traded=true;
      }
     
     //val1=iFractals(NULL, 0, MODE_UPPER,3); been suggested I might need to reset these here
     //val2=iFractals(NULL, 0, MODE_LOWER,3); I'll investigate this some more
     
     
     if(val2 > 0 && val1 == 0 && traded == true)
      {
      B = val2;
      Print(B, " B low");
      if(val1==0)
        {
        for (i=0; val1==0; i++)
           {
           val1=iFractals(NULL, 0, MODE_UPPER, i);
           A = val1;
           if(A!=0)
             {
              Print(A, " A high");
             }
           }
        }        
             
        C = B+(A-B)*fibo_retrace; //retrace 50% no fractal  //recheck my math on this one
        Print(C, " DOWN ABC retrace level");
        if(Bid <= C)
           {
           Print (Bid, " DOWN ABC C Retrace Hit");
           } 
                 
      traded=false;
      }
     
                    
                
   return(0);
  }    

//+------------------------------------------------------------------+
With my limited knowledge and experience this is all I could come up with for an ABCD scheme

I'll work on it more to allow user to change A's and B's to levels that do not breach previous A's and B's in order to truly stay within a trend etc.

Hope someone can use this or perhaps can add to it with some better ideas

Now I'll work on candle patterns and indicators to add to it or something, and popup alerts, maybe sounds and some popup video might be fun

Thanks for for the help all.

 

Доброго времени суток уважаемые форумчане!

Меня зовут Герман, мне 23 года, я являюсь трейдером компании "Инстафорекс"

Помогите в поиске нужного скрипта! Скрипт нужен для сетки отложенных ордеров.

 
GERICH:

Доброго времени суток уважаемые форумчане!

Меня зовут Герман, мне 23 года, я являюсь трейдером компании "Инстафорекс"

Помогите в поиске нужного скрипта! Скрипт нужен для сетки отложенных ордеров.

Dude I'm not interested in InstaForex and if you want a grid script please post a project in the coders for hire section
And Please post in English

Happy trading
Reason: