Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 306
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
Where's the idea?
In that case, not an IDEA, but an APPROACH.
Why wait? You need to check the code in the tester! You must add Spread variable with gap into modification conditions!
if (zeroprice>Ask+(Spread+gap)*Point)
//-------------------------------------------// if zeroprice is pre-multiplied, remove *Point!
if (zeroprice<Bid-(Spread+gap)*Point)
I tried, and so OrderModify(OrderTicket(),OrderOpenPrice(), OrderStopLoss(),zeroprice+Spread,0,Blue); // set the take in b/y for the Buy, if the position is negative too, but still TP=SL, though I don't understand with the gap, is it also needed as a variable?
TP is at the top and SL is at the bottom. What does it have to do with them being equal? And the gap is needed for the reserve, so that the server will accept the declared price and not reject it. Yes, let there be one variable for those cases where the price may be unacceptably close to the point of modification.
I've already said it's a flaw in the script (TP=SL), because the stop can be taken and the TP cannot, if the price doesn't reach it. We will get SL in - and God forbid the price will change and we will lose on the other ones as well.
Anyway I don't know what to change yet, I'll try it in the morning sober.
I don't know what to change yet, I'll try in the morning when I'm sober.
Please advise.
All 43 sell orders with 0.1 lot volume ($1) closed on profit, with each stop of 231 pips.
There was only 1 market order at a time.
It means that the price could not fall short by more than 230 pips on any of the positions.
Why does the tester show a 244 pip drawdown on Equity?
If the price went down to 244 pips on some position, a stop loss would be triggered.
http://clip2net.com/s/6im1rj
Please advise.
All 43 sell orders with 0.1 lot volume ($1) closed on profit, with each stop of 231 pips.
There was only 1 market order at a time.
It means that the price could not fall short by more than 230 pips on any of the positions.
Why does the tester show a 244 pip drawdown on Equity?
If the price went down to 244 pips on some position, a stop loss would be triggered.
http://clip2net.com/s/6im1rj
Maybe the test was not on Euros and the point value was not $10. Maybe a losing order had to be held for a long time and there was a negative swap.
Maybe the test was not on the EUR and the point value was not $10. Maybe the losing order had to be held for a long time and there was a negative swap.
Euro-dollar. So it's the second option.
Thank you.
Folks, please help with trailing stop!!!!!!!!!! Seems to compile everything, but in the tester does not turn on trailing stops!!! Urgent please))
//+------------------------------------------------------------------+
//| Nevalyashka_BOT.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp.
#property link "https://www.metaquotes.net/"
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
extern int Bars_To_Count = 400;
extern int int Arrow_dis_from_can = 2;//points
extern bool play_sound = true;
extern string sound_name = "Red Alert";
extern double lots =0.1;
extern int SlipPage =30;
extern int StopLoss =250;
extern int TrailingStop =220;
extern int TrailingStep =1;
extern string comment = "NaVaLyaShka wins;
extern int Magic =777;
double buf_up[];
double buf_down[];
double up;
double down;
double h;
int bars_cheked;
int ticket;
int Sl;
int i;
//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
void init()
{
SetIndexBuffer(0,buf_up);
SetIndexArrow(0,233);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(1,234);
SetIndexBuffer(1,buf_down);
SetIndexStyle(1,DRAW_ARROW);
if (Digits ==3 || Digits ==5)
{
StopLoss*=10;
SlipPage*=10;
TrailingStop*=10;
TrailingStep *=10;
}
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
void deinit()
{
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
void start()
{
for(int h=1;h<Bars_To_Count-bars_cheked;h++)
{
/////////up
if(Open[h]<Close[h])
{
for(int u=h+1;u<Bars_To_Count+1;u++)
{
if(Open[u]!=Close[u])
break;
}
if(Open[u]>Close[u])
{
Sl=NormalizeDouble(Ask-StopLoss*Point,Digits);
ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,SlipPage,0,0,comment,Magic,0,indicator_color1);
if (ticket>0)
{
if (OrderSelect(ticket,SELECT_BY_TICKET, MODE_TRADES) ==true)
{
OrderModify(ticket,OrderOpenPrice(),Sl,0,0);
}
}
buf_up[h]=Low[h]-Arrow_dis_from_can*Point;
}
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
////////down
if(Open[h]>Close[h])
{
for(int e=h+1; e < Bars_To_Count+1; e++)
{
if(Open[e]!=Close[e])
{
break;
if(Open[e]<Close[e])
{
Sl=NormalizeDouble(Bid+StopLoss*Point,Digits);
ticket=OrderSend(Symbol(),OP_SELL,Bid,Bid,SlipPage,0,0,comment,Magic,0,indicator_color2);
if (ticket>0)
{
if (OrderSelect(ticket,SELECT_BY_TICKET, MODE_TRADES) ==true)
{
OrderModify(ticket,OrderOpenPrice(),Sl,0,0);
}
buf_down[h]=High[h]+Arrow_dis_from_can*Point;
}
}
}
}
}
Trailing();
}
void Trailing()
{
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
if(OrderSymbol()==Symbol()||OrderMagicNumber()==Magic)
if(OrderType()==OP_BUY)
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>TrailingStop)
{
if(OrderStopLoss()<Bid-TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop,OrderTakeProfit(),0,Green);
}
}
}
}
if(OrderType()==OP_SELL)
{
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>TrailingStop)
{
if((OrderStopLoss()>(Ask+TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop,OrderTakeProfit(),0,Red);
}
}
}
}
}
}
//+------------------------------------------------------------------
All is not necessary!!! Thank you!!! Found and corrected))