View Single Post
  #17 (permalink)  
Old 06-29-2006, 09:35 PM
Aaragorn's Avatar
Aaragorn Aaragorn is offline
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
ok somewhere down here I think I have to make the logic conditions that use the indicator to filter...

PHP Code:
// ENTRY
  
    
if(total || isNewSumbol(Symbol())) //I have modified the if condition too: it was total<1 (orBanAway aka cucurucu)
     
{
       
double HedgeLots = (HedgePercent/100)*Lots//calculates the Lots for the hedged position
       
if(isCrossed == 1)
         {
            if(
UseStopLoss)
               
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);
            else
               
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);
            
            if(
ticket>0)
              {
               if(
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
              }
            else Print(
"Error opening BUY order : ",GetLastError()); 
//######################################################################   the added code starts here         
            
if(UseStopLoss)
               
ticket=OrderSend(Symbol(),OP_SELL,HedgeLots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);
            else
               
ticket=OrderSend(Symbol(),OP_SELL,HedgeLots,Bid,3,0,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);
            
            if(
ticket>0)
              {
               if(
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
              }
            else Print(
"Error opening SELL order : ",GetLastError());             
//######################################################################   ends here          
            
return(0);
         }
         if(
isCrossed == 2)
         {
            if(
UseStopLoss)
               
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);
            else
               
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);
            
            if(
ticket>0)
              {
               if(
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
              }
            else Print(
"Error opening SELL order : ",GetLastError()); 
//###################################################################### the added code starts here  
            
if(UseStopLoss)
               
ticket=OrderSend(Symbol(),OP_BUY,HedgeLots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);
            else
               
ticket=OrderSend(Symbol(),OP_BUY,HedgeLots,Ask,3,0,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);
            
            if(
ticket>0)
              {
               if(
OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
              }
            else Print(
"Error opening BUY order : ",GetLastError()); 
//######################################################################  ends here   
            
return(0);
         }
         return(
0);
      }
     return(
0);
     }
     
   return(
0);
  }
  }
//+------------------------------------------------------------------+ 
I'm thinking to make this...
if(isCrossed == 1 && point < **the top line variable from the custom indicator**- 25)
if(isCrossed == 2 && point > **the bottom line variable from the custom indicator** +20)

would that work, would that make the indicator filter the orders?

no that's not right that doesn't separate the buys from the sells because it triggers both a sell and a buy on a buy signal and on a sell signal ...oy

but which variable from the indicator? I'm still not certain which to use?

if(isCrossed == 1 && Point < topindicatorlinevalue - longrange)
if(isCrossed == 2 && Point < bottomindicatorlinevalue + shortrange)

I have trouble getting the variable out of the indicator. I tried making a global variable to do it but that didn't work for me, I don't know why.

I put this in the top part...

//---- Filter Parameters
extern double longrange = 25;
extern double shortrange = 20;

the compiler was ok with that....

I put this in the top part too..

double t[];
double b[];


then i tried to put the t and b where the indicator would give them it's values....right with the others...

avg = findAvg(period, x);
upper[x] = middle2 + (3.5*avg);
lower[x] = middle2 - (3.5*avg);
t[x] = middle2 + (3.5*avg);
b[x] = middle2 - (3.5*avg);

the compiler was still ok with all this...

then i tried to do this where it orders buys...

if(isCrossed == 1 && Point < t - longrange)

it didn't work and I got this from the compiler...

Compiling 'EMA_CROSSmodv4.mq4'...
'-' - left square parenthesis expected for array C:\Program Files\Interbank FX Trader 4-live mini\experts\EMA_CROSSmodv4.mq4 (350, 38)
'-' - unexpected token C:\Program Files\Interbank FX Trader 4-live mini\experts\EMA_CROSSmodv4.mq4 (350, 38)
')' - assignment expected C:\Program Files\Interbank FX Trader 4-live mini\experts\EMA_CROSSmodv4.mq4 (350, 48)
3 error(s), 0 warning(s)

Last edited by Aaragorn; 06-30-2006 at 01:00 AM.
Reply With Quote