stuck with EA

 

Hi

I'm stuck with this EA, I have an EA with some lines plotted of the highs and lows, and dont know how to make a order when the price crosses those lines, how can I do that?

something changes if the lines are bojects?


dont know what else to do


what is wrong with this?

//if it is going up
   if(PriceInfo[0].high > PriceInformation2[HighestCandle21].high )
     {

      //create a buy signal
      signal="buy";
     }

//if it is going down
   if(PriceInfo[0].low < PriceInformation4[LowestCandle21].low )
     {
      //create a buy signal
      signal="sell";
     }
 
you are only assigning variables to the "signal". do you have another Function or whatever to do the trading? do you need to return "signal" to tell the function to buy or sell?
 
Bernard Ho:
you are only assigning variables to the "signal". do you have another Function or whatever to do the trading? do you need to return "signal" to tell the function to buy or sell?
   if(signal =="sell" && PositionsTotal()<2)

     {
      trade.Sell(volume,NULL,Bid,STOPSHORT,f,NULL);    //trade.Sell(volume,NULL,Bid,sl,tp,NULL);
      //buy 10 microlot
     }
  if(signal =="buy" && PositionsTotal()<2)

     {
      trade.Buy(volume,NULL,Ask,STOPLONG,h,NULL);    //trade.Sell(volume,NULL,Ask,sl,(Ask+tp * _Point),NULL);
     }


   CheckTrailingStop3(h);    ///para el tp de buy
   CheckTrailingStop4(f);   ///para el tp de sell
//    }
/**
   Comment(
      "Highest candle within the last 10 candles: ",HighestCandleD1_10, "and its value is: ",PriceInformation1[HighestCandle11].high,"\n",
      "Highest candle within the last 20 candles: ",HighestCandleD1_20, "and its value is: ",PriceInformation2[HighestCandle21].high, "\n",
      "Lowest candle within the last 10 candles: ",LowestCandleD1_10, "and its value is: ",PriceInformation3[LowestCandle11].low, "\n",
      "Lowest candle within the last 20 candles: ",LowestCandleD1_20, "and its value is: ",PriceInformation4[LowestCandle21].low, "\n",
      "El valor de ATR: ",ATRValue,"\n",
      "El StopLong superior es: ",STOPLONG," y el StopShort es: ",STOPSHORT,"\n",
      "El TP del Long es: ",h,"y el TP del Short es: ",f
   );

**/

  }



//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
void create_hline(string name, double price0, ENUM_LINE_STYLE style, int width, color _color)
  {
   if(ObjectFind(0,name)<0);
   ObjectCreate(0,name,OBJ_HLINE,0,0,0);
   ObjectSetDouble(0,name,OBJPROP_PRICE,0,price0);
   ObjectSetInteger(0,name,OBJPROP_WIDTH,width);
   ObjectSetInteger(0,name,OBJPROP_STYLE,style);
   ObjectSetInteger(0,name,OBJPROP_COLOR,_color);
  }
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
void CheckTrailingStop3(double h)
  {
   double iPs=NormalizeDouble(h,_Digits); //h

//
//     }
   for(int i=PositionsTotal()-1; i>=0; i--)
     {
      string symbol=PositionGetSymbol(i);

      if(_Symbol==symbol)
        {
         ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
         
         double CurrentTPs=(POSITION_TP);
         
         if(CurrentTPs>iPs)
           {
            trade.PositionModify(PositionTicket,0,(CurrentTPs));
           }
        }
     }
  }

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

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


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//
void CheckTrailingStop4(double f)
  {
   double iPi=NormalizeDouble(f,_Digits);  //f

//
//     }
   for(int i=PositionsTotal()-1; i>=0; i--)
     {
      string symbol=PositionGetSymbol(i);

      if(_Symbol==symbol)
        {
         ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
         double CurrentTPi=(POSITION_TP);
         if(CurrentTPi<iPi)
           {
            trade.PositionModify(PositionTicket,0,(CurrentTPi));
           }
        }
     }
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

Ive used this ... but gives problems because of stops ....