Buy/Sell

Back to topics list To post a new topic, please log in or register
avatar
10
nofear91 2015.06.29 13:23
 

Hi, 

 

 I'm trying to buy or sell between d1-d2 lines. if UpTrend ->> Buy else->> Sell. Where do I add buy and sell command?  Can you help me?

 

bool CheckD1D2() {
   bool myCheck = False;
   if(upTrend) {
      if (candle_Low < d1 && candle_Low > d2) {myCheck = True;}
   } else {
      if (candle_High > d1 && candle_High < d2) {myCheck = True;}
   }
   return(myCheck);
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

avatar
Moderator
3406
GumRai 2015.06.29 13:38 #
 

if UpTrend ->> Buy else->> Sell.

That obviously means something to you. It means nothing to me.

So i have no idea what you are asking 

avatar
10
nofear91 2015.06.29 14:21 #
 
GumRai:

if UpTrend ->> Buy else->> Sell.

That obviously means something to you. It means nothing to me.

So i have no idea what you are asking 

 

 

void OnTick()
{
  
   // We only run the EA after a full tick!
   static datetime tmp;
   if (tmp != Time[0])
   {
      tmp =  Time[0];
      cHigh = iHigh(NULL,0,1);
      cLow = iLow(NULL,0,1);
      
      bool minmaxChangeLow = FALSE;
      bool minmaxChangeHigh = FALSE;
      switch(state) {
         
         // 1 = Find Retracement
         case 1:
            // Decrement initBuffer if it is over 0
            if (initBuffer > 0) {initBuffer--;}
            // Did max or min change? If yes then recalc R
            minmaxChangeLow = FALSE;
            minmaxChangeHigh = FALSE;
            if (cHigh > max){
               max = cHigh;
               maxt = Time[1];
               upTrend = TRUE;
               minmaxChangeHigh = TRUE;
               Print("cHigh > max... upTrend:" + IntegerToString(upTrend));
            }
            if (cLow < min){
               min = cLow;
               mint = Time[1];
               upTrend = FALSE;
               minmaxChangeLow = TRUE;
               Print("candle_Low < min... upTrend:" + IntegerToString(upTrend));
            }
            // SPECIAL CASE: BOTH MIN AND MAX CANNOT BE CHANGED AT THE SAME TIME...
            // If they both changes, ignore...
            if ((minmaxChangeHigh && !minmaxChangeLow) || (!minmaxChangeHigh && minmaxChangeLow)){
               Print("Min Max changes!");
               CalcRetracement();
               // If we are over the init buffer, go to next state...
               if (initBuffer == 0) {
                  trendMin = 1000;
                  trendMax = 0;
                  state = 2;
               }
               break;
            }
            // If we are below D2, cancel Retracement and find a new one...
            if(upTrend) {
               if (cLow < D2) {
                  min = cLow;
                  mint = Time[1];
                  upTrend = False;
                  CalcRetracement();
                  break;
               }
            } else {
               if (cHigh > D2) {
                  max = cHigh;
                  maxt = Time[1];
                  upTrend = True;
                  CalcRetracement();
                  break;
               }
            }
         break;
         
         // 2 = Find trend line
         case 2:
            // If we are between D1-D2 buy or sell 
            // If we are past D2, the retracement is cancelled and we go back to previous state!
            if (CheckD1D2()) {
               if(upTrend){
                  buy();
               else{
                  sell();
                }
               }
               state =3;
               break;
            }
            if (CheckD2()) {
               trendMin = 1000;
               trendMax = 0;
               state = 1;
               break;
            }
            if (CheckMinMax()) {
               CalcRetracement();
               trendMin = 1000;
               trendMax = 0;
               state = 1;
               break;
            }
         break;
         
avatar
12985
WHRoeder 2015.06.29 16:46 #
 
nofear91:
  1. No question asked, no reply needed.
  2. You already have buy() and sell() functions. What is your problem?
Back to topics list  

To add comments, please log in or register