[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 425

 

Please help me understand what's wrong:

//+------------------------------------------------------------------+

//| AAAA.mq4 |

//| |

//| |

//+------------------------------------------------------------------+

#property copyright ""

#property link ""


extern string TimeStart = "00:00"; //time of the beginning of the control period

extern string TimeEnd = "00:00"; //timer of the control period end.


extern double LOT = 0.01; // lot

extern int Magic = 777; // magic



double marga,Lot,SL,TP; // entered margin,lot, stop loss and take profit variables

int Total,Orders,tipOrders,TradeDey; // variables type,order type,trading day.


//+---------------------------------------------------------------------------------------------------------------------------------------+

//| function of the Expert Advisor |

//+---------------------------------------------------------------------------------------------------------------------------------------+

int start() // Function of initialization start

{

datetime Time_Start = StrToTime(StringConcatenate(Day(),".",Month(),".",Year()," ",TimeStart, ":00")); // start parameters //

datetime Time_End = StrToTime(StringConcatenate(Day(),".",Month(),".",Year()," ",TimeEnd, ":00")); // End parameters//



Total=0; // If there are no orders

for(int i=1; i<=OrdersTotal(); i++) // Order loop

{

if (OrderSelect(i-1,SELECT_BY_POS)==false) // If there are no market orders

{

if //If:

{

int BarStart = iBarShift(NULL,PERIOD_M1,Time_Start,false); // search for the bar at the beginning of the check period on m1

int BarEnd = iBarShift(NULL,PERIOD_M1,Time_End,false); //search bar end of the control period at m1

double Max_Price=iHigh(NULL,0,iHighest(NULL,PERIOD_M1,MODE_HIGH,BarStart-BarEnd,BarEnd)); //the highest price value within the period

double Min_Price=iLow (NULL,0,iLowest (NULL,PERIOD_M1,MODE_LOW,BarStart-BarEnd,BarEnd)); //the lowest price value within the period

}

if (TimeCurrent()>Time_End && ObjectFind("bar0"+Time_End)==-1) // Graphic display settings

{

ObjectCreate("bar0"+Time_End, OBJ_RECTANGLE, 0, 0,0, 0,0);

ObjectSet("bar0"+Time_End, OBJPROP_STYLE, STYLE_SOLID);

ObjectSet ("bar0"+Time_End, OBJPROP_COLOR, Blue);

ObjectSet ("bar0"+Time_End, OBJPROP_BACK, true);

ObjectSet ("bar0"+Time_End, OBJPROP_TIME1,Time_Start);

ObjectSet ("bar0"+Time_End, OBJPROP_PRICE1,Max_Price);

ObjectSet ("bar0"+Time_End, OBJPROP_TIME2,Time_End);

ObjectSet ("bar0"+Time_End, OBJPROP_PRICE2,Min_Price);

}

if (Bid<Max_Price) OrderSend(Symbol(),OP_BUYSTOP,LOT,Ask,3,Min_Price, //conditions for placing a BUY pending order

NormalizeDouble(Ask + Max_Price - Min_Price,Digits), "UPDD",Magic,Blue);

if (Bid>Max_Price)

Comment("Pending order cannot be placed on Bid");

if (Bid>Min_Price) OrderSend(Symbol(),OP_SELLSTOP,LOT,Bid,3,Min_Price, //conditions for placing SELL pending order

NormalizeDouble(Ask + Max_Price-Min_Price,Digits), "UPDD",Magic,Blue);

if (Bid<Max_Price)

Comment("Pending order cannot be placed on SELL");

}

return;

}

Can't compile. otherwise it should place two pending orders up and down from the range.

 
Legeo777:

Please help me understand what's wrong:

//+------------------------------------------------------------------+

//| AAAA.mq4 |

//| |

//| |

//+------------------------------------------------------------------+

#property copyright ""

#property link ""


extern string TimeStart = "00:00"; //time of the beginning of the control period

extern string TimeEnd = "00:00"; //timer of the control period end.


extern double LOT = 0.01; // lot

extern int Magic = 777; // magic



double marga,Lot,SL,TP; // entered margin,lot, stop loss and take profit variables

int Total,Orders,tipOrders,TradeDey; // variables type,order type,trading day.


//+---------------------------------------------------------------------------------------------------------------------------------------+

//| function of the Expert Advisor |

//+---------------------------------------------------------------------------------------------------------------------------------------+

int start() // Function of initialization start

{

datetime Time_Start = StrToTime(StringConcatenate(Day(),".",Month(),".",Year()," ",TimeStart, ":00")); // start parameters //

datetime Time_End = StrToTime(StringConcatenate(Day(),".",Month(),".",Year(),",TimeEnd, ":00")); // End parameters//



Total=0; // If there are no orders

for(int i=1; i<=OrdersTotal(); i++) // Order loop

{

if (OrderSelect(i-1,SELECT_BY_POS)==false) // If there are no market orders

{

if //If: - remove
{

int BarStart = iBarShift(NULL,PERIOD_M1,Time_Start,false); // search for the bar at the beginning of the check period on m1

int BarEnd = iBarShift(NULL,PERIOD_M1,Time_End,false); //search bar end of the check period at m1

double Max_Price=iHigh(NULL,0,iHighest(NULL,PERIOD_M1,MODE_HIGH,BarStart-BarEnd,BarEnd)); //the highest price value within the period

double Min_Price=iLow (NULL,0,iLowest (NULL,PERIOD_M1,MODE_LOW,BarStart-BarEnd,BarEnd)); //the lowest price value within the period

}

if (TimeCurrent()>Time_End && ObjectFind("bar0"+Time_End)==-1) // Graphic display settings

{

ObjectCreate("bar0"+Time_End, OBJ_RECTANGLE, 0, 0,0, 0,0);

ObjectSet("bar0"+Time_End, OBJPROP_STYLE, STYLE_SOLID);

ObjectSet ("bar0"+Time_End, OBJPROP_COLOR, Blue);

ObjectSet ("bar0"+Time_End, OBJPROP_BACK, true);

ObjectSet ("bar0"+Time_End, OBJPROP_TIME1,Time_Start);

ObjectSet ("bar0"+Time_End, OBJPROP_PRICE1,Max_Price);

ObjectSet ("bar0"+Time_End, OBJPROP_TIME2,Time_End);

ObjectSet ("bar0"+Time_End, OBJPROP_PRICE2,Min_Price);

}

if (Bid<Max_Price) OrderSend(Symbol(),OP_BUYSTOP,LOT,Ask,3,Min_Price, //conditions for placing a BUY pending order - pending orders cannot be placed by Ask or Bid

NormalizeDouble(Ask + Max_Price - Min_Price,Digits), "UPDD",Magic,Blue);

if (Bid>Max_Price)

Comment("Pending order cannot be placed on Bid");

if (Bid>Min_Price) OrderSend(Symbol(),OP_SELLSTOP,LOT,Bid,3,Min_Price, //conditions for placing SELL pending order - same

NormalizeDouble(Ask + Max_Price-Min_Price,Digits), "UPDD",Magic,Blue);

if (Bid<Max_Price) - there must be an error here

Comment("Pending order cannot be placed on SELL");

}

} - add

return;

}

I can't compile it. Actually, it should place two pending orders up and down from the range.

After the fixes, it should compile, but it probably won't work - wrongly set times, non-normalized prices, no check for proximity of stops to open prices.
 
If you are knowledgeable, could you please tell us how to set the pending order existence time to 23.59, i.e. if the order is placed by an EA, it would exist until 23.59 of the current day
 
stater:
If you are knowledgeable, could you please tell us how to set the pending order existence time to 23.59, i.e. if the order is placed by an EA, it would exist until 23.59 of the current day
datime exp=iTime(Symbol(),PERIOD_D1,0)+23*60*60+59*60;
 
Sepulca:


Thanks a lot! Can you tell me how many EAs can work in one terminal, I opened 5 charts EURUSD, I threw 5 different EAs on them, but the journal shows only the first one working...although all my faces are smiling

 

What is the smartest way to make a MM, on the condition of 0.1 lot for every 1000 balance.

Which is more reasonable to use, AccountBalance or AccountEquity?

 

Good afternoon,

Is there a command that could be added to the script (whose code is "OrderSend(Symbol(),OP_BUYSTOP...") to make the script execute on all open charts?

 
sss2019:

What is the smartest way to make a MM, on the condition of 0.1 lot for every 1000 balance.

Which is more reasonable to use, AccountBalance or AccountEquity?


It makes no difference. If you open one order, they are equal at the moment of opening, but if you have a lot, one formula is not enough.
 
stater:

Thanks a lot! Can you tell me how many EAs can work in one terminal, I opened 5 charts EURUSD and put 5 different EAs on them, but the journal shows only the first one working...although all my faces are smiling



On different currency pairs will work, even if it's the same Expert Advisor. In one chart, only one will work. But on different charts of the same currency pair I don't even know.....
 
Roger:

It makes no difference, if you open one order, they are equal at the moment of opening, and if you have many, then one formula is not enough.


I was just thinking that if i already have several orders open and they are in drawdown, then lot should be calculated with equity, otherwise if you calculate it with balance, then lot may be too big and not enough money to open.

Please show me an example of a calculation like this for a 1000 lot deposit of 0.1 lot.

Reason: