[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 22

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello. Help for Dummies: I have an EA that can place pending orders on the min. and max. of the previous candle. Opening in the direction of the candle.
The need:
- To change the opening direction, i.e. pending buy to - pending sell.
- Make min and max of the previous candle instead of min and max of the previous day
- Leave everything else as it is, i.e. delete orders, lot parameters, stop-los, magic number
All my actions either lead to error 130 in the tester or it won't compile at all. Thanks for any advice.
Below is the working code, without my intervention.
extern double Lot = 0.01;
extern int StopLoss = 0;
extern int TakeProfit = 0;
extern int Magic = 618;
int Up_bars = 0;
int Down_bars = 0;
double StopLoss_new = 0;
double TakeProfit_new = 0;
//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
for( int cnt=0;cnt<OrdersTotal();cnt++)
{
if (OrderSelect(cnt,SELECT_BY_POS, MODE_TRADES)>0)
{
if (
(OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)
&& OrderMagicNumber() == Magic
&& OrderSymbol() == Symbol()
&& OrderComment() != DoubleToStr(Bars,0)
)
{
Comment("okkk");
OrderDelete(OrderTicket());
}
}
}
StopLoss_new = StopLoss;
TakeProfit_new = TakeProfit;
if (Up_bars != Bars)
{
if (High[1]-Ask >= MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)
{
if (StopLoss_new != 0) StopLoss_new = NormalizeDouble(High[1]-StopLoss*Point,Digits);
if (TakeProfit_new != 0) TakeProfit_new = NormalizeDouble(High[1]+TakeProfit*Point,Digits);
if (OrderSend(Symbol(),OP_BUYSTOP,Lot,NormalizeDouble(High[1],Digits),10,StopLoss_new,TakeProfit_new,DoubleToStr(Bars,0),Magic,0,Green) < 0)
{
Sleep(1000);
RefreshRates();
}
else
{
Up_bars = Bars;
}
}
}
StopLoss_new = StopLoss;
TakeProfit_new = TakeProfit;
if (Down_bars != Bars)
{
if (Bid-Low[1] >= MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)
{
if (StopLoss_new != 0) StopLoss_new = NormalizeDouble(Low[1]+StopLoss*Point,Digits);
if (TakeProfit_new != 0) TakeProfit_new = NormalizeDouble(Low[1]-TakeProfit*Point,Digits);
if (OrderSend(Symbol(),OP_SELLSTOP,Lot,NormalizeDouble(Low[1],Digits),10,StopLoss_new,TakeProfit_new,DoubleToStr(Bars,0),Magic,0,Green) < 0)
{
Sleep(1000);
RefreshRates();
}
else
{
Down_bars = Bars;
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Hello. Help a dummy figure this out:
Captain Obviousness... and yet someone give me a hint.
I'll give you a hint - put that expression in words. And you'll see that you've put it wrong.
PS.
If it is so obvious to you where to look for an error, then why ask?
If Error 130. Reconsider the stop and takeaway.
help please, the order should close at 4 times the distance from high to orderopenprice
Where did I mess up?
all orders close within 3 pips of opening
Have you tried to calculate the result of your formula? If not, then do it, because I'm getting some bullshit. Maybe it's because I don't know all the conditions.
Only one error - don't know how to fix it. Where is the problem ?
'Symbol' - initialization expected C:\Program Files\MetaTrader Finam\experts\1.mq4 (8, 13)
'Symbol - initialization expected C:\Program Files\MetaTrader Finam\experts\1.mq4 (8, 13)
alex12, specify something specific, like
Only one error - don't know how to fix it. Where is the problem ?
'Symbol' - initialization expected C:\Program Files\MetaTrader Finam\experts\1.mq4 (8, 13)
'Symbol - initialization expected C:\Program Files\MetaTrader Finam\experts\1.mq4 (8, 13)
You have:
You need to:
In fact, you can double-click on the error message and the cursor will go to the specified (by the way) location where the compilation error occurred, i.e., here: (8, 13)After that, other errors will be thrown... :)
Move the above line to the beginning of the start() function
That's a start - then deal with other errors...
Hi all.
Guys, we need some help. Describing the situation.
the current price is 1.4100 (for example) I need to find a bar whose open will be within (plus or minus 10 pt from 1.4100) from 1.4090 to 1.4110 - this is ok.
For example the program has found the bar with the open at 1.4105 that fits me.
Then the program should compare this bar with the bar to its left and the right and if it is lower, it will be suitable.
Artem, the trick here is that there is a line like this below:
So the way you suggested doesn't make much sense - if I understood correctly what alex12 wants.