Fractal Break Out-Stuck - page 6

 

first about that bracket

see this  

 

 int total = OrdersTotal();
if(total<1)
{

//--------------------------------------//
//------------Money Management----------//
 if (Money.Management)
   {
      if (Risk<1 || Risk>1000)
      {
         Comment("Invalid Risk Value.");
         return(0);
      }
      else
      {
         Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*pips2dbl*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT);
      }
   }
//------------------------------------------//
//-------------EMA SETTINGS-----------------//
double EMA=iMA(NULL,0,MA_Period,MA_Shift,MA_Type,MA_Price,0);
double BarClose;
BarClose=Bid;

//---------------------------------------------------------//
//-----------------FRACTALS--------------------------------//
double fractalU=iFractals(NULL,Fractal_TF,1,Fractal_Buffer);
double fractalD=iFractals(NULL,Fractal_TF,2,Fractal_Buffer);
Print( "This Up Fractal is",fractalU,"Down Fractal is",fractalD);

//----------------PRCOESSING BUY---------------------------//
if(BarClose>EMA && BarClose== fractalU)
{
double SLB=Bid-StopLoss*pips2dbl;
double TPB=Bid+TakeProfit*pips2dbl;
int buy= OrderSend(Symbol(),0,Lots,Ask,Slippage*pips2points,0,0);
}

if(buy>0) 
{
OrderSelect(buy,SELECT_BY_TICKET,MODE_TRADES);
OrderModify(buy,OrderOpenPrice(),SLB,TPB,0,Green);
}

//---------PROCESSING SELL---------//
if(BarClose<EMA&&BarClose==fractalD)
{
double SLS=Ask+StopLoss*pips2dbl;
double TPS=Ask-TakeProfit*pips2dbl;

int sell= OrderSend(Symbol(),1,Lots,Bid,Slippage*pips2points,0,0);
}

if (sell>0)
{
OrderSelect(sell,SELECT_BY_TICKET,MODE_TRADES);
OrderModify(sell,OrderOpenPrice(),SLS,TPB,0,Green);
}




//----------------------------------------------//
//-----------------EXITING ORDERS---------------//

for(int i=OrdersTotal()-1; i>=0;i--)          <===HOW Can be here one trade in the loop if OrdersTotal() < 1 
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)  break;

if(OrderMagicNumber()!=MagicNumber || OrderSymbol() !=Symbol()) continue;

double SL=OrderStopLoss();
bool result;
int  error;
//-----The Differnt Order types---//

if(OrderType()==OP_BUY)
{

  if(BreakEven>0)
  {
   
     if(Bid-OrderOpenPrice() >=BreakEven*pips2dbl)
     {
      
        if(OrderStopLoss() <OrderOpenPrice())
        {
         
          SL=OrderOpenPrice()+Point;
        }
     }
  }
}
                  
          

if(OrderType()==OP_SELL){

 if(BreakEven>0)
 {
  
    if(OrderOpenPrice()-Ask >= BreakEven*pips2dbl)
    {
     
       if(OrderStopLoss()>OrderOpenPrice())
       {
        
          SL=OrderOpenPrice() - Point;
    
       }
    }
  }
}


if(SL != OrderStopLoss()) result=OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,CLR_NONE);
         if(result!=TRUE) { error=GetLastError(); Print("ModifyError = ",OrderTicket(),"   ",error);}     
}
return(0);
}//THIS IS THE BRACKET FOR ORDERS OPEN CLOSE********************

 

 I don't think you can explain what i pointed out here....

 

about the fractals......   what is this test doing ???

   double fractalU;
   for(int y=0;fractalU < Point;y++)
     {
      fractalU=iFractals(NULL,0,1,y);
      Alert("fractalUp  y =  "+y+ " "+fractalU);
     } 

 Do the same and you will see what bar you have to choose for getting right fractalbar 

.

Do we have the fractals always at the same bar ??? 

 

I see about the:

It would be impossible to enter this loop if there is no trade on. I need to code a differnt Orders Accounting section

for(int i=OrdersTotal()-1; i>=0;i--)          <===HOW Can be here one trade in the loop if OrdersTotal() < 1 
{

 
deVries:

about the fractals......   what is this test doing ???

 Do the same and you will see what bar you have to choose for getting right fractalbar 

.

Do we have the fractals always at the same bar ??? 


Yes it is always at the same bar, no matter fractal up or fractal down....

 
//---------------FRACTAL INPUTS--------------------//
extern string Label6="===FRACTAL INPUTS===";
extern int    Fractal_Buffer=0;
extern int    Fractal_TF=0;


//--------Start Funcitons-------//
int start()
{

//-----------------FRACTALS--------------------------------//
double fractalU=iFractals(NULL,Fractal_TF,1,Fractal_Buffer);
double fractalD=iFractals(NULL,Fractal_TF,2,Fractal_Buffer);
Print( "This Up Fractal is",fractalU,"Down Fractal is",fractalD);

 Your code Fractal_Buffer  = 0   ALLWAYS 0

 The test I gave showed there was never a fractal to find at  Bar 0

DO THE TEST........   LEARN 

   double fractalU;
   for(int y=0;fractalU < Point;y++)
     {
      fractalU=iFractals(NULL,0,1,y);
      Alert("fractalUp  y =  "+y+ " "+fractalU);
     } 
 

I am sorry I am doing such a bad job communicating my finding deVries.


I have run the test and yes there is never a fractal at bar 0.

I see what your doing, you want me to use for(loop) to find the y to use in place of Fractal_Buffer, because it should not always be set =0.

 
ZacharyRC:

I am sorry I am doing such a bad job communicating my finding deVries.


I have run the test and yes there is never a fractal at bar 0.

I see what your doing, you want me to use for(loop) to find the y to use in place of Fractal_Buffer, because it should not always be set =0.




   double fractalU;
   for(int y=0;fractalU < Point;y++)
     {
      fractalU=iFractals(NULL,0,1,y);
     } 
     
double fractalD;
for(int x=0;fractalD< Point;x++)
 {
 fractalD=iFractals(NULL,0,2,x);
 }

 

What I am struggling to understand about coding, is that the EA was still taking correct trades with the other fractal code, which was incorrect.

Also, moving the stop once, did not happen when I took the time-filter off which is incorrect either.


I am currently working on my order accounting...but the book makes it difficult for a lot of these things take creativity.


Thank you for your mighty patience!

 
AHHHH I cannot move the stop because of this hahaha Im am very slow
int total = OrdersTotal();
if(total<1)
{


Reason: