[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

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
I want to set a take profit in this way:
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.
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:
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.
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.