How do I retrieve data from an indicator? - page 6

 
Retabs:


I'll be correcting myself. Already insertedthe code via the SRC button.

Why then would you delete my code if it is, as you wrote, inserted according to the rules?


Because you have to offer your code pasted according to the rules, not me yours! Just now deleted it when I got home!
 
borilunad:

Because you have to offer your code pasted according to the rules, not me yours! Just now deleted it when I got home!


Can you please advise. How to allow a new trade to open only when the indicator lines re-cross, i.e. after val1 does not equal val2? (code above). By loop?

 
Retabs:


Can you tell me please. How to limit the opening of one trade until another is closed? (code above).


Before opening, put a condition that if there is no position, then you can open!

There are many different functions, but while you explore them I suggest one standby that is for all occasions!

if(OrderTotal() == 0)
{
  // потом остальные условия, чтобы зря не производить расчёты,
  // если пока ещё есть открытая позиция. 
  // Если понадобится открывать больше позиций, тогда проставите
  // допустимый максимум, например, 3 позиции:
if(OrderTotal() < 3)
{
  // Всё это не ленитесь находить в Документации! Замечено, что 
  // если находите сами и сами делаете, тогда ваши знания и навыки
  // будут крепкими!
  
 
<br / translate="no">
Borilunad:

Because you have to offer your code pasted according to the rules, not me yours! Just now deleted it when I got home!

Thank you. Revisited my conditions and realised I didn't quite get what I wanted right. I'm sorry.

Can you please tell me. How do I allow opening anew trade only when indicator lines are re-crossed, i.e. after val1 does not equal val2? (code above). To allow only one trade between 2 crossovers, regardless of number of opened at that time past trades, and of course without touching them.

I tried adding a new variable as a marker that changes its value during crossing, but nothing worked.

I think the only way out is to catch the moment when the deal is done and change the marker back to its original value.

 
Retabs:


Please advise. How to allow opening a new trade only when indicator lines are re-crossed, i.e. after val1 does not equal val2? (code above). By a loop?


While I was writing to you, you added conditions that you want to see written by me! Here is where you have to find and write what you need yourself, looking in the Documentation and looking at your time series chart , bars-candles, and go deep into the study of Sergei Kovalev's Tutorial, which explains everything in an accessible manner!

So, do not waste your time, take up the study, and the result will be! And if you use hints you will do yourself a disservice, because even a professionally written EA always needs a babysitter, without which it will get cranky at any time and will stop earning because of the frequent changes of market habits! That's why you should always look for new solutions, experiment and change the strategy a little or a lot, and knowing what you've done is much easier than understanding someone else's! Good luck to you!

 
borilunad:


While I was writing to you, you added conditions that you want to see written by me! This is where you have to find and write what you need, looking in the Documentation and looking at your chart time series, bars-candles, and go deep into the study of the Tutorial by Sergey Kovalev, which explains everything in an accessible manner!

So don't waste your time, take up teaching, and you will get results! And on tips you will do yourself a disservice, because even a professionally written EA always needs a babysitter, without which it will get cranky at any time and stop earning due to frequent changes in the market habits! That's why you should always look for new solutions, experiment and change the strategy a little or a lot, and knowing what you've done is much easier than understanding someone else's! Good luck to you!


OK. I am not giving up on the reference. Please tell me which direction to go in order to "catch the moment when the transaction took place, and change the marker back to its original value".
 
Retabs:

All right. I'm not giving up on the certificate. Tell me which direction to dig in to "catch the moment when the trade took place, and change the marker back to its original value"


time series in the Documentation, bars-slides onthe chart! And you will learn a lot of very useful and useful stuff along the way! And the Tutorial!

And it's not for a day or two of learning, months and years, for life if you really want to know and know how! Good luck!

 
_new-rena:

Finally.

The 130 error is due to the stops and takeovers. There should be a price level at which they should trigger. (certainly not waiting for a price rate of -100 or 60, should be like Price-100*Point or Price+60*Point, for example)


Please advise. How to allow opening anew trade only when the indicator lines will be re-crossed, i.e. after val1 will not be equal to val2? To allow only one trade between 2 crossings, not depending on number of opened at that moment previous trades, and of course not touching them.

//+------------------------------------------------------------------+
//|                                Sovetnik_RegressionPolynomial.mq4 |
//|                                                      Retabs 2014 |
//|                                                        www.----- |
//+------------------------------------------------------------------+
#property copyright "Retabs 2014"
#property link      "www.-----"
#property version   "1.00"
#property strict
//--- input parameters
input int   StopLoss=60;
input int   TakeProfit=100;
input double   Lots=0.10;
input int   Shift=5;

double SL;
double TP;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double val1=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,0,0);
   double val2=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,1,0);
   
   if(val1>val2)
   OrderSend(Symbol(),OP_BUY, Lots,Ask,Shift,Ask-StopLoss*Point,Ask+TakeProfit*Point,"коммент",5371533,0,Red);
   
   if(val1<val2)
   OrderSend(Symbol(),OP_SELL,Lots,Bid,Shift,Bid+StopLoss*Point,Bid-TakeProfit*Point,"коммент",5371533,0,Blue);
  }
//+------------------------------------------------------------------+
 
Retabs:


Please advise. How to allow opening anew deal only when indicator lines will cross again, i.e. after val1 will not be equal to val2? To allow only one trade between 2 crossings, not depending on number of opened at that moment previous trades, and of course not touching them.

Like this
void OnTick()
  {
//---
   double val10=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,0,0);
   double val20=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,1,0);

   double val11=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,0,1);
   double val21=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,1,1);
   
   if(val11 < val21 && val10>=val20)
   OrderSend(Symbol(),OP_BUY, Lots,Ask,Shift,Ask-StopLoss*Point,Ask+TakeProfit*Point,"коммент",5371533,0,Red);
   
   if(val11 > val21 && val10<=val20)
   OrderSend(Symbol(),OP_SELL,Lots,Bid,Shift,Bid+StopLoss*Point,Bid-TakeProfit*Point,"коммент",5371533,0,Blue);
  }
 

Thanks for the reply. Just now and I have come up with solutions myself, but on a different principle. Tried mine and yours, seems to be correct.

//+------------------------------------------------------------------+
//|                                Sovetnik_RegressionPolynomial.mq4 |
//|                                                      Retabs 2014 |
//|                                                        www.----- |
//+------------------------------------------------------------------+
#property copyright "Retabs 2014"
#property link      "www.-----"
#property version   "1.00"
#property strict
//--- input parameters
input int   StopLoss=100;
input int   TakeProfit=160;
input double   Lots=0.10;
input int   Shift=5;

double SL;
double TP;
int    X=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double val1=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,0,0);
   double val2=iCustom(NULL,0,"RegressionPolynomial",10000,55,5,2,0,1,0);
   

   if (X>0 && val1==val2)
   Ctrl=0;
   
   
    if (X==0  )
      {
      if(val1>val2)
      OrderSend(Symbol(),OP_BUY, Lots,Ask,Shift,Ask-StopLoss*Point,Ask+TakeProfit*Point,"коммент",5371533,0,Red);
      Ctrl=Ctrl+1;
      }
      
    if (X==0 ) 
    
      {if(val1<val2)
      OrderSend(Symbol(),OP_SELL,Lots,Bid,Shift,Bid+StopLoss*Point,Bid-TakeProfit*Point,"коммент",5371533,0,Blue);
      X=X+1;
      }
   
  }
//+------------------------------------------------------------------+

But here is the thing: in the visual crossover point, the lines are actually crossed more than once, therefore the signal is received several times and the Expert Advisor has time to place 4-30 orders.

We have to get rid of this drawback. The only thing I have invented is to average previous readings and compare them with present ones. Logically, yes. But how can I do that programmatically? Help!