[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 722

 
IgorM:


the whole problem was the declaration of a variable:

Taki no. I tried to declare it both at the beginning of the code, where the parameters are, and before the counters.
 
IgorM:


Always put curly braces after for for now, then you'll get the hang of it

I'll go through the whole code :)


Thank you all!

 
Abzasc:

Let's go through all the code :)

Without parentheses, only one operator falls within the scope of conditions (if, while, for). If there is more than one, braces must be used.

 
ToLik_SRGV:

Without parentheses, only one operator can be used after conditions (if, while, for). If there is more than one, the use of curly braces is mandatory.

Learned now :)
 

Friends! I can't figure it out... There is a trend line drawn on the AD indicator chart (in this case the trend line is UP). When the trend line crosses this trend line up-down we have, so to speak, a preliminary sell signal. If the indicator line remains below the trend line on the first bar, the sell is likely. I cannot find out how I should compare the trend value on the 0 bar with the price value on the 0 bar. I wrote it in an abstruse way... Suppose I can calculate the trend line projection on the zero or the first bar, say, using the straight line equation... But how can I get the value of the obtained point on the price chart from there? ??? I don't understand... After all, I ultimately need to understand that the price has crossed the trend line from top to bottom... At the same time - what does it have to do with the price, if I'm looking at the indicator... But, still, how do I compare the level calculated using the straight line equation with the price? I'm confused... Can anybody untangle me?


The trend line on the price chart, drawn from minima of bars where extremums were found on the AD chart says nothing, and it's not relevant...

 

Setting SL and TP to zero -- doesn't work, no orders are placed.

Or is it evening and fatigue?

//+------------------------------------------------------------------+
//|                                                         Grid.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property show_inputs

extern double volume = 0.1;
extern int price = 500;
extern int slippage = 30;
extern int stoploss = 500;
extern int takeprofit = 500;
extern int steps = 500;
extern int count_orders = 5;

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   double buy_price = Ask+price*Point;
   double sell_price = Bid-price*Point;

   int ticket;

   for(int i = 0;i<count_orders;i++)
    {
     
     ticket=OrderSend(Symbol(),OP_SELLSTOP,volume,
     sell_price-i*steps*Point,slippage,
     sell_price-i*steps*Point+stoploss*Point,
     sell_price-i*steps*Point-takeprofit*Point,
     "yuriytokman@mail.com    "+i+" *");
     if(ticket<0)
       {
        Print(i,"  OrderSend failed with error #",GetLastError());
        return(0);
       }

     ticket=OrderSend(Symbol(),OP_BUYSTOP,volume,
     buy_price+i*steps*Point,slippage,
     buy_price+i*steps*Point-stoploss*Point,
     buy_price+i*steps*Point+takeprofit*Point,
     "yuriytokman@mail.com    "+i+" *");
     if(ticket<0)
       {
        Print(i,"  OrderSend failed with error #",GetLastError());
        return(0);
       }     
         
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Files:
grid.mq4  2 kb
 
Swetten:

Setting SL and TP to zero -- doesn't work, no orders are placed.

Or is it evening and tiredness?

Don't kick me, I am learning :)

This is buy_price+i*steps*Point-stoploss*Point,

sale price + counter*500... Isn't that a lot? Without SL and TP multiplier, maybe it needs to be smaller...

 

In the course of the code, we have this construction:

LastTimeDN     =TimeDN[l-1];
LastVarDN      =PeakDN[l-1];
PreLastTimeDN  =TimeDN[l];
PreLastVarDN   =PeakDN[l];
LastTimeDN and PreLastTimeDN are of datetime type. After performing the above operations these variables contain the number of seconds since the year ... of my birth ...
Can you tell me how to convert them to bar numbers ?
 
artmedia70:

How do you compare the level calculated from the straight line equation with the price?

The angle has to be taken into account, it's complicated...

What do you mean by "price has crossed the trendline from top to bottom"? The price has crossed it, so the indicator has crossed it. No?

 

Swetten:

Setting SL and TP to zero -- doesn't work, no orders are placed.

Or is it evening and tired?

Here, everything works on 5 digits. Maybe you are working on 4 digits, then just scale down the price or reduce the script parameters.