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

 
mukata:

Hello

my "start on historical data" button is not active

What could be the reason?

Start what?
 
Vinin:
Are the parameters right?
No, the parameters are correct. Checked the shift from 0 to 99. All values from 1 to 99 clearly correspond to the display, but with a shift value of 0, the data does not correspond to the indicator. I can't figure out how they are taken and what my error is.
 

Good time everyone :-)

I have faced this problem. I have a function which puts a pending order. But it places them ONLY if there is no order at the given price. But an order is repeated at the same price in a strange way. Here is the function which places an order.

int fOrderOpenBuy(double PR1, double PTP){
bool chek1=false;
   RefreshRates();
   double lts=fGetLotsSimple(OP_BUY);
      if(lts>0){      
         if(!IsTradeContextBusy()){
            //double PR=Close[1]-(150*Point);
            double slts=ND(PR1-Point*StopLoss);
            if(StopLoss==0)slts=0;
//проверка ордеров
     int  TotalOrders=OrdersTotal(); 
           for (int i=0; i<=TotalOrders; i++){
     
                 if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
                 
                     if   (PR1==OrderOpenPrice()){chek1=true;}   
                 Print ("Чек "+OrderOpenPrice()+"  "+PR1);
                 }
           }  
        if (chek1==false) {   int irv=OrderSend(Symbol(),OP_BUYLIMIT,lts,PR1,Slippage,slts,PTP,NULL,Magic_N,0,CLR_NONE); }
               if(irv>0){
                  PlaySound("ok");
                  return(irv);
               }
               else{
                  PlaySound("timeout");
                  Print ("Error open BUY. "+fMyErDesc(GetLastError())); 
                  return(-1);
               }
         }
         else{
            static int lt2=0;
               if(TimeCurrent()>lt2+20){
                  lt2=TimeCurrent();
                  Print("Need open buy. Trade Context Busy");
               }            
            return(-2);
         }
      }
      else{
         static int lt3=0;
            if(TimeCurrent()>lt3+20){
               lt3=TimeCurrent();
               if(lts==-1)Print("Need open buy. No money");
               if(lts==-2)Print("Need open buy. Wrong lots size");                  
            }
         return(-3);                  
      }
}  

It outputs the same open prices, but the lineif(PR1==OrderOpenPrice()){chek1=true;} does not want to be executed. Can anyone answer why????

 

Because I'm getting sick and tired of..... :-( prices are the same and the order still opens.....

 
Dear Professionals !!!!! The EA does not trade on Demo and Real, but in the Strategy Tester everything is OK!

Can you please tell me what the problem could be? I tried to attach different indicators, they all work, but only in the Strategy Tester!

Files:
 

Good afternoon everyone!

Can you give me a hint...

Here is a code snippet where there are two conditions when the Print function prints a message.

The problem.

Print function prints the message EACH tick, I need it to print it only on the first tick and on the rest - rested.

Please advise me how to stop it after the first tick.

Thank you.

if (OrderSelect (Ht-1,SELECT_BY_POS, MODE_HISTORY))

if ( OrderType ()==OP_SELL)

X1 = OrderProfit( );

if (OrderSelect (Ht-1,SELECT_BY_POS, MODE_HISTORY))

if ( OrderType ()==OP_SELL)

if(X1 < 0)

Print(" LOW ", X1 );

 
solnce600:

Good afternoon everyone!

Can you give me a hint...

Here is a code snippet where there are two conditions when the Print function prints a message.

The problem.

Print function prints the message EACH tick, I need it to print it only on the first tick and on the rest - rested.

Please advise me how to stop it after the first tick.

Thank you.

if (OrderSelect (Ht-1,SELECT_BY_POS, MODE_HISTORY))

if ( OrderType ()==OP_SELL)

X1 = OrderProfit( );

if (OrderSelect (Ht-1,SELECT_BY_POS, MODE_HISTORY))

if ( OrderType ()==OP_SELL)

if(X1 < 0)

Print(" LOW ", X1 );

If it is a rachsite once per bar, I use

if (b!=Bars){

b=Bars;

}

So the calculation that is in brackets only happens once per bar...

 
nikelodeon:

If we are talking about rachsite once per bar, I use

if (b!=Bars){

b=Bars;

}

So, the calculation that is in brackets only happens once per bar...

Thank you very much.

I need the info to be shown on the first minute bar and only on it.

The version that you propose I tried, ..... but it displays information on 2 and 3 and so on ... because the second bar is not equal to the first and the third is not equal to the second, etc..

I need to print the information once at the first bar. And until the next order is closed by the STOP, thePrint functionshould "rest".

 
solnce600:

Thank you very much.

I need the info to be displayed on the first and only the first minute bar.

The option you offer I tried, ..... but it displays information on 2 and 3 and so on ... because the second bar is not equal to the first and the third is not equal to the second, etc.

I need to print the information once at the first bar. And thePrint functionshould "rest" until the next order is closed by the STOP.

Try to use a flag.

like

bool flag=false;

......

if (x1<0)&&(flag==false){Print();flag=true;}

Then the print will be printed ONE time.

And after the stop is triggered, reset the flag to false and the print will be executed once more....

 
Eh.... I wish someone would tell me what the poltergeist is in my code. I'd be glad to have one :-)
Reason: