Closing of positions. On indicator signal. - page 8

 
Lukyanov:

Net profit 6157.73


Sergey, a profit of $6000 on 6,000 to 9,000 transactions.

1. What is the MOJ?

2. 1,500 trades a day - what broker can withstand that?

 

Good evening, everyone! There's been another problem. Please tell me if you know how to write the expression

hann = iCustom(.... .... .... ) for indicator

At least in its most basic form - to set Lb parameter and bar number...

/+------------------------------------------------------------------+
//|                                                          SSL.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
//----
#property indicator_buffers 1
#property indicator_color1 Blue
extern int Lb=10;
double ssl[],Hld,Hlv;
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,ssl);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() {   return(0);  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   for(int i=Bars-Lb;i>=0;i--)     {
      if(Close[i]>iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1))
         Hld=1;
      else        {
         if(Close[i]<iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1))
            Hld=-1;
         else
            Hld=0;
        }
      if(Hld!=0)
         Hlv=Hld;
      if(Hlv==-1)
         ssl[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
      else
         ssl[i]=iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW,i+1);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Here is the chart -
 
rid:

Good evening, everyone! There's been another problem. Please help, who can - write an expression

hann = iCustom(.... .... .... ) for indicator

iCustom( Symbol(), Period(), "SSL", indLb, 0, bar );
 

Thank you, komposter.

 

Good afternoon. Please advise.

There is a Force-index indicator installed in mt4. It's bipolar, with a midline at t.0.

Here is its code.

#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int ExtForcePeriod=13;
extern int ExtForceMAMethod=0;
extern int ExtForceAppliedPrice=0;
//---- buffers
double ExtForceBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string sShortName;
   SetIndexBuffer(0, ExtForceBuffer);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
//---- name for DataWindow and indicator subwindow label
   sShortName="Force("+ ExtForcePeriod+")";
   IndicatorShortName( sShortName);
   SetIndexLabel(0, sShortName);
//---- first values aren't drawn
   SetIndexDrawBegin(0, ExtForcePeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Force Index indicator                                            |
//+------------------------------------------------------------------+
int start()
  {
   int nLimit;
   int nCountedBars=IndicatorCounted();
//---- insufficient data
   if(Bars<= ExtForcePeriod) return(0);
//---- last counted bar will be recounted
   if( nCountedBars> ExtForcePeriod) nCountedBars--;
   nLimit=Bars- nCountedBars;
//---- Force Index counted
   for(int i=0; i< nLimit; i++)
      ExtForceBuffer[ i]=Volume[ i]*
(iMA(NULL,0, ExtForcePeriod,0, ExtForceMAMethod, ExtForceAppliedPrice, i)-
iMA(NULL,0, ExtForcePeriod,0, ExtForceMAMethod, ExtForceAppliedPrice, i+1));
//---- done
   return(0);
  }


However. My task is to draw the indicator in its entirety in positive (or negative, not matter) zone.

To do it programmatically.

I.e. not like this: double force=(iForce+10), but programmatically!

Please advise who knows what to add (insert) to the code for this purpose?

 
rid >> :

However. I need the whole indicator to be drawn in the plus (or minus, whatever) zone.

Please tell me, who knows, what should I add to code for this?

IMHO, sigmoid wrapper is what you need. The buffer will have values from 0 to 1.

for(int i=0; i< nLimit; i++)
      ExtForceBuffer[ i]=Volume[ i]*
(iMA(NULL,0, ExtForcePeriod,0, ExtForceMAMethod, ExtForceAppliedPrice, i)-
iMA(NULL,0, ExtForcePeriod,0, ExtForceMAMethod, ExtForceAppliedPrice, i+1));

//заменяем на 

for(int i=0; i< nLimit; i++)
{
         ExtForceBuffer[ i]=Volume[ i]*
   (iMA(NULL,0, ExtForcePeriod,0, ExtForceMAMethod, ExtForceAppliedPrice, i)-
   iMA(NULL,0, ExtForcePeriod,0, ExtForceMAMethod, ExtForceAppliedPrice, i+1));

   ExtForceBuffer[ i] = Sigmoid( ExtForceBuffer[ i]);
}

//...

double Sigmoid(double x)
{
   double value = MathExp( x);
   return ( value/(1 + value))
}
 

Thank you, TheXpert ! I'll give it a try.

//gzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.

It worked !

 

Good afternoon everyone. I want to make my first EA, but I don't know how to write the code. The trades are opened on the MA. If the price touches the MA from above, then buy. If it touches below, then it is a sell. The MA slope should be considered. The slope of MAs and opening of the order should be unidirectional. Thank you.

 
Shu писал(а) >>

research is fascinating! it is even good for the brain and for experimentation. i salute and respect that.

All bikes and motorbikes have already been (strikethrough) invented before us - put all orders into your own array (perhaps more than one) and do whatever manipulations you like with it. sort it by any criteria, or delete it (the ticket is your friend), or modify it (it's easy to make modifications of stoplosses/takeprofits, or create new orders.

ps (one more thing). if you decide to take your creation seriously, remember that at any second (millisecond) the connection with your brokerage company may disconnect. The ideal solution is to enable the Expert Advisor to see the necessity of closing certain orders (in this case) after an emergency stop/shutdown and close them.

However, most of publicly sold "grails" in the form of P.C. - are similarly toy-like...

About the arrays I don't really understand. But the second idea - that if the expert misses the signal for closing, he will still be able to grasp the necessity of closing, I like it. But how to do it...

 

Afternoon.

EA puts limit bylimit orders following price movement at distance =Distance.

I need to delete excessive (farthest) orders as the price moves upwards.

I have done it. But for some reason, it works very incorrectly! The first order is deleted normally. Then, on the contrary, the ones closest to the price are deleted! Then they stop or are deleted "out of the blue", and the log generates error 4108 (unknown ticket). Then for some time they are deleted normally.

I think it was said somewhere that it is important to correctly arrange the search of orders.

//жжжжж Удаление лишних байлим ордеров жжжжжжжжж
if( NumberOfOrders(NULL,OP_BUYLIMIT, MAGIC)> КоличествоОрдеров  )  {
    //если ордеров больше заданного значения 
//for (int z = OrdersTotal() - 1; z >= 0; z -- )  {//перебираем с "конца"
  for ( int z=0;    z<OrdersTotal();        z++)  {//перебираем с начала         
  if (OrderSelect( z, SELECT_BY_TICKET, MODE_TRADES))          {//перебираем по тикету           
   if (OrderSymbol()==Symbol()&& OrderType() == OP_BUYLIMIT) {//выбираем байлимиты   
     if ( OrderOpenPrice() <(Ask-( КоличествоОрдеров* Дистанция)*Point) ) {
     //если расстояние от тек. цены больше заданного
   
   OrderDelete(OrderTicket(),Yellow);   //  return(0);    //удаляем самый дальний
            }}}}} 

However. Regardless of whether the order retrieval is run "from the end" or from the beginning. The result is incorrect.

The code seems to be the simplest one!

What can be wrong here? Please advise!