Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 218

 
Oh, and I forgot the calendar.
 
FEAR:
Oh, and I forgot the calendar.

I don't quite understand... What's your point?
 

Hello! Sorry if this is the wrong place, but I think it is. I have recently started to study Expert Advisor programming and chose Puria method as an experiment.

Here is the Expert Advisor itself:

#define MAGICMA 1111
//Input parameters
extern int TP=150;
extern int SL=150;
extern int MP1=5;
extern int MP2=75;
extern int MP3=85;
double macd,macdS,ma1,ma1S,ma2,ma3;
bool buy =false;
bool sell =false;
//bool buy_ma=false;
/*****************************************************************************/
int init()
{
return(0);
}
/*****************************************************************************/
int deinit()
{
return(0);
}
/*****************************************************************************/
void start()
{
//double sl,tp;
ma1=iMA(NULL,0,MP1,0,MODE_EMA,PRICE_CLOSE,1)
ma1S=iMA(NULL,0,MP1,0,MODE_EMA,PRICE_CLOSE,2);
ma2=iMA(NULL,0,MP2,0,MODE_LWMA,PRICE_LOW,1);
ma3=iMA(NULL,0,MP3,0,MODE_LWMA,PRICE_LOW,1);
macd=iMACD(NULL,0,19,27,1,PRICE_CLOSE,MODE_MAIN,1);//1526.1
//macdS=iMACD(NULL,0,19,27,1,PRICE_CLOSE,MODE_MAIN,2);

if( ma1 > ma2 && ma1>ma3){
if( ma1S<ma2 && ma1S<ma3){
buy=true;
}
}
if ( ma1 < ma2 && ma1 < ma3){
if (ma1S > ma2 && ma1S > ma3)
sell=true;
}
for(int i=0;i<OrdersTotal();i++){
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
if(OrderType()==OP_BUY){
buy=false;
}
if(OrderType()==OP_SELL){
sell=false;
}
//else sell=false;
}
if (macd > 0 && buy){
OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-SL*Point,Ask+TP*Point,"",MAGICMA,0,Blue);
buy=false;
}
if (macd < 0 && sell){
OrderSend(Symbol(),OP_SELL,0.01,Bid,3,Bid+SL*Point,Bid-100*Point,"",MAGICMA,0,Red);
sell=false;
}

}

A number of questions have arisen:

1) How to make expert to work on different methods of quotation ( 4 or 5 signs)

2) I would like to write a trailing stop instead of a take profit (how to implement it or useful link).

 

Please tell me please, I want to order two scripts to sell all orders in buy terminal and sell all orders in sell terminal no need any gui, only to put on hotkeys. How much will it cost and where to order it from?

I would like to place them in a code base, and the author's stuff will remain if necessary.

I understand what I have to do in the terminal to select orders and then execute a cloSed, but I can not do it for a long time because of the two simple scripts.

Thanks.

 
bambastik:

Please tell me please, I want to order two scripts to sell all orders in buy terminal and sell all orders in sell terminal no need any gui, only to put on hotkeys. How much will it cost and where to order from?

Thank you.

Have you looked in the catbase?
 
artmedia70:
Have you looked in the catbase?

Yes, I did, in the kotobase, there are only these suitable in essence https://www.mql5.com/ru/code/8602 but they are difficult for my understanding, I have very little brains. there you need to put type instead of profit but how to do it I can not understand.
 
bambastik:
I looked it up, in the cotbase, there are only these suitable scripts https://www.mql5.com/ru/code/8602 but they are difficult for me to understand, I have very little brains.
What kind of script do you need? What should it do?
 

In fact. Select all the buys on the chart and close them and that's it. And the same one only with sell.

I've re-did this one now, but the compiler says something is wrong with the end.

//+------------------------------------------------------------------+
//| CloseAllProfit.mq4 |
//| Copyright © 2008, PRMQuotes Software Corp. |
//| Jedimedic77@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, PRMQuotes Software Corp."
#property link ""

//+------------------------------------------------------------------+
//| global variables to program: |
//+------------------------------------------------------------------+
double Price[2];
bool closesell = true;


void start() {
int iOrders=OrdersTotal()-1, i;

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderType() >= 0)) {
if((OrderType()==OP_SELL) {
OrderClose(OrderType());
}

}

I've never looked at the profile, but I've seen it in the forum. I've never seen it before and it's a long story, so I guess it worked out that way.
 
bambastik:

In fact. Select all the buys on the chart and close them and that's it. And the same only with sell.

All Buy and all Sell are two different scripts. This has been clear from the beginning. The question is - should it close absolutely all positions? Or should it close only those positions that are on the chart where the script is running? Should it close positions opened manually or positions opened by an Expert Advisor, or both?
 
artmedia70:
All Buy and all Sell are two different scripts. That was clear from the start. The question is - should it close absolutely all positions? Or should it close only those positions that are on the chart where the script is running? Should it close positions opened manually or positions opened by an Expert Advisor, or both?

Otherwise, they may write any error messages, checks etc. I think this script does not need anything like that. I do not use EAs, I only trier now, I have no plans for classes in my life in the next month, I have decided to check forex.
Reason: