Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 63

 
FAQ:


I see, more questions then:

You need to control the open time of the candle with the function : iTime

I tried to control the open time of a candlestick with this function: iTime

The order opens at the 15 o'clock candle...... but the 15 o'clock candle is often not the first one.

Before it, the earlier candlesticks had already been in contact with 1.3000.

And I need it to be before the 15 o'clock candlestick, which has crossed 1.3000.

Thank you.

 
sometimes the newbies are stumped... exactly logic, simple human logic. and programming is rather linear. try to think of your conditions in a single line.
 
FAQ:
sometimes newbies are stumped... exactly logic, simple human logic. and programming is rather linear. try to think of your conditions in one line.

Let me give you my idea graphically.

http://clip2net.com/s/5vbxUK

And how would you put this idea into one line?

Thank you.
 
in time, in reverse order. this is how the programme will analyse it. imagine that you are at the decision point.
 
FAQ:
in time, in reverse order. That's how the program will analyse it.

Sorry - I don't quite understand your intention.

I'd appreciate it if you could write how it might look in code form...

Thank you.

 
solnce600:

Good afternoon everyone!

I would be very grateful to anyone who can tell me how to code such an idea.


The graph TF 5

At the moment bid is 1.3150

There is a price level - 1.3000.

The price goes down.

====================================

// If the price crosses 1.3000.

// If price first crosses 1.3000.

// If the price first crosses 1.3000 and the crossing is within the 15hour candle (i.e. 15:00,15:05.....15:55)


// Open a trade.

===================================

Thank you.



this is just an idea without full implementation

extern double crossLevel = 1.                       3;extern int hour = 15;int start(){    static int cross = 0;    if (TimeHour(TimeCurrent()) == hour) {// candle corresponds to hour        if (isCrossPrice(crossLevel, Bid)) {// level crossing let Bid            cross++;            if (cross == 1) {// first cross level                ifxml-ph// open an order - implement yourself                    cross = 0;                }            }        }    }bool isCrossPrice(double level, double price){    bool res = false;    static double prev = 0;    if (prev > 0) {        if ((prev <= level && price > level) || // cross level up            (prev >= level && price < level)) { // cross level down            res = true;        }    }    prev = price;    return(res);}
 
keekkenen:

it is only an idea without full implementation


Thank you very much.
 
solnce600:


Sorry - I don't quite understand your intention.

I'd appreciate it if you could write down what it might look like in code form...

Thank you.


It's still a long way to the code, you have to understand the principle, the algorithm.
 

I've been struggling for two days now and can't figure it out. I need to find the lowest price for the last n bars, but not from the current bar, but from the bar received through the function. The function returns the index of the bar at which the order was opened. This is the bar from which we need to look back through the history for the n bars to find the lowest price. Below is my code, what is wrong with it?

 double low_price_n_bar()
 {
   
   double low_bar=100000, index_bar;
   
   for (int i=time_orders; i<=count_bar; i++) //time_orders индекс бара получаемого из функции, count_bars внешняя переменная количество баров для сдвига назад по истории
   {
    index_bar= ND(iLow(Symbol(),0,i));
    if (index_bar<low_bar)
    {
      low_bar=index_bar;     
    }
   
   }
   return(low_bar);
 }
 

Dear forum users, please help me very much.


if (TimeBar==Time[0]) return(0);


double MA1 = NormalizeDouble(iMA(NULL,TimeFrame_2,MA_Period_2,MA_Shift_2,MA_Method_2,Applied_Price_2,0),Digits); // where 0 is shift from the current bar by the specified number of periods back
//double MA21 = NormalizeDouble(iMA(NULL,timeframe_2,period_2,ma_shift_2,ma_method_2,applied_price_2,2),Digits);
double MA2 = NormalizeDouble(iMA(NULL,timeFrame_3,MA_Period_3,MA_Shift_3,MA_Method_3,Applied_Price_3,0),Digits);
//double MA31 = NormalizeDouble(iMA(NULL,timeframe_3,period_3,ma_shift_3,ma_method_3,applied_price_3,2),Digits)
double MA3 = NormalizeDouble(iMA(NULL,TimeFrame_4,MA_Period_4,MA_Shift_4,MA_Method_4,Applied_Price_4,0),Digits);

double OsMA = NormalizeDouble(iOsMA(NULL,TimeFrame_5,FastEMA_5,SlowEMA_5,SignalSMA_5,Applied_Price_5,0),Digits)

if (MaxOrders>b && Low[0]>=MathMax(MA1,MA2)&& Low[0]>MA3 && Ask>MathMax(MA1,MA2)+DeltaOpen*Point && Ask>MA3 && MA2<MA3 && MA1<MA3 && OsMA>0 && Trade)
{
if (OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),Slippage,SL,TP, "Puria_1",Magic,0,Blue) ==-1) TimeBar=0;
else TimeBar=Time[0];

}
if (MaxOrders>s && High[0]<=MathMin(MA1,MA2) && High[0]<MA3 && Bid<MathMin(MA1,MA2)-DeltaOpen*Point && Bid<MA3 && MA1>MA3 && MA2>MA3 && OsMA<0 && Trade)
{
if (OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),Slippage,SL,TP, "Puria_1",Magic,0,Red) ==-1) TimeBar=0;
else TimeBar=Time[0];
}

return(0);


With these conditions, the Expert Advisor opens a trade, say, on SELL, closes it on profit, and immediately opens another trade on SELL. How to prescribe in an EA, that when the signal is received, only one deal should open, i.e. one signal - one deal.
I thank you in advance.