[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 762

 
FoxUA:

The question is how to write this function correctly

it works like this

and I need both to work please explain

It's not a very clear question, but okay.
It's very easy to write it down, almost the same as yours:

void tmp_function(){
   if(my_total_order == 0){
      OpenBuyOrder(Lot,PRAsk);
      OpenBuyStopOrder(Lot,PRAsk); 
      OpenBuyLimitOrder(Lot,PRAsk);
   }
   if(my_total_order == 5){
      OpenBuyOrder(Lot,PRAsk);
      OpenBuyStopOrder(Lot*3,PRAsk); 
      OpenBuyLimitOrder(Lot*3,PRAsk);
   }
}
 
ToLik_SRGV:

The question is not quite clear, but OK.
It's very simple to write, almost the same as yours:


I'm not very good at explaining things, what can you do? Well, it was a digression, and now in fact there is a code composed of 2 parts, each is the appointment of the variable so the question is whether it is possible how to combine these two functions without cutting out anything from them

if(my_total_order == 0)           //|                     //|   
{double Lt=Lot;                  //|                     //|
  double PR=PRAsk;                //| --- первая функция  //|
  OpenBuyOrder(Lt,PR);            //|                     //|
  OpenBuyStopOrder(Lt,PR);        //|                     //|
  OpenBuyLimitOrder(Lt,PR);}      //|                     //|
//+--------------------------------+                      //|----  надо обеденить в одну
if(my_total_order == 5)           //|                     //|
{double Lt=Lot*3;                //|                     //|
  double PR=PRBid;                //| --- вторая функция  //|
  OpenSellOrder(Lt,PR);           //|                     //|
  OpenSellStopOrder(Lt,PR);       //|                     //|
  OpenSellLimitOrder(Lt,PR);}     //|                     //|

проблема   'Lt' - variable already defined (уже определенная переменная),       
           'PR' - variable already defined (уже определенная переменная), 
'Lt' 'PR' -  они как раз и нужны но как им присвоить разные значения ? 



 
FoxUA:

I'm not very good at explaining things, what can you do? Well, that was a digression, and now in fact there is a code composed of 2 parts, each is the appointment of the variable so the question is whether it is possible to combine these two functions without cutting out anything from them

They can be declared as global, for example, outside of the function.
And they are only needed to pass values Lot and PRAsk? It is possible to pass them directly, like I wrote.
 
ToLik_SRGV:
You can declare them as global, for example outside of functions.
Are they needed only to pass values of Lot and PRAsk? You can pass them directly, like I wrote.

Yes, but the value of one lot will be 10 and + each of them will be at PRAsk and PRBid total functions to open, namely " int OpenBuyOrder(double Lt, double PR).............." and the rest, will be hell of a lot, so I'm looking how it would not describe in 3 volumes

 

THE SOLUTION HAS BEEN FOUND, THANK YOU ALL.

 

Another question, how can I from a market order, price StopLoss andTakeProfit be assigned to a time variable ?

 
Techno:
in without visualisation, why doesn't it work? Graphic objects, corner objects don't you use?
Even if it's a bare-bones strategy without any graphics, all the same... empty in the results, like in a vacuum...
 
FoxUA:

Another question is how can I assign the StopLoss and TakeProfit price from a market order to a time variable ?

Look for the required order in the market and use functions OrderStopLoss() and OrderProfit() to get the information you need...

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

double OrderStopLoss( )
Returns the closing price when the stop loss for the currently selected order is reached.
The order must be pre-selected using the OrderSelect() function.

double OrderProfit( ) )
Returns the net profit value (without swaps or commissions) for the currently selected order. For open positions, this is the current unrealized profit. For closed orders, it is the fixed profit.
The order must be pre-selected using the OrderSelect() function.
================================================================================
... and you write it into the variables.
 
artmedia70:

Search the market for the required order and use OrderStopLoss() and OrderProfit() to retrieve the information you need...

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

double OrderStopLoss( )
Returns the closing price of a position when the stop loss level of the currently selected order is reached.
The order must be pre-selected using the OrderSelect() function.

double OrderProfit( )
Returns the net profit value (without swaps or commissions) for the currently selected order. For open positions, this is the current unrealized profit. For closed orders, it is the fixed profit.
The order must be pre-selected using the OrderSelect() function.

I'm sorry, but I didn't ask how I should find StopLoss and TakeProfit data; we know that!

 

Dear programming experts! Could you please add the function of checking the opening hours to the EA code? I.e. the EA should open positions only within a certain time interval, for example from 8 am to 8 pm (Moscow time).

Files:
Reason: