[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 259

 

Good day to this thread! You know, the indicator compiles, but it doesn't draw anything, and I don't know what's wrong, what to think, how to look for a bug. Anyway, the code worked, I added a function to it with minimal changes, but now it does nothing at all!!!

Maybe the problem is somewhere in the declarations that begin with the grid, or maybe I'm too slow and messed up... It was working!

//+------------------------------------------------------------------+
//|                                            ИндюкДимонакомпил.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#import "user32.dll"
   int   PostMessageA(int  hWnd,int  Msg,int  wParam,string lParam);
#import
#define WM_COMMAND                     0x0111
int delimiter = 0;

#property indicator_chart_window
double ВерхняячертаBuffer1[];
double НижняячертаBuffer2[];
double СинняячертаBuffer3[];
 double вершина; 
 double основание_первого_снижения;
 double начало;
 double вершина_волны_3;
 extern int T=4,K=200;
 int timeframe, start ;
 int бар_вершина ;
 int бар_основание_первого_снижения;
 int бар_начало;
int pereklutsatel;
double naklon,linija2; int P;extern int RO=49;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit=Bars-counted_bars-1;

   for (int i=limit;i>=0;i--) {
//----
 for ( int J=0;J<=RO;J++){
//----

  // for(int i=Bars; i>=0;i--)
   i=Bars;
      бар_вершина=iHighest( NULL,  timeframe, MODE_HIGH, K, start ) ;
       вершина =High[ бар_вершина ];
       бар_основание_первого_снижения=iLowest( NULL,  timeframe, MODE_LOW,NormalizeDouble ( бар_вершина/2,0), start ) ;
       основание_первого_снижения=Low[ бар_основание_первого_снижения ];
       бар_начало=iLowest( NULL,  timeframe, MODE_LOW,NormalizeDouble (бар_вершина*1.5,0), бар_вершина ) ;
       начало=Low[ бар_начало ];
       
         
  if(начало>основание_первого_снижения){naklon=(начало-основание_первого_снижения)/(бар_начало-бар_основание_первого_снижения);
  
    НижняячертаBuffer2[бар_начало]=начало;linija2=начало;for(i=бар_начало-1;i>=0;i--){linija2=linija2-naklon;
    
    НижняячертаBuffer2[i]=linija2;
     
   }
    НижняячертаBuffer2[бар_основание_первого_снижения]=основание_первого_снижения;}
    
    
         for (i=0;i<100;i++){  СинняячертаBuffer3[i]= Open[i];}
          for (i=330;i<500;i++){  СинняячертаBuffer3[i]= Open[i];}

     ВерхняячертаBuffer1[бар_начало]=начало;
     
 double точка4; int бар_точка4;   бар_точка4=iHighest( NULL,  timeframe, MODE_HIGH, бар_основание_первого_снижения, 3 ) ; 
  точка4 =High[ бар_точка4 ];  
   
   if(вершина>точка4){naklon=(начало-точка4)/(бар_начало-бар_точка4);  
   double linija1=начало;for(i=бар_начало-1;i>=0;i--){linija1=linija1-naklon;ВерхняячертаBuffer1[i]=linija1; }}
   
double vulf=НижняячертаBuffer2[0];
  if ( vulf==Ask&&vulf==Bid)vulf=1;
  else{ for (vulf=vulf+Point*10; vulf==НижняячертаBuffer2[0];vulf=vulf-Point){
           if ( vulf==Ask&&vulf==Bid){vulf=1;}} 
      for (vulf=vulf-Point*10; vulf==НижняячертаBuffer2[0];vulf=vulf+Point){
           if ( vulf==Ask&&vulf==Bid)vulf=1;} 
              
           
           
           }
           
           
   if (vulf==1){Comment ("  Есть вульв!!! "  , "  timeframe " , timeframe);return(0);  }
    if (vulf!=1&&pereklutsatel==1) {    
   
     if(delimiter<3){delimiter++;Comment(delimiter);return(0);}
   delimiter=0;
    fChangePeriod();P++;
                                 
                   }  } }
//----
   return(0);
  }
//+------------------------------------------------------------------+

void fChangePeriod(){int ii,hwd = WindowHandle(Symbol(),Period());
   switch(Period()){
      case PERIOD_W1    : ii = 33134; break; //PERIOD_D1;
      case PERIOD_D1    : ii = 33136; break; //PERIOD_H4;
      case PERIOD_H4    : ii = 33135; break; //PERIOD_H1;
      case PERIOD_H1    : ii = 33140; break; //PERIOD_M30;
      case PERIOD_M30   : ii = 33139; break; //PERIOD_M15;
      case PERIOD_M15   : ii = 33138; break; //PERIOD_M5;
      case PERIOD_M5    : ii = 33137; break; //PERIOD_M1;
      case PERIOD_M1    : ii = 33141; break; //PERIOD_W1;
   }     
   PostMessageA(hwd, WM_COMMAND, ii, 0);
   return;
}
 
skyjet:
Thank you very much! So the EA trades on ticks, but can I change it to trade on intervals (candlesticks)? I am totally confused with it.

It is difficult to say, I have not done it that way. Maybe you need to somehow remember a bar or candlestick and if the next one appears, then... something is up. The code written inside the start function is executed on every tick, and what's already written there is what the programmer wrote.
 
Please answer the following question: let's assume two sell and buy orders open simultaneously with the same TP=SL =100 pips. The market went only in one direction and both TP and SL have triggered. Does the trader stay in the loss due to spread, or everything is zero? Since there are builds and askkens, we'd better ask you to solve this puzzle. It seems to me that it should be zero because we have to consider this spread when opening orders. Thank you.
 
yosuf:
Please answer the following question: let's assume two sell and buy orders open simultaneously with the same TP=SL =100 pips. The market went only in one direction and both TP and SL have triggered. Does the trader stay in the loss due to spread, or everything is zero? Since we have builds and askkens, it would be better to entrust you with solving this puzzle. I have builds and asks and I prefer to let you solve this puzzle. Thank you.
No zeros. Definitely in the red.
 
yosuf:
Please answer the following question: let's assume two sell and buy orders open simultaneously with the same TP=SL =100 pips. The market went only in one direction and both TP and SL have triggered. Does the trader stay in the loss due to spread, or everything is zero? Since we have builds and askkens, it would be better to entrust you with solving this puzzle. I have builds and asks and I prefer to let you solve this puzzle. Thank you.

If you (hypothetically) assume that you manage to open two opposite orders simultaneously, then you will immediately find yourself in the red, no matter which way the price goes.
 
DmitriyN:
No zeros. Definitely in the negative.
How much is in minus? If we make TP = 104 and SL = 100, will it be zero? TP=SL + 2*spread?
 
yosuf:
And how much is in minus? If you make TP = 104 and SL = 100, will it be zero?

Am I the only one who thinks you are trolling?
 
PapaYozh:

Am I the only one who thinks you are trolling?
It's a normal question for a novice trader. Yusuf doesn't joke about such things. Don't forget that his newly acquired knowledge is still of a virtual nature.
 
granit77:
A normal question for a novice trader. Yusuf does not joke about such things. Don't forget that his newly acquired knowledge is still of a virtual nature.

Thank you, for a tested TP, the described option is an emergency, so, wanted to go to a clean zero in such situations. I do not need anything from the TA services, in principle, but as insurance against unidirectional movement, I think it can save. As it is, I expect volatility of the market within these limits of TP and SL.
 
granit77:
A normal question for a novice trader. Yusuf does not joke about such things. Don't forget that his newly acquired knowledge is still of a virtual nature.


Come on, he's been entertaining us for a year and a half now :)