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

 
belck:

I want to set a take profit in this way:

if (TakeProfit<10*Point) TakeProfit=10*Point;
The indicator line changes its position after a certain period of time. How can I make sure that take profit does not change, but stays the same as it was set when I opened it?
I can hardly guess why you calculate TP. TP is usually calculated at the moment of order placement - then it will be assigned to the order and you need to change it using OrderModify(), sometimes TP is virtual, in this case you need to save it in the array
 
IgorM:
I can't even guess why you calculate TP. Usually TP is calculated at the time of placing the order - then it will be assigned to the order and you need to change it using OrderModify(), sometimes TP is virtual, then store it in an array

Thanks for the tip.

 

I have just made up an EA, I keep training, everything is getting faster each time, but it is not trading!

If you can, please advise, I think I will be in touch.

//+------------------------------------------------------------------+
//| Dimon's Borders .mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialisation function |
//+------------------------------------------------------------------+
extern int BandsPeriod=20,i=1 ;extern int BandsShift=0;
extern double BandsDeviations=2.0;
extern double Lots=0.1,TakeProfit=50,stoploss=10;
int init()
{int Average;
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialisation function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{double Average,Upper Border,Lower Border,newres,sum,deviation;

Average=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);
//----
newres=Close[i]-Average;
sum=newres*newres;


deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
Upper boundary=Average+deviation;
Lower boundary=Average+deviation;
//----
if (Upper boundary<Close[i])
{ Comment(" buoy! ",Upper Boundary );
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-stoploss*Point,Ask+TakeProfit*Point, "macd sample",16384,0,Green);

}


if (Lower Limit>Close[i])
{ Comment(" sell! ",Bottom Border );

OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+stoploss*Point,Bid-TakeProfit*Point, "macd sample",16384,0,Red);
}
return(0);
}
//+------------------------------------------------------------------+

I apologize for the non-English variables, it is a lot easier for me to remember what to do.

 
VOLDEMAR:
Hi ! I can't figure out what's wrong with ???? Doesn't modify market order
slb =NormalizeDouble(Bid - (StopLoss * Point),Digits); // calculation of stop for buy positions//
tpb =NormalizeDouble(Ask + (TakeProfit* Point),Digits); //calculate profit for buy positions//
sls =NormalizeDouble(Ask + (StopLoss * Point),Digits); //calculate stop for sell positions//
tps =NormalizeDouble(Bid - (TakeProfit* Point),Digits);

//================================================== ==================//
int total=OrdersTotal();
int n=0;
for (int i=total-1; i>=0; i--)
{
if(OrderSelect(i, SELECT_BY_POS))
{
if(OrderSymbol()==Symbol())
{
n++;
}}}
if ( total == 1 )
{
for (int k=total-1; k>=0; k--)
{
if(OrderSelect(k, SELECT_BY_TICKET))
Alert("order exists", k);
{
if ((OrderType()==OP_BUY)&&(OrderTakeProfit()==0)&&(OderStopLoss()==0))
{
OrderModify(k,OrderOpenPrice(),slb,tpb,0,Blue);
Alert("error", GetLastError());

}}}}
return(0);}

WHAT'S THE PROBLEM PLEASE HELP ...........?????

you can still try it like this:

double TakeProfitBuy = NormalizeDouble((three - zero) / 4, Digits);
if (TakeProfitBuy<10*Point) TakeProfitBuy=10*Point;
double TakeProfitSell = NormalizeDouble((zero - two) / 4, Digits);
if (TakeProfitSell<25*Point) TakeProfitSell=25*Point;
 

What is the best way:

- specify in the advisor on which pairs and what period to trade

or

- throw an EA on a chart of a currency pair with the necessary preset timeframe

??

 

Just one more thing - please don't be clever, I'm writing in advance, otherwise it's not very pleasant.

The answer to this question is very important to me, so please take it seriously.

 
In my opinion, the second option is much more practical and convenient.
 

To make up your mind and settle on a chosen solution.

I'm also inclined to the idea of just throwing an EA on the required currency pairs, or to write one for certain currency pairs.

i'm also inclined to the option of just throwing it on.

As for the trader's taste, it is not so important to choose an Expert Advisor.

 
Got it. Very clever. I'm not an expert, but the second option is a lot easier.
 
Please help! The Expert Advisor is not working, not trading at all.
Reason: