And let's make a "cartoon" out of it (multicurrency) - page 12

 
Swan >> :

like this:

>> Thank you.

 

I wonder about the majors right now...for my expert...)

Pound, Euro, Chiff, New Zealander, Canadian, Aussie... are in a position of readiness)

You can try to connect somehow... do a general analysis... If the directions of the chosen pairs coincide, then bet...

 
ALex2008 >> :

Thank you...

That's the way it's supposed to be.


      CheckBU=false;
      if( Type==0 && Stop> OpenPrise) CheckBU=true;
      if( Type==1 && Stop< OpenPrise) CheckBU=true;  

It may work without it, it's more reliable :)


if (( Type<=1)&&( Stop==0|| Stop!= StopLoss))       SetStop();

StopLoss is calculated in function SetStop(). It will be the same with

if ( Type<=1)       SetStop();
 
Swan >> :

StopLoss is calculated in function SetStop(). It will be the same with

No, that's different... It's not a proper check, but it's meant to check the left stop... it's supposed to be

or this.

StopLoss=MathMax(b0,b1);
>> or this

StopLoss=MathMin(s0,s1);

That is why the first StopLoss is equal to -0


if(!WorkOrders()){
      StopLoss=0;

And then it's one of the values above... And correspondingly, if the stop is exactly like this, it will not be checked again...

Swan >> :

Maybe it will work without it, it's safer that way :)

Corrected).





 
Swan >> :

if (Type<=1) SetStop();

And if you send it there at once... then every 4 hours there will be new parameters for the stop (b1,s1,b0,s0)... and it will change...

 

Tried to write it in a human way... to fix...

Added alogical variable mod to the stop check...

//+------------------------------------------------------------------+
//|                                                    CandyLite.mq4 |
//|                                                    Ш.Александр.В |
//|                                              shestovav@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Ш.Александр.В"
#property link      "shestovav@gmail.com"

#include <stdlib.mqh>

extern double Profit    = 3000;
extern double Lot       = 0.1;
extern bool BU          = true;
extern double BUenter   = 150;
extern double BUstop    = 10;


int Type, Ticket;
double OpenPrise, EnterBU, StopLossBU, SLmax, Stop, StopLevel, b1, s1, b0, s0, StopLoss, Enter;
bool mod, CheckBU;

int init(){
   Profit*=Point; 
   BUenter*=Point;
   BUstop*=Point;
   return(0);
  }

int deinit() {
   return(0);
  }

int start() {
   StopLevel=Point*MarketInfo(Symbol(),MODE_STOPLEVEL);   // вычисление стоплевел //Point*
   
   if(! WorkOrders()){
      mod=false;
      StopLoss=0;
      StopLossBU=0;
      UpTrend();
      DownTrend();
   }
      
   if( WorkOrders()){
      if (( Type<=1)&&( Stop==0||! mod))                 SetStop();
      if (( BU==true)&&( Type<=1)&&(! CheckBU))          SetBU();
      if (( Type==1)||( Type==5))                       UpTrend();
      if (( Type==0)||( Type==4))                       DownTrend();
      //Comment("SL=", );
   }

   return(0);
  }
//-------Поиск входа для установки ордеров, удаление старых ордеров и установка новых
void UpTrend(){
     if((iOpen(NULL,PERIOD_H4,1) - iClose(NULL,PERIOD_H4,1) <= 0) &&
        (iOpen(NULL,PERIOD_H4,2) - iClose(NULL,PERIOD_H4,2) > 0)){
         Enter=iHigh(NULL,PERIOD_H4,1)+(Ask-Bid)+10*Point;
         SLmax=iLow(NULL,PERIOD_H4,1)-10*Point;
         if(IsTradeAllowed()){
            DellAllOrders();
            if( Enter-Ask> StopLevel-0.5*Point){
               OrderSend(Symbol(), OP_BUYSTOP, Lot, Enter, 0, SLmax, Enter+ Profit, 0, 0,0, Green);}
         else Sleep(1000);
         }
      }
  }
void DownTrend(){
     if((iOpen(NULL,PERIOD_H4,1) - iClose(NULL,PERIOD_H4,1) >= 0) &&
        (iOpen(NULL,PERIOD_H4,2) - iClose(NULL,PERIOD_H4,2) < 0)){
         Enter=iLow(NULL,PERIOD_H4,1)-10*Point;
         SLmax=iHigh(NULL,PERIOD_H4,1)+(Ask-Bid)+10*Point;
         if(IsTradeAllowed()){
            DellAllOrders();
            if(Bid- Enter> StopLevel-0.5*Point){
               OrderSend(Symbol(), OP_SELLSTOP, Lot, Enter, 0, SLmax, Enter- Profit, 0, 0,0, Green);}
         else Sleep(1000);
         }
      }
  }

//-------Вычисление стопа и установка
void SetStop(){
      RefreshRates();
      b0=iLow(NULL,PERIOD_H4,0)-10*Point;
      s0=iHigh(NULL,PERIOD_H4,0)+(Ask-Bid)+10*Point;
      b1=iLow(NULL,PERIOD_H4,1)-10*Point;
      s1=iHigh(NULL,PERIOD_H4,1)+(Ask-Bid)+10*Point;
            
         if( Type==0){
            StopLoss=MathMax( b0, b1);
            if( Stop!= StopLoss) mod=OrderModify( Ticket, OpenPrise, StopLoss,OrderTakeProfit(),0,Red);
            else mod=true;
         }
         if( Type==1){
            StopLoss=MathMin( s0, s1);
            if( Stop!= StopLoss) mod=OrderModify( Ticket, OpenPrise, StopLoss,OrderTakeProfit(),0,Red);
            else mod=true;
         }
   }

//-------Вычисление бу и установка
void SetBU(){
      if( Type==0){
         EnterBU= OpenPrise+ BUenter;
         StopLossBU= OpenPrise+ BUstop;
         RefreshRates();
         if(Bid>= EnterBU){
            StopLoss= StopLossBU;
            OrderModify( Ticket, OpenPrise, StopLossBU,OrderTakeProfit(),0,Red);}
      }
      if( Type==1){
         EnterBU= OpenPrise- BUenter;
         StopLossBU= OpenPrise- BUstop;
         RefreshRates();
         if(Ask<= EnterBU){
            StopLoss= StopLossBU;
            OrderModify( Ticket, OpenPrise, StopLossBU,OrderTakeProfit(),0,Red);}
      }
}
   
//-------Удаление всех ордеров, открытых и отложенных
void DellAllOrders(){
      if( WorkOrders()){
      if( Type<=1)OrderClose( Ticket,OrderLots(),OrderClosePrice(),10);
      else OrderDelete( Ticket);}
  }
  
//-------Поиск ордеров
bool WorkOrders(){
      for (int i=OrdersTotal()-1; i>=0; i--){
      if (!OrderSelect( i, SELECT_BY_POS))  continue;
      if (OrderSymbol()!=Symbol())        continue;
      OpenPrise=OrderOpenPrice();
      Type     =OrderType();
      Ticket   =OrderTicket();
      Stop     =OrderStopLoss();
      CheckBU=false;
      if( Type==0 && Stop> OpenPrise) CheckBU=true;
      if( Type==1 && Stop< OpenPrise) CheckBU=true;
      return(true);}
  return(false);
  }
  
 
I will try to make my point of view too, not to impose it by any means !!!
I'm not imposing anything!!! Trailing stops, no-loss and other wisdom is absolutely unnecessary, it's all for the benefit of beginners.
It's all for the beginners and the profit of the brokerage company, the Expert Advisor, and the system itself should be as simple as possible,
Indicators, levels, etc. make absolutely no difference.
The most important thing is to have strict rules for SELL and BUY, the system is reversible, i.e., always in the market!
Once again, this is my point of view !
 
ALex2008 >> :

Tried to write it in a human way... to fix...

Added a logical variable mod to the stop check...


check, mod added and error-checking

Files:
candylite.mq4  5 kb
 
AAE >> :
I will try to make my point of view too, not to impose it by any means !!!
I'm not imposing anything!!! Trailing stops, no-loss and other wisdom is absolutely unnecessary, it's all for the benefit of beginners.
It's all for the beginners and the profit of the brokerage company, the Expert Advisor, and the system itself should be as simple as possible,
Indicators, levels, etc. make absolutely no difference.
The most important thing is to have strict rules for SELL and BUY, the system is reversible, i.e., always in the market!
Once again, this is my point of view !

totally disagree with your point of view :)

Reason: