KARAUL!!! HELP. 4 hours and 45 minutes to go!!! - page 6

 
IceBerg:

Friendship is friendship, but tobacco is apart... The full code will be for this one:

notused:

give full code with standard library (can't do it myself as I'm no expert in standard library) ...

--

not for the good, but for the bad... For you will lose your grasp of reality... learn OOP.

At this point I think the question is over.

Comrade, you don't have to teach me about OOP, I can teach anybody, and not only about OOP. I asked for a code to compare what you need to write to open a deal with the help of the standard library and what you need to write without it. And what is easier to understand in the end? It seems to be quite a constructive suggestion.

Well, no, so no.

 

A BIG THANK YOU to everyone!

sent

Waiting for verification

With any luck we will meet at the Automated Trading Championship 2012!

Good Luck to all of you!

(I have to learn ...)

 
notused:

Comrade, I don't need to be taught about OOP, I can teach anyone, and not only about OOP. And I asked for a code to compare what you need to write to open a deal with the help of the standard library and what you need to write without it. And what is easier to understand in the end? It seems to be quite a constructive suggestion.

Well, no, so no.

I have written everything.

File in directory Include:

class МойСигнальщик : public CExpertSignal //наследуемся от Signal
  {
private:
   CiCustom          МойИндикатор; 
     
public:
                     МойОбработчик();
                    ~МойОбработчик();
      
      bool              ValidationSettings(void);
      
      bool              InitIndicators(CIndicators *indicators);
      
      virtual int       LongCondition();
      virtual int       ShortCondition(); 
      
protected:

   bool              МойИндикатор(CIndicators *indicators);
    
int МойСигнальщик::LongCondition()
  {
   int signal=0;
  
   if (!signalLong0==0)
            {
               signal=100;
            }
   return(signal);
  }

In the Expert Advisor:

#include <МойСигнальщик.mqh>
input double Signal_StopLevel       =150.0;        // Stop Loss level (in points)
input double Signal_TakeLevel       =120.0;        // Take Profit level (in points)
input double Signal_PriceLevel      =10.0;         // Price level to execute a deal
input double Money_FixLot           =1.0;         
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(-1);
     }
//--- Creating signal
   CExpertSignal *signal=new CExpertSignal;
   if(signal==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating signal");
      ExtExpert.Deinit();
      return(-2);
     }
//---
   ExtExpert.InitSignal(signal);
   signal.ThresholdOpen(Signal_ThresholdOpen);
   signal.ThresholdClose(Signal_ThresholdClose);
   signal.PriceLevel(Signal_PriceLevel);
   signal.StopLevel(Signal_StopLevel);
   signal.TakeLevel(Signal_TakeLevel);
   signal.Expiration(Signal_Expiration);
//--- Creating filter IRTMiniMax
   МойИндикатор *filter0=new МойИндикатор;
   if(filter0==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating filter0");
      ExtExpert.Deinit();
      return(-3);
     }
   signal.AddFilter(filter0);
//--- Set filter parameters
   filter0.Weight(Signal_MovingMM_Weight);
//--- Creation of trailing object
   CTrailingNone *trailing=new CTrailingNone;
   if(trailing==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating trailing");
      ExtExpert.Deinit();
      return(-4);
     }
//--- Add trailing to expert (will be deleted automatically))
   if(!ExtExpert.InitTrailing(trailing))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing trailing");
      ExtExpert.Deinit();
      return(-5);
     }

//--- Set trailing parameters
//--- Creation of money object
   CMoneyFixedLot *money=new CMoneyFixedLot;
   if(money==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating money");
      ExtExpert.Deinit();
      return(-6);
     }
//--- Add money to expert (will be deleted automatically))
   if(!ExtExpert.InitMoney(money))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing money");
      ExtExpert.Deinit();
      return(-7);
     }
//--- Set money parameters
   money.Lot(Money_FixLot);
//--- Check all trading objects parameters
   if(!ExtExpert.ValidationSettings())
     {
      //--- failed
      ExtExpert.Deinit();
      return(-8);
     }
//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(-9);
     }
//--- ok
   return(0);
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| "Trade" event handler function                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
   ExtExpert.OnTrade();
  }
//+------------------------------------------------------------------+
//| "Timer" event handler function                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+

That's all...

Teach me about OOP, please

 

And the whole thing is already ready and there's no need, again, to reinvent the wheel...

 
pavivas:

A BIG THANK YOU to everyone!

sent

Waiting for verification

With any luck we will meet at the Automated Trading Championship 2012!

Good Luck to all of you!

(I have to learn ...)

Oof )) Congratulations. Now we'll have to cheer for you ))
 
MqlTradeRequest request = {0};
MqlTradeResult result = {0};
MqlTick tick;
SymbolInfoTick(_Symbol, tick);
request.volume = 1;
request.action = TRADE_ACTION_DEAL;
request.symbol = _Symbol;
request.type_filling = ORDER_FILLING_FOK; 
request.price = tick.ask;
request.sl = tick.ask - 100 * _Point;
request.tp = tick.ask + 200 * _Point;
request.type = ORDER_TYPE_BUY;
request.deviation = 10;
OrderSend(request, result);    
Which is easier? Filling in one structure or dealing with signals?
 
notused:
which is easier? filling one structure or dealing with signals?
I agree, classes are good, libraries are for the lazy... IMHO
 
Mischek:
Oof )) Congratulations. Now we'll have to cheer for you ))
 
notused:
What's easier? fill in one structure or deal with signals?

That's the thing... The Signal in this particular case can be a text message from your phone... but when you tell your advisor exactly what to do... he'll do it...

I can do anything on the Signal, as long as the suit fits... I'm already on ATC2012)

 
notused:

Yes, that's the way to go.

but more often than not.