[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 279

 

Please give me a hint. I haven't quite figured out how indicators work yet. My indicator does not draw when I change timeframe, and it draws once in a while. But sometimes it does, and it works exactly as I wanted it to! Please tell me what it needs.

//+------------------------------------------------------------------+
//|                                            ИндюкДимонакомпил.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

#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 DarkBlue
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=-1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

SetIndexStyle(0,DRAW_SECTION,STYLE_SOLID,2,CLR_NONE);//Alert ("SetIndexStyle ",GetLastError( ) );
  SetIndexBuffer(0,ВерхняячертаBuffer1);//Alert ("SetIndexBuffer ",GetLastError( ) );
   SetIndexEmptyValue(0,0.0);
   
   SetIndexStyle(1,DRAW_SECTION,STYLE_SOLID,2,CLR_NONE);//Alert ("SetIndexStyle ",GetLastError( ) );
  SetIndexBuffer(1,НижняячертаBuffer2);//Alert ("SetIndexBuffer ",GetLastError( ) ); 
   SetIndexEmptyValue(1,0.0);
   
   SetIndexStyle(2,DRAW_SECTION,STYLE_SOLID,T,CLR_NONE);//Alert ("SetIndexStyle ",GetLastError( ) );
  SetIndexBuffer(2,СинняячертаBuffer3);//Alert ("SetIndexBuffer ",GetLastError( ) ); 
   SetIndexEmptyValue(2,0.0);
   
   
  ObjectDelete("вершина");
  ObjectDelete("основание_первого_снижения  ");
   ObjectDelete("начало");
    ObjectDelete("точка4");
    ObjectDelete("пятая_точка!");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("вершина");
  ObjectDelete("основание_первого_снижения  ");
   ObjectDelete("начало");
    ObjectDelete("точка4");
    ObjectDelete("пятая_точка!");
   ObjectsDeleteAll(WindowOnDropped( ) , OBJ_TEXT);
//----
   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[ бар_начало ];
       
   ObjectCreate( "вершина",  OBJ_TEXT , WindowOnDropped( ) , Time[бар_вершина],  вершина+(10*Point)) ; 
    ObjectSetText( "вершина", "вершина", 5, "вершина",Crimson ) ;// Alert("GetLastError()",GetLastError());
      // ObjectSet(  "вершина",  OBJPROP_COLOR, Crimson) ;
      
   ObjectCreate( "основание_первого_снижения",  OBJ_TEXT , WindowOnDropped( ) , Time[бар_основание_первого_снижения],  основание_первого_снижения-(10*Point)) ; 
    ObjectSetText( "основание_первого_снижения", "основание_первого_снижения", 5, "основание_первого_снижения",Crimson ) ;   
   
    ObjectCreate( "начало",  OBJ_TEXT , WindowOnDropped( ) , Time[бар_начало],  начало-(10*Point)) ; 
    ObjectSetText( "начало", "начало", 5, "начало",Crimson ) ;   
           
  if(начало>основание_первого_снижения){naklon=(начало-основание_первого_снижения)/(бар_начало-бар_основание_первого_снижения);
 // Alert("naklon  ", naklon);
    НижняячертаBuffer2[бар_начало]=начало;linija2=начало;for(i=бар_начало-1;i>=0;i--){linija2=linija2-naklon;
   
    НижняячертаBuffer2[i]=linija2;  // Alert ("linija2  " , linija2 ); 
     Alert("НижняячертаBuffer2[i]  ", НижняячертаBuffer2[i] , "  i " , i);
     
   }
    Нижняячерта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);
   ObjectCreate( "точка4",  OBJ_TEXT , WindowOnDropped( ) , Time[бар_точка4],  точка4+(10*Point)) ; 
    ObjectSetText( "точка4", "точка4", 5, "точка4",Crimson ) ;  
   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;}
 if (vulf+(10*Point)>Ask&&vulf-(10*Point)<Bid){vulf=1 ;} 
           
      Alert ("vulf  " , vulf );   Comment ("  vulf!!! "  , vulf);  
   if (vulf==1){Comment ("  Есть вульв!!! "  , "  timeframe " , timeframe);
   ObjectCreate( "пятая_точка!",  OBJ_TEXT , WindowOnDropped( ) , Time[0],  Bid-(10*Point)) ; 
    ObjectSetText( "пятая_точка!", "пятая_точка!", 5, "пятая_точка!",Crimson ) ;   return(0);  }
    if (vulf!=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;
}
 
drknn:

You could put the ticket in global variables as well. :) You can roll the hell out of it at all. But as an idea selection of the order before modification will work. Only if it is not necessary to reset lots only 1 time for the whole order lifetime (with a single modification at that) :) :).

In short, there are a lot of variants :).

You can do it globally as well. But the terminal writes them into a file before closing (if memory serves me correctly). I.e. it will not save from loss of a ticket at unexpected power cut.

So far I don't see any more reliable way than to take data directly from the server when you need it.

 

Newbie question(:

Hello, I would like to write a simple EA that would place a grid of pending orders in one direction (e.g. long) with the following input parameters:

minimum price

maximum price

Number of orders between these two prices

TP - clearly up to the next order

SL - 0.

and not to pay attention to other orders which are not his.

In this case if one of the bids has played the same order should appear again.

The market price does not affect the parameters.

Example: Market price is 1.22.

set 1.23(min), 1.27(max), 5 (number of orders).

there should be a pending order at 1.23 - 1.24 - 1.25 -1.26 -1.27 (respectively with TP set to the value of the next pending order, except the uppermost one - it will respectively be 1.28).

p.s.: tried to dig in the code Setka but for me it is still a "dense" forest .... Can anyone help?

And it is desirable to separate the blocks and sign them - what is responsible.

Thanks...

 
merlinco:

Question from a newbie(:

Hello, I would like to write a simple Expert Advisor that would set a grid of pending orders in one direction (like long) with a ...

Kind. If you "wanted to", write - they will look at the sane code here and correct it. Study the tutorial, documentation, exps from the site codebase.

The market is not free, if for you it is still a "black forest", then go straight to the rubes - they will write there for your food.

 
merlinco:

Newbie question(:

Hi, I would like to write an EA (a simple one) which would place a grid of pending orders in one direction (e.g. long) with the following input parameters:

...

Thank you...

О... Exactly like this one I ordered through the jooba... For 60 quid. I can make you one for 60... :)
 
artmedia70:
I can make you one for 60... :)
What if it's not 60 quid but 70 quid worth of code? :) ;)
 
Roman.:

Kind. If you "wanted to", write - they will look at the sane code here and correct it. Study the tutorial, documentation, expats from the site codebase.

There is no free stuff here, if so far it is a "dense forest" for you, go straight to zhoba - they will write for food.


Gentlemen experts, if you send a newcomer to another place to write in place of "in zhobu" at least "in job" or "to work. I remember when I was a rookie and they sent me there, the first thing that came to mind was that they sent me to the asshole from here.
 

as you rightly sent me to the "zhoba"))

I'll certainly try writing first... ...even though I'm a nerd, so maybe I'll turn to artmedia70.

But in this case it turns out that we will be correcting code that someone is selling?! - does he mind?

And I think 60 is too much for this simple code... 30 imho. Then all this code will be converted and it will be about 700, which by the way I won't regret to give.

Too many thoughtful ideas, which correlate with the situation in the account.

thanks for the link to the tutorial.... found a description of the function of restoring a played order on the forum but the skeleton itself will most likely have to be borrowed from someone and corrected.

So...

Thank you all.

Can anyone suggest some free examples that are suitable for me? It's easy to prescribe an algorithm if you know the functions.

 
Hi, how do I know how many pips an order is in profit?
 
veti-k:
Hi, can you tell me how to find out how many pips an order is in profit?
For the selected open position you need to find the difference between its opening price and the current price.
Reason: