[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 216

 
stalkertula:

Thanks for the answer, but I have the algorithm written in Russian, but I'm not good at mql, at least a tip on the functions that fixed the number (I'll write it in the settings) of open sell/buy orders, and then the signal to prohibit placing sellstop/buystop pending orders.

Why isn't this algorithm, which you have already written, reflected in your code?
Do you think that just looking at your code you haven't written at once you can point out your error?

We still need to "read" it...

Here is an excerpt of code where everything we wrote on a bit of paper is shown in the code as well:

//================================================================================================================   
//------------------------------- Определение тоннеля и его верхней и нижней границ ------------------------------ 
//================================================================================================================   
   if (NormalizeDouble(MathAbs(MA169-MA144),dg)/pt<=sp)           // Если разница МАшек меньше спреда, ... 
      Tonnel=false;                                               // Тоннель меньше спреда - считаем, что он узкий
   if (NormalizeDouble(MathAbs(MA169-MA144),dg)/pt>sp)            // Если разница МАшек больше спреда, ... 
      Tonnel=true;                                                // Тоннель больше спреда - считаем, что он норм.
//-------------------------------------------------------------      
   if (CmpD(MA169,MA144)) {                                       // Если 169-я МАшка выше 144-й, ...
      UP_Limit=MA169+sp*pt;                                       // ... то 169 - верх тоннеля, ...
      DN_Limit=MA144-sp*pt;                                       // ... а 144 - низ тоннеля
      }
   if (CmpD(MA144,MA169)) {                                       // Если 144-я МАшка выше 169-й, ...
      UP_Limit=MA144+sp*pt;                                       // ... 144 - верх тоннеля, ...
      DN_Limit=MA169-sp*pt;                                       // ... 169 - низ тоннеля
      }
   if (NormalizeDouble(MA169-MA144,dg)==0) {                      // Если 169-я МАшка равна 144-й, ...
      UP_Limit=MA169+sp*pt;                                       // ... то 169 - верх тоннеля, ...
      DN_Limit=MA144-sp*pt;                                       // ... а 144 - низ тоннеля
      }
//-------------------------------------------------------------      
      string NameArUP=Prefix+"UP"+TimeToStr(Time[0]);             // Нарисуем тоннель
      string NameArDN=Prefix+"DN"+TimeToStr(Time[0]);
      SetArrow(4, DeepSkyBlue, NameArUP, Time[0], UP_Limit, 0);   // Его верх
      SetArrow(4, Gold,        NameArDN, Time[0], DN_Limit, 0);   // Его низ
//================================================================================================================   
//------------------------------------- Проверка на вхождение цены в тоннель ------------------------------------- 
//================================================================================================================ 
   if (CmpD(UP_Limit, pa) && CmpD(pb, DN_Limit)) {
      if (Above) {                                                // Если цена была выше тоннеля
         LastAbove=true;                                          // Ставим  флаг "прошлого" положения цены "выше"
         LastBottom=false;                                        // Снимаем флаг "прошлого" положения цены "ниже"
         }
      if (Bottom) {                                               // Если цена была ниже тоннеля
         LastBottom=true;                                         // Ставим  флаг "прошлого" положения цены "ниже"
         LastAbove=false;                                         // Снимаем флаг "прошлого" положения цены "выше"
         }
      Inside=true;                                                // Ставим флаг расположения цены внутри тоннеля
      Above=false;                                                // Сброс флага "над"
      Bottom=false;                                               // Сброс флага "под"
      ReadyTradeB=true;                                           // Флаг готовности к торговле Бай
      ReadyTradeS=true;                                           // Флаг готовности к торговле Селл
      }
//================================================================================================================   
//------------------------------- Проверка на расположение цены относительно тоннеля ----------------------------- 
//================================================================================================================ 
   if (CmpD(pa,UP_Limit)) {                                       // Если цена выше тоннеля
      if (Inside) {
         Inside=false;                                            // Сброс флага нахождения цены внутри тоннеля
         LastInside=true;
         }
      Above=true;                                                 // Цена находится над тоннелем
      Bottom=false;
      }
   if (CmpD(DN_Limit,pb)) {                                       // Если цена ниже тоннеля
      if (Inside) {
         Inside=false;                                            // Сброс флага нахождения цены внутри тоннеля
         LastInside=true;
         }
      Bottom=true;                                                // Цена находится под тоннелем
      Above=false;
      }
//================================================================================================================   
//------------------------------------ Проверка на пересечение границ тоннеля ------------------------------------ 
//================================================================================================================ 
// .... пока не отлажу предыдущее, за это не стоит и браться...
//----------------------------------------------------------------

So, until the simplest thing is fixed, you shouldn't go further...

And what do you have? You've piled everything together, you haven't commented on a single line. Now take a week off and go back to your code. I'm sure it'll take you two hours to remember. 100%

 
coronel:
Permanent lot 0.1.


In that case, in my opinion, it is a good result for the week. I do not remember exactly, I think it is about 800 points. Only the stability seems to me to be not all right: the chart is not very smooth... Anyway, thanks for the answer. At least at least some figure is emerging. I'm pretty far away from that: 3000-4000 points a year is the limit. But my balance chart is flatter...

I've been thinking: 0.1 fixed lot - but with what leverage? It's not quite clear from the balance chart how many points were earned?

 

How do I get the value of the selected Fiba level from such an indicator ?

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

//| Parabolic_ZZ.mq4 |

//| Copyright © 2009, Vic2008 |

//| |

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

#property copyright "Copyright © 2009, Vic2008"

#property link ""

#include <stdlib.mqh>

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Red

#property indicator_color2 Magenta

//---- input parameters

extern double SAR_step=0.02; //parameters parabolic.

extern double SAR_maximum=0.2;

extern int BarsCount = 500; //Distance in bars to draw the indicator.

extern bool Fibo1_off = False; //Disabling Fibo levels.

extern bool Fibo2_off = False;

extern bool Fibo_Absolut_Value = False; //Include the absolute price values at the Fibo levels.

extern color Label_Color = Gray;

extern color Fibo_Color = Blue;

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

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

//| Custom indicator initialisation function |

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

int init()

{

//---- indicators

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexStyle(0,DRAW_SECTION);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(1,DRAW_SECTION,0,2,Magenta);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

ObjectsDeleteAll(0,OBJ_ARROW);

ObjectDelete("FiboZZLast");

ObjectDelete("FiboZZPrev");

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

//int counted_bars=IndicatorCounted();

string txt;

int w,PosLow,PosHigh;

double LPic=1000000,HPic=0,price;

datetime TimeTmp;

//----

ExtMapBuffer1[0]=Close[0];

ExtMapBuffer2[0]=EMPTY_VALUE;

for( w=0;w<BarsCount;w++){

if( w!=0 ){ ExtMapBuffer1[w]=EMPTY_VALUE; ExtMapBuffer2[w]=EMPTY_VALUE; }

if( iSAR(NULL,0,SAR_step,SAR_maximum,w) > Close[w] && LPic>=Low[w] ){ LPic=Low[w]; PosLow=w; }

if( iSAR(NULL,0,SAR_step,SAR_maximum,w) < Close[w] && HPic<=High[w] ){ HPic=High[w]; PosHigh=w; }

// H -> L

if( iSAR(NULL,0,SAR_step,SAR_maximum,(w+1)) > Close[w+1] && iSAR(NULL,0,SAR_step,SAR_maximum,w) < Close[w] && HPic!=0)

{

ExtMapBuffer1[PosHigh]=HPic;

ExtMapBuffer2[PosHigh]=HPic;

HPic=0;

}

// L -> H

if( iSAR(NULL,0,SAR_step,SAR_maximum,w) < Close[w] && iSAR(NULL,0,SAR_step,SAR_maximum,w+1) > Close[w+1] && LPic!=1000000 )

{

ExtMapBuffer1[PosLow]=LPic;

ExtMapBuffer2[PosLow]=LPic;

LPic=1000000;

}

}

if( Fibo1_off ) ObjectDelete("FiboZZLast");

if( Fibo2_off ) ObjectDelete("FiboZZPrev");

//Draw price marks and FIBO levels

int wave_cnt=0;

for( w=0;w<BarsCount;w++){

if( ExtMapBuffer2[w]!=EMPTY_VALUE ){

if( wave_cnt<=3 ){

ObjectDelete("PZZ_"+DoubleToStr( wave_cnt, 0));

ObjectCreate("PZZ_"+DoubleToStr( wave_cnt, 0), OBJ_ARROW, 0, Time[w], ExtMapBuffer2[w], Time[w], 0);

ObjectSet("PZZ_"+DoubleToStr( wave_cnt, 0), OBJPROP_ARROWCODE, SYMBOL_LEFTPRICE );

ObjectSet("PZZ_"+DoubleToStr( wave_cnt, 0), SYMBOL_LEFTPRICE, ExtMapBuffer2[w]);

ObjectSet("PZZ_"+DoubleToStr( wave_cnt, 0), OBJPROP_COLOR, Label_Color );

if(wave_cnt==1 && Fibo1_off==False ){

ObjectDelete("FiboZZLast");

ObjectCreate("FiboZZLast", OBJ_FIBO, 0, TimeTmp, ExtMapBuffer2[w], TimeTmp, price);

ObjectSet("FiboZZLast", OBJPROP_LEVELCOLOR, Fibo_Color);

ObjectSet("FiboZZLast", OBJPROP_COLOR, Fibo_Color);

ObjectSet("FiboZZLast", OBJPROP_RAY, False );// To enable the rays replace False with True

ObjectSet("FiboZZLast", OBJPROP_FIBOLEVELS, 14);

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+0,0.236); ObjectSetFiboDescription("FiboZZLast",0, "23.6");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+1,0.382); ObjectSetFiboDescription("FiboZZLast",1, "38.2");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+2,0.50); ObjectSetFiboDescription("FiboZZLast",2, "50.0");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+3,0.618); ObjectSetFiboDescription("FiboZZLast",3, "61.8");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+4,1.0); ObjectSetFiboDescription("FiboZZLast",4, "100.0");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+5,1.618); ObjectSetFiboDescription("FiboZZLast",5, "161.8");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+6,2.618); ObjectSetFiboDescription("FiboZZLast",6, "261.8");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+7,4.236); ObjectSetFiboDescription("FiboZZLast",7, "423.6");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+8,0.088); ObjectSetFiboDescription("FiboZZLast",8, "8.8");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+9,0.145); ObjectSetFiboDescription("FiboZZLast",9, "14.5");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+10,0.764); ObjectSetFiboDescription("FiboZZLast",10, "76.4");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+11,0.855); ObjectSetFiboDescription("FiboZZLast",11, "85.5");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+12,0.921); ObjectSetFiboDescription("FiboZZLast",12, "92.1");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+13,0.0); ObjectSetFiboDescription("FiboZZLast",13, "0.0");

if( Fibo_Absolut_Value ){

ObjectSet("FiboZZLast", OBJPROP_FIBOLEVELS, 14);

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+0,0.236); ObjectSetFiboDescription("FiboZZLast",0, "23.6 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+1,0.382); ObjectSetFiboDescription("FiboZZLast",1, "38.2 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+2,0.50); ObjectSetFiboDescription("FiboZZLast",2, "50.0 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+3,0.618); ObjectSetFiboDescription("FiboZZLast",3, "61.8 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+4,1.0); ObjectSetFiboDescription("FiboZZLast",4, "100.0 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+5,1.618); ObjectSetFiboDescription("FiboZZLast",5, "161.8 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+6,2.618); ObjectSetFiboDescription("FiboZZLast",6, "261.8 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+7,4.236); ObjectSetFiboDescription("FiboZZLast",7, "423.6 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+8,0.088); ObjectSetFiboDescription("FiboZZLast",8, "8.8 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+9,0.145); ObjectSetFiboDescription("FiboZZLast",9, "14.5 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+10,0.764); ObjectSetFiboDescription("FiboZZLast",10, "76.4 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+11,0.855); ObjectSetFiboDescription("FiboZZLast",11, "85.5 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+12,0.921); ObjectSetFiboDescription("FiboZZLast",12, "92.1 %$");

ObjectSet("FiboZZLast",OBJPROP_FIRSTLEVEL+13,0.0); ObjectSetFiboDescription("FiboZZLast",13, "0.0");

}

}

if( wave_cnt==2 && Fibo2_off==False ){

ObjectDelete("FiboZZPrev");

ObjectCreate("FiboZZPrev", OBJ_FIBO, 0, TimeTmp, ExtMapBuffer2[w], TimeTmp, price);

ObjectSet("FiboZZPrev", OBJPROP_LEVELCOLOR, Fibo_Color);

ObjectSet("FiboZZPrev", OBJPROP_COLOR, Fibo_Color);

ObjectSet("FiboZZPrev", OBJPROP_RAY, False );// To enable the rays replace False with True

ObjectSet("FiboZZPrev", OBJPROP_FIBOLEVELS, 14);

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+0,0.236); ObjectSetFiboDescription("FiboZZPrev",0, "23.6");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+1,0.382); ObjectSetFiboDescription("FiboZZPrev",1, "38.2");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+2,0.50); ObjectSetFiboDescription("FiboZZPrev",2, "50.0");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+3,0.618); ObjectSetFiboDescription("FiboZZPrev",3, "61.8");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+4,1.0); ObjectSetFiboDescription("FiboZZPrev",4, "100.0");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+5,1.618); ObjectSetFiboDescription("FiboZZPrev",5, "161.8");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+6,2.618); ObjectSetFiboDescription("FiboZZPrev",6, "261.8");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+7,4.236); ObjectSetFiboDescription("FiboZZPrev",7, "423.6");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+8,0.088); ObjectSetFiboDescription("FiboZZPrev",8, "8.8");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+9,0.145); ObjectSetFiboDescription("FiboZZPrev",9, "14.5");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+10,0.764); ObjectSetFiboDescription("FiboZZPrev",10, "76.4");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+11,0.855); ObjectSetFiboDescription("FiboZZPrev",11, "85.5");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+12,0.921); ObjectSetFiboDescription("FiboZZPrev",12, "92.1");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+13,0.0); ObjectSetFiboDescription("FiboZZPrev",13, "0.0");

if( Fibo_Absolut_Value ){

ObjectSet("FiboZZPrev", OBJPROP_FIBOLEVELS, 14);

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+0,0.236); ObjectSetFiboDescription("FiboZZPrev",0, "23.6 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+1,0.382); ObjectSetFiboDescription("FiboZZPrev",1, "38.2 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+2,0.50); ObjectSetFiboDescription("FiboZZPrev",2, "50.0 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+3,0.618); ObjectSetFiboDescription("FiboZZPrev",3, "61.8 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+4,1.0); ObjectSetFiboDescription("FiboZZPrev",4, "100.0 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+5,1.618); ObjectSetFiboDescription("FiboZZPrev",5, "161.8 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+6,2.618); ObjectSetFiboDescription("FiboZZPrev",6, "261.8 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+7,4.236); ObjectSetFiboDescription("FiboZZPrev",7, "423.6 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+8,0.088); ObjectSetFiboDescription("FiboZZPrev",8, "8.8 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+9,0.145); ObjectSetFiboDescription("FiboZZPrev",9, "14.5 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+10,0.764); ObjectSetFiboDescription("FiboZZPrev",10, "76.4 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+11,0.855); ObjectSetFiboDescription("FiboZZPrev",11, "85.5 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+12,0.921); ObjectSetFiboDescription("FiboZZPrev",12, "92.1 %$");

ObjectSet("FiboZZPrev",OBJPROP_FIRSTLEVEL+13,0.0); ObjectSetFiboDescription("FiboZZPrev",13, "0.0");

}

}

}

wave_cnt++;

price=ExtMapBuffer2[w];

TimeTmp=Time[w];

}

}



//----

return(0);

}

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

 
lagriv:

How to get the value of the selected fibre level from such an indicator ?

what the fuck?

you might want to put "war and peace" in there as well.

 

help please... my Expert Advisor checks open orders ...one order can be open at a time ...but when I enter a stop on a straight line at the moment of opening an order it gives out error 130...for instance it was like this

if(down>0)

{

ticket=OrderSend(Symbol(),OP_SELL,dLot,Bid,3,0,Bid-TakeProfit*Point,0,16384,0,Red);

I type in a stop of size 100

ticket=OrderSend(Symbol(),OP_SELL,dLot,Bid,3,100,Bid-TakeProfit*Point,0,16384,0,Red); ...gives error 130 in the tester

DTz Alpari...maybe I should modify p after open an order and place a stop?...tell me how roughly this can be done or point me to an EA where this is done...please

 
ilmur:

help please...

100*Point
 
ilmur:

help please... the advisor has an open order check function ...one order may be open at a time ...but when entering a stop size directly at the time of opening

a new order may be modified after it has been opened and a stop may be set ... could you please advise how to do this or point me to an EA where this is done ... please


A stop should be of type double. The price at which the stop should be set should be specified.

extern double   Lot=1;// Лот ордера при ручном управлении.
extern int      StopLoss=100;//СтопЛосс ордера при ручном управлении
extern int      TakeProfit=100;//ТейкПрофит ордера при ручном управлении
extern int      MAGIC=467003; // У ордеров открытых вручную MAGIC=0
extern int      Proskalz=10; //Проскальзывание
..........
double PR,SL,TP;
..............
PR=PR=NormalizeDouble(Ask,Digits);
if(StopLoss==0){
  SL=0;
}
if(StopLoss>0){
  SL=PR-StopLoss*Point;
}
if(TakeProfit==0){
 TP=0;
}
if(TakeProfit>0){
  TP=PR+TakeProfit*Point;
}
SL=NormalizeDouble(SL,Digits);
TP=NormalizeDouble(TP,Digits);
int TicketBuy=OrderSend(Symbol(),OP_BUYSTOP,Lot,PR,Proskalz,SL,TP,NULL,MAGIC,0,CLR_NONE);
if(TicketBuy==(-1)){
  Print("Ошибка № "GetLastError()," при установке Бай-ордера");
}
 
alsu:
100*Point
Thank you so much to everyone who responded
 
artmedia70:

Why isn't this algorithm you have already written reflected in your code?
Do you think that just looking at your unformatted code you can immediately point out your error?

You still need to "read" it...

Here is an extract from the code where everything you've sketched out on a piece of paper is shown in the code as well:

So, until you get the simplest thing right, you shouldn't go any further...

What about you? You've piled everything together, you haven't commented on a single line. Now take a week off and go back to your code. I'm sure it'll take you two hours to remember. 100%


I'm sorry, the code is not mine, I'm learning it on my own, it was a piece concerning pending orders, the rest is blah-blah, as usual settings, lots, fractals, trawl. This EA is not working, i.e. it is losing because of piled orders, so I have decided to place some restrictions and see what happens. I will use the mql language but I have no idea what to do with it. I do not know how to use it.
 
stalkertula:
Sorry, the code is not mine, I'm studying it myself. This was a part concerning pending orders, the rest was blah-blah, like we usually do with settings, lots, fractals and trawl. This EA is not working, i.e. it is losing because of piled orders, so I have decided to place some restrictions and see what happens. I will use the mql language but I have no idea what to do with it. Thanks, I will look into it.

That's weird. What's there to apologize for? Well... I've shown you how you should design your own codes, so you don't have to figure it out later.

And since your code is someone else's... But... You can also comment on those strings, which meanings became clear to you during the analysis. After that it will be clearer, and you'd better write your own one on the basis of the analyzed one. So to fully comprehend, understand and convert it to your own needs.

That'sexactly what will lead you to a logical understanding. It will also be good for you. :)
Good luck!

Reason: