ONLY CANDLE / BAR - How to catalog or segregate Candle? - PLEASE CORRECT ME!

 


ONLY CANDLE - How to catalog or segregate Candle?

PLEASE CORRECT ME!



We have bullish and Bearish candle I want to segregate this

 it's just like shepherd. shepherd have farm, croft and have sheep.

when it is season to shave sheep shepherded Mr. JOHN go to farm caught the sheep and ...

First sheep caught is too small to shave - John let go.

Next sheep is good John take scissors and sheep is naked

Next sheep is good and have big wool - John take BIG scissors and sheep is naked

Next sheep is Aries - John take Knife and Aries is eunuch at this moment


I want do the same with candle / bars
Our candle is going Bar[0].... we waiting..... she is going, we waiting.... 15 minutes (M15) and there is it! ... what is it? check!

If I have Bullisch Candle and Candle (price open [1]- price close [1]) have 2 point too small - let go , we do nothing



If I have Bullisch Candle and Candle (price open [1]- price close [1]) have 4 point - then start program

CheckForOpenS1();  start buy function if our price get  + 4 Point above our candle  (scenario1)

 

If I have Bullisch Candle and Candle (price open [1]- price close [1]) have 5 point -This is very Big Candle- then start program

CheckForOpenS2();  start buy function if our price get  + 14 Point above our candle  (scenario2)



I want to this witch every candle, I want start program BUY if I have big Candle, if I have too small Candle i will be waiting for the next

So... this is in correct but I have idea :)

Please do not write no necessary thing.

int start() // start program 
   
double bear() // check first candle -mabey is bear? = THIS IS aur NEW function title bear body is in()
   {     // start body
      double A=Open[1];  // stay Open[1] is changeable A
      double B=Close[1];  // stay Open[1] is changeable A    
      double C=A-B;         // result
      return(C);              // take result C and put in to function bear()
   }                              //end body, NOW bear is aur C example 6 or 89 ;212; 1; 2;..;;;.
   
double bull() // check first candle -mabey is bull
   {
      double A=Open[1];   // we use double because euro/usd have point example 1.9865
      double B=Close[1];     
      double C=B-A;
      return(C);
   }

// when we have bull catalog/ segregate  him..
switch(bull())
      { 
         case 1 : break;            // nothing happen
         case 2 : break;            // nothing happen
         case 3 : break;            // nothing happen
         case 4 : CheckForOpenS1(); break; // start CheckForOpenS1()- take it and go thrue with this.. we will see want is '...S1'
         case 5 : CheckForOpenS2(); CheckForOpenS3() break; // start CheckForOpenS2() and S3 ....
      }

// when we have bears catalog/segregate him..
switch(bears())
      { 
         case 1 : break;
         case 2 : break;
         case 3 : break;
         case 4 : CheckForOpenY1(); break;// start CheckForOpenY1()- take it and go thrue with this.. we will see want is '...Y1'
         case 5 : CheckForOpenY2(); CheckForOpenY3(); break; // start CheckForOpenY2() and Y3
      }


return(); // exit program wait for new tip, and ower and ower ....
}  // end


 
 

Do you think any non English first language people can understand your story? I understand sheep and sheperd Mr John, but the story makes no sense to me. (Maybe its me... so I am sorry)

Could you explain your problem in some 'international English' using the general definitions for trading/mql4?

What does this sentence mean?


PLEASE DO NOT WRITE TOPIC this well be hand book for the rest people
 
kronin:

Do you think any non English first language people can understand your story? I understand sheep and sheperd Mr John, but the story makes no sense to me. (Maybe its me... so I am sorry)

Could you explain your problem in some 'international English' using the general definitions for trading/mql4?

What does this sentence mean?

Kronin, probably that was just error in online translator, it happened all the time in forum.
 

ONLY CANDLE - How to open position? - it should be next subject. Moderator what are You think? can I?

We implement the selected scenario
How to send order?

int start() // start program 
{

// We have some function here like "int CalculateCurrentOrders(string symbol)" and  "double LotsOptimized()"
// many different thing, suddenly! we have our "CheckOpen();" 

//--------------------------------

void CheckOpen()      // void - because function return nothing
{                     // start body
   int    res;        // we will use changeable "res" this is "int" value
   if( Bid==Close[1]+4*Point)  // check conditions: Bid or Ask must be 4 Point above a BAR if no - nothing happen if Yes go below
     {               // start body if
      res=OrderSend(Symbol(),OP_SELL,0.02,Bid,0,Open[1]+37*Point,0,"",MAGICMA,0,Red);  // start "res" and "res" is sending message to platform to open position 
                     // what position is in "()" allways must be the same sequence symbol , op_*** , lot size , ...)
      return;        // if "res" do it then retunrn too ... y ... "if". Because "if" is done return too CheckOpen(). Because "CheckOpen()" is done stop and end.
     }               // stop body if

  }                  // stop body function "void CheckOpen()"
  
//-------------------------------- 

  We have one order 
  But what I should do to open two position in one function?
  We have our scenario CheckForOpenS1() in these scenario We buy two times if our price will be in correct place of course

//--------------------------------  


 
void CheckOpen1()      // define first function
{                     
   int    res;       
   if( Bid==Close[1]+4*Point)  
     {               
      res=OrderSend(Symbol(),OP_SELL,0.02,Bid,0,0,0,"",MAGICMA,0,Red);  
                     
      return;        
     }               

}   
  
void CheckOpen2()      // define second function
{                     
   int    res;       
   if( Bid==Close[1]+8*Point)  // change 8 Point ( 4 ==> 8 )
     {               
      res=OrderSend(Symbol(),OP_SELL,0.02,Bid,0,0,0,"",MAGICMA,0,Red);  
                     
      return;        
     }               

}   

//       I DONT KNOW..............

//--------------------------------  / our scenario  
void CheckForOpenS1()= true;      
 
  void CheckOpen1()
  void CheckOpen2()
  
  
//--------------------------------  / OR LIKE THESE
int res;
if ( CheckForOpenS1() == true)
 {
 res= CheckOpen1() CheckOpen2();
 }
 
Wodzuuu:

ONLY CANDLE - How to open position? - it should be next subject. Moderator what are You think? can I?

We implement the selected scenario
How to send order?

  We have one order 
  But what I should do to open two position in one function?
  We have our scenario CheckForOpenS1() in these scenario We buy two times if our price will be in correct place of course

I don't really understand what you are asking . . .  you are not making yourself very clear . . . or maybe it is just me.

This code will cause you problems though . . .

if( Bid == Close[1] + 4 * Point)

 Read this thread:  Can price != price ?

 

might otherwise
how to write a simple EA with several scenarios of events

was a small candle - open Features 1
was the average candle -  open Features 2
was a large candle - open Features 3


switch () is appropriate at this point, I think

Function 1 opens 1 position and makes sure it closes
The 2 opens 2 positions guarding them and closes
The three open 2 positions but at a different price ....

every time we have a candle, every time there is another function that does different things

I know that you can not write for me, but any advice.... 

 

As promised, I looked at that again, but it does still not make sense to me, I am sorry.

This will never work:

double bull() // check first candle -mabey is bull
   {
      double A=Open[1];   // we use double because euro/usd have point example 1.9865
      double B=Close[1];     
      double C=B-A;
      return(C);	// <-- C is probably never 1,2,3,4,5.....
   }

// when we have bull catalog/ segregate  him..
switch(bull())		// <-- the expression here is something like 0.00123. None of your case statements will be executed.
      { 
         case 1 : break;            // nothing happen
         case 2 : break;            // nothing happen
         case 3 : break;            // nothing happen
         case 4 : CheckForOpenS1(); break; // start CheckForOpenS1()- take it and go thrue with this.. we will see want is '...S1'
         case 5 : CheckForOpenS2(); CheckForOpenS3() break; // start CheckForOpenS2() and S3 ....
      }

Read here about how to use switch: https://docs.mql4.com/basis/operators/switch

 

This is not clear at all:

void CheckOpen2()      // define second function
{                     
   int    res;       
   if( Bid==Close[1]+8*Point)  // change 8 Point ( 4 ==> 8 )
     {               
      res=OrderSend(Symbol(),OP_SELL,0.02,Bid,0,0,0,"",MAGICMA,0,Red);  
                     
      return;        
     }               

} 

The equal expression is maybe not wanted, but what should it be?

If it should read as < then it will immediately send a SELL order when a new bar arrives (as the open price of the new bar is maybe < than the close price of the previos bar +8*Point)
If it should read as > then it will wait for the price is moving up a little bit and then send a SELL order. I don't really understand your strategy, so it's maybe wanted like this.

I could also imagine you mean: 

if(Bid<Close[1]-8*Point)   

Are you trading with a 4 digit broker where 1 Point is equal to 1 Pip? Otherwise the price must only move 0.8 pips what is also probably not what you want (And the spread could additionaly confuse it).

I think you should go through your code again and correct it where you can. Feel free to ask further questions if you have any specific ones. Please be aware, that your strategy can work completely else, only because a coder misunderstood what you have meant. 

 

My strategy is to
if the candle appears BULL from 4 to 5 point , after the candle (ever, under any conditions) get ready to send two Buy orders (if the price reaches our required level to buy one, and how to reach buy2)

if the candle appears BULL from 6 to 7 point, after the candle (ever, under any conditions) get ready to send three Buy orders (if the price reaches our required level to buy one, and how to reach buy2 and 3)

I have a small mistake somewhere in the Bid or Ask why EA does not work ... (I can not find this error but normally EA works very well for what I wrote .. buys and close) but it shows my technical plan.

I MAKE CORRECT IT WORKS AT NOW

As you look at the bottom it gets very crowded and sometimes replaces the EA Bull4 scenarios and scenario opens Bull6 Bull4 and as I realized it suddenly change your mind and finish the Bull6 Bull6
Can it be simplified ?

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#define MAGICMA  20050610


//+------------------------------------------------------------------+
//| Calculate open positions    HOW MEANY OF THIS                    |
//+------------------------------------------------------------------+

int CalculateCurrentOrders(string symbol)
  {
   int buys=0,sells=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; 
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
        {
         if(OrderType()==OP_BUY) buys++;
        }
     }
//---- return orders volume
   return(buys);
  }

//+------------------------------------------------------------------+
//| Calculate candle                                                 |
//+------------------------------------------------------------------+
bool BULL4()
   {
   if(Close[1]-Open[1]>=4*Point && Close[1]-Open[1]<=5*Point)
   return(true);
   } 

bool BULL6()
   {
   if(Close[1]-Open[1]>=6*Point && Close[1]-Open[1]<=7*Point)
   return(true);
   }
      
//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+
 
void CheckForOpenBULL41()
  {
   int    res;
   if(Bid==Close[1]+3*Point)  
     {
      res=OrderSend(Symbol(),OP_BUY,0.41,Ask,0,Close[1]-25*Point,0,"",MAGICMA,0,Blue);
      return;
     }
  }
  
void CheckForOpenBULL42()
  {
   int    res;
   if(Ask>OrderOpenPrice()+2*Point)  
     {
      res=OrderSend(Symbol(),OP_BUY,0.42,Ask,0,Close[1]-25*Point,0,"",MAGICMA,0,Blue);
      return;
     }
  }  
  
void CheckForOpenBULL61()
  {
   int    res;
   if(Bid==Close[1]+4*Point)  
     {
      res=OrderSend(Symbol(),OP_BUY,0.61,Ask,0,Close[1]-25*Point,0,"",MAGICMA,0,Red);
      return;
     }
  }
  
void CheckForOpenBULL62()
  {
   int    res;
   if(Ask>OrderOpenPrice()+2*Point)  
     {
      res=OrderSend(Symbol(),OP_BUY,0.62,Ask,0,Close[1]-25*Point,0,"",MAGICMA,0,Red);
      return;
     }
  }

void CheckForOpenBULL63()
  {
   int    res;
   if(Ask>OrderOpenPrice()+2*Point)  
     {
      res=OrderSend(Symbol(),OP_BUY,0.63,Ask,0,Close[1]-25*Point,0,"",MAGICMA,0,Red);
      return;
     }
  }
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+

void CheckForCloseBULL()
{
   RefreshRates();
   if(OrderOpenPrice()+4*Point< Ask)
   for (int i = OrdersTotal(); i >= 0;i--)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if (OrderSymbol() == Symbol()) 
      {
         bool ticket = true;
         if (OrderType() == OP_BUY) ticket = OrderClose(OrderTicket(),OrderLots(),Bid,1,Black);

      }
   }
} 

  
  
//+------------------------------------------------------------------+
//| Start function                                 |
//+------------------------------------------------------------------+
void start()
  {
   
   if(BULL4()==true && CalculateCurrentOrders(Symbol())==0) CheckForOpenBULL41();
   else                                    CheckForCloseBULL();

   if(CalculateCurrentOrders(Symbol())==1) CheckForOpenBULL42();
   else                                    CheckForCloseBULL();
   
   //---//
   
   if(BULL6()==true && CalculateCurrentOrders(Symbol())==0) CheckForOpenBULL61();
   else                                    CheckForCloseBULL();

   if(CalculateCurrentOrders(Symbol())==1) CheckForOpenBULL62();
   else                                    CheckForCloseBULL();
   
   if(CalculateCurrentOrders(Symbol())==2) CheckForOpenBULL63();
   else                                    CheckForCloseBULL(); 
    
   if(CalculateCurrentOrders(Symbol())==3) CheckForOpenBULL63();
   else                                    CheckForCloseBULL(); 
       
   if(CalculateCurrentOrders(Symbol())==4) CheckForCloseBULL();
  }
//+------------------------------------------------------------------+

 

 
Wodzuuu:

My strategy is to
if the candle appears BYK from 4 to 5, after the candle (ever, under any conditions) get ready to send two data purchase orders (if the price reaches our required level to buy one, and how to reach zkup 2)

if the candle appears BYK from 6 to 7, after the candle (ever, under any conditions) get ready to send three purchase orders (if the price reaches our required level to buy one, and how to reach zkup 2 and 3)

I have a small mistake somewhere in the Bid or Ask why EA does not work ... (I can not find this error but normally EA works very well for what I wrote .. buys and close) but it shows my technical plan.

As you look at the bottom it gets very crowded and sometimes replaces the EA Bull4 scenarios and scenario opens Bull6 Bull4 and as I realized it suddenly change your mind and finish the Bull6 Bull6
Can it be simplified ?

BYK ??

 

This is wrong . . .

for (int i = OrdersTotal(); i >= 0;i--)

  . . .  the positions start at 0,  so you need to count down from OrdersTotal() - 1


You do this . . . .

void CheckForCloseBull()           // close ALL AT ONCE buy of course
{
   RefreshRates();
   if(  OrderOpenPrice()  > Ask+6*Point)

 . . .  you get the OrderOpenPrice()  but for which Order ?  you will have multiple orders open . . .



You use variable  res  to hold the return value from your OrderSend() calls . . . and what do you do with it ?  nothing,  why ?

 What are Function return values ? How do I use them ?

 

Very good answer RaptorUK


1. res problem
I am studying EA Moving Average resolution there is only 3 times, all as a function of time, after for it does not exist.

The first time it is used for information "hello we will be use res"

a second  time to send the order. OrderSend returns the number of orders, which is our res = 343321, abowe the function 'void CheckForOpen () " res does not exist.

but...
I think that if the "void CheckForOpen ()" Observe the truth of this command OrderSelect somehow bring that number except "void CheckForOpen ()" I will try ..
 

2. OrderOpenPrice() problem

 you're absolutely right, but this syntax works surprisingly well :)  I will try do something in that place

 

3. OrdersTotal() - 1  you're absolutely right,

 

4. BYK (POLAND)= BULL  translator have problem  

 

For those who still do not understand my EA write a story: D hehehe


All the steps that we do, are the functions. I am now writing on a computer is one function. I watch TV show is the second function, etc.
Now let's move to the kitchen ...
We have a cookbook, open the table of contents and read sequentially points
First How to make pork chops - put the meat into a bowl, add salt, peper, peel potatoes
On the left the event - the right features, and a few of theme - no unless easy!


After reading how to make pork chops begin to do it, to do things. Steak gets 25 minutes, and as I started to have an end.
It's been five minutes  M5 ( five minutes later) we start read the next point a cookbook.
Second How to make a salad - Peel carrots, peel onions, and other crap


And here the magic happens, because it created double, maple (second person). We do this on pork chops and salad at the same time. We begin to have in the kitchen two people in one.

The more points you read, the more people in the kitchen appears. People in the kitchen will disappear after completing their duties and wash the dishes.


The event is candles - features various options for buying and selling or closing.