Why is this EA not working?
Why is this EA not working?

 

Publi

Resultados 1 al 3 de 3

Tema: Why is this EA not working?

  1. #1
    init and deinit are not needed, even this code will work as is: Inserted Code int cnt=0; void start(){cnt ;Comment(Ticks from start ,cnt);} but I get many errors on this ea - there are so many undefined parameters

  2.                         
    Publicidad
  3. #2
    Hola, acabo de echar un vistazo rápido a su EA ... no tiene la función init y deinit ... y lo necesita ...

  4. #3
    Hi,
    Can someone please help me understand why this EA is not working unless the ask manual confirmation button is ticked???

    A trendline drawn on the chart and the description field is populated with the trade parameters in a string such as Action=Buy Trigger=5 TP=60 SL=30 TS=45 BE=10 Lots=1.5

    When the trend line is breached by the trigger pips, a trade should be entered......

    Please help it is driving me crazy!


    #define EA_NAME Trader
    #define MAGIC_NUMBER 456456

    #define PARAM_ACTION Action
    #define PARAM_TRIGGER Trigger
    #define PARAM_TAKEPROFIT TP
    #define PARAM_STOPLOSS SL
    #define PARAM_TRAILSTOP TS
    #define PARAM_BREAKEVEN BE
    #define PARAM_LOTS Lots

    #define GRID_ID 0
    #define GRID_TYPE 1
    #define GRID_TRIGGER 2
    #define GRID_TP 3
    #define GRID_SL 4
    #define GRID_TS 5
    #define GRID_BE 6
    #define GRID_LOTS 7

    extern int Slippage = 30;
    extern bool EmailAlert = false;
    extern bool PopupAlert = false;



    int start() {

    /grid to hold order info
    string sGrid[0][8];
    ArrayResize(sGrid,0);

    //Inspeccionar líneas para pedidos pendientes
    doManageLineActions(sGrid);

    /Manage open positions
    /This is done after lines are checked so if an order is submid
    /it will show up in the grid as an open position.
    doManagePositions (sGrid);

    doDrawGrid (sGrid);

    return(0);
    }

    anular doManageLineActions (cadena sGrid [] []) {

    /iterate all objects on chart
    for (int i = ObjectsTotal () - 1; igt; = 0; i -) {

    /get object name and price at current bar
    /if no price then simply move on
    Nombre de cadena = Nombre del objeto (i);
    double dPrice = getLinePrice(sName);

    if (dPrice lt; 0) continue;

    /get the par for the object starting with Action.
    /if action isn't defined then simply move on
    string sEction = getParam (Name, PARAM_ACTION);
    if (sAction != Buy sAction != Sell) continue;

    int iTrigger = StrToInteger(getParam(sName,PARAM_TRIGGER));
    int iTakeProfit = StrToInteger(getParam(sName,PARAM_TAKEPROFIT));
    int iStopLoss = StrToInteger(getParam(sName,PARAM_STOPLOSS));
    int iTrailStop = StrToInteger(getParam(sName,PARAM_TRAILSTOP));
    int iBreakEven = StrToInteger(getParam(sName,PARAM_BREAKEVEN));
    double dLots = StrToDouble(getParam(sName,PARAM_LOTS));

    //determina el rango de activación
    double dTriggerUpper = MathMax(dPrice,dPrice iTrigger*Point);
    double d'TriggerLower = MathMin (d'Price, Price Trigger * Point);

    //si está dentro del rango de activación, envíe una orden
    if (Bid lt;= dTriggerUpper Bid gt;= dTriggerLower) {
    int iTicket = 0;
    if (sAction == Buy) {
    iTicket = OrderSend(Symbol(),OP_BUY,dLots,Ask,Slippage,Ask-iStopLoss*Point,Ask iTakeProfit*Point,Line: sName,MAGIC_NUMBER);
    }
    else if (sAction == Sell) {
    iTicket = OrderSend(Symbol(),OP_SELL,dLots,Bid,Slippage,Bid iStopLoss*Point,Bid-iTakeProfit*Point,Line: sName,MAGIC_NUMBER);
    }

    //agregue trailtop y breakeven a globalvars para permitir el seguimiento a través del reinicio de EA
    GlobalVariableSet(getGlobalVarName(iTicket,PARAM_B REAKEVEN),iBreakEven);
    GlobalVariableSet(getGlobalVarName(iTicket,PARAM_T RAILSTOP),iTrailStop);
    /remove order info from the line
    ObjectSetText(sName,);
    }
    más {
    //agregar a la matriz de pedidos como una acción pendiente
    ArrayResize(sGrid,ArrayRange(sGrid,0) 1);
    int index = ArrayRange (sGrid, 0) -1;

    /Print(Name: ,sName, Action: , sAction, Index: , index);
    sGrid[index][GRID_ID] = sName;
    sGrid [índice] [GRID_TYPE] = getParam (sName, PARAM_ACTION);
    sGrid[index][GRID_TRIGGER] = getParam(sName,PARAM_TRIGGER);
    sGrid[index][GRID_TP] = getParam(sName,PARAM_TAKEPROFIT);
    Cuadrícula [índice] [GRID_SL] = obtener Param (Nombre, PARAM STOPLOSS);
    sGrid[index][GRID_TS] = getParam(sName,PARAM_TRAILSTOP);
    sGrid[index][GRID_BE] = getParam(sName,PARAM_BREAKEVEN);
    sGrid[index][GRID_LOTS] = getParam(sName,PARAM_LOTS);
    }
    }
    }

    /Find open positions owned by this EA and manage them.
    void doManagePositions(string sGrid[][]) {

    /iterate all orders
    for (int i = OrdersTotal () - 1; igt; = 0; i--) {

    //selecciona el orden
    OrderSelect (i, SELECT_BY_POS);

    /if not for this symbol or EA, move on
    if (OrderSymbol ()! = Symbol ()) continuar;
    if (OrderMagicNumber() != MAGIC_NUMBER) continue;

    //ver si hay un trailing stop o break even even definido
    /these would have been previously stored in global vars
    int iTicket = OrderTicket ();
    int iBreakEven = GlobalVariableGet (getGlobalVarName (iTicket, PARAM_BREAKEVEN));
    int iTrailStop = GlobalVariableGet(getGlobalVarName(iTicket,PARAM_T RAILSTOP));
    Print(Trail:, iTrailStop);

    //realiza mantenimiento de stoploss
    double dNewStop = 0;
    if (OrderType() == OP_BUY) {
    /check breakeven
    if (iBreakEven gt; 0 OrderOpenPrice () iBreakEven * Point lt; = Bid)
    dNewStop = OrderOpenPrice();
    /check trailstop
    if (iTrailStop gt; 0)
    dNewStop = MathMax(dNewStop,Bid-iTrailStop*Point);
    //actualizar stoploss si es necesario
    if (dNewStop != 0 dNewStop gt; OrderStopLoss())
    OrderModify(iTicket,OrderOpenPrice(),dNewStop,Orde rTakeProfit(),OrderExpiration());
    }
    if (OrderType () == OP_SELL) {
    /check breakeven
    if (iBreakEven gt; 0 OrderOpenPrice() - iBreakEven * Point gt;= Bid)
    dNewStop = OrderOpenPrice();
    //verifica el trailtop
    if (iTrailStop gt; 0)
    if (dNewStop == 0) dNewStop = Bid-iTrailStop*Point;
    else dNewStop = MathMax(dNewStop,Bid-iTrailStop*Point);
    /update stoploss if required
    if (dNewStop != 0 dNewStop lt; OrderStopLoss())
    OrderModify(iTicket,OrderOpenPrice(),dNewStop,Orde rTakeProfit(),OrderExpiration());
    }

    /add to orders array as an open position
    ArrayResize(sGrid,ArrayRange(sGrid,0) 1);
    int index = ArrayRange (sGrid, 0) -1;
    sGrid[index][GRID_ID] = iTicket;
    if (OrderType() == OP_BUY) sGrid[index][GRID_TYPE] = Buy;
    if (OrderType() == OP_SELL) sGrid[index][GRID_TYPE] = Sell;
    sGrid[index][GRID_TRIGGER] = ;
    sGrid[index][GRID_TP] = DoubleToStr(OrderTakeProfit(),Digits);
    sGrid[index][GRID_SL] = DoubleToStr(OrderStopLoss(),Digits);
    sGrid[index][GRID_TS] = iTrailStop;
    sGrid[index][GRID_BE] = iBreakEven;
    sGrid[index][GRID_LOTS] = OrderLots();
    }
    }


    void doDrawGrid(string sGrid[][]) {

    int col1 = 5;
    int col2 = col1 200;
    int col3 = col2 80;
    int col4 = col3 80;
    int col5 = col4 80;
    int col6 = col5 80;
    int col7 = col6 80;
    int col8 = col7 80;
    string sName;

    for (int i=ObjectsTotal()-1;igt;=0;i--) {
    sName = ObjectName (i);
    if (StringFind (sName, Grid) == 0) ObjectDelete (sName);
    }

    /create column labels
    sName = Grid0_ID;
    if (ObjectFind (sName) == -1) {
    ObjectCreate (sName, OBJ_LABEL, 0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col1);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText(sName,ID);
    }
    sName = Grid0_Type;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col2);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText(sName,Type);
    }
    sName = Grid0_Trigger;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col3);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText(sName,Trigger);
    }
    sName = Grid0_TakeProfit;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col4);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText(sName,TakeProfit);
    }
    sName = Grid0_StopLoss;
    if (ObjectFind(sName) == -1) {
    ObjectCreate (sName, OBJ_LABEL, 0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col5);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText(sName,StopLoss);
    }
    sName = Grid0_TrailStop;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col6);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText(sName,TrailStop);
    }
    sName = Grid0_BreakEven;
    if (ObjectFind (sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet (sName, OBJPROP_XDISTANCE, col7);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText(sName,BreakEven);
    }
    sName = Grid0_Lots;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col8);
    ObjectSet(sName,OBJPROP_YDISTANCE,15);
    ObjectSetText (sName, Lots);
    }

    /iterate objects in grid array and draw them
    for (i=0;ilt;ArrayRange(sGrid,0);i ) {

    int yOffset = 15 (i 1) * 15;

    sName = Grid (i 1) _ID;
    if (ObjectFind(sName) == -1) {
    ObjectCreate (sName, OBJ_LABEL, 0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col1);
    ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
    }
    ObjectSetText (sName, sGrid [i] [GRID_ID]);
    sName = Grid (i 1) _Type;
    if (ObjectFind (sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col2);
    ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
    }
    ObjectSetText (sName, sGrid [i] [GRID_TYPE]);
    sName = Grid (i 1) _ Trigger;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col3);
    ObjectSet (sName, OBJPROP_YDISTANCE, yOffset);
    }
    ObjectSetText(sName,sGrid[i][GRID_TRIGGER]);
    sName = Cuadrícula (i 1) _ TakeProfit;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet (sName, OBJPROP_XDISTANCE, col4);
    ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
    }
    ObjectSetText(sName,sGrid[i][GRID_TP]);
    sName = Grid (i 1) _StopLoss;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col5);
    ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
    }
    ObjectSetText(sName,sGrid[i][GRID_SL]);
    sName = Grid (i 1) _TrailStop;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col6);
    ObjectSet (sName, OBJPROP_YDISTANCE, yOffset);
    }
    ObjectSetText(sName,sGrid[i][GRID_TS]);
    sName = Cuadrícula (i 1) _ BreakEven;
    if (ObjectFind(sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col7);
    ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
    }
    ObjectSetText(sName,sGrid[i][GRID_BE]);
    sName = Grid (i 1) _Lots;
    if (ObjectFind (sName) == -1) {
    ObjectCreate(sName,OBJ_LABEL,0,0,0);
    ObjectSet(sName,OBJPROP_XDISTANCE,col8);
    ObjectSet(sName,OBJPROP_YDISTANCE,yOffset);
    }
    ObjectSetText(sName,sGrid[i][GRID_LOTS]);
    }


    }


    string getGlobalVarName(int iTicket, string sParam) {

    return (EA_NAME _ Symbol () _ iTicket _ sParam);
    }

    string getParam(string sLine, string sParam) {

    //obtén una descripción y suelta un espacio extra en la parte delantera y trasera
    string desc = ObjectDescription(sLine) ;

    /mod the param to match how it would be represented in the desc
    sParam = sParam =;

    /find the index of the param
    int index = StringFind (desc, sParam);

    /strip the description out from in front of the value
    string value = StringSubstr(desc,index StringLen(sParam));

    /strip the description out from behind the value
    index = StringFind (valor,);
    if (index != -1) value = StringSubstr(value,0,index);

    retorno (valor);
    }

    double getLinePrice(string sObjName) {

    int iObjType = ObjectType(sObjName);

    /if it's a horizontal line...
    if (iObjType == OBJ_HLINE)
    return(ObjectGet(sObjName,OBJPROP_PRICE1));

    /if it's a trend line...
    if (iObjType == OBJ_TREND)
    return(ObjectGetValueByShift(sObjName,0));

    /otherwise...
    return(-1);
    }



    *

    /Iterate over objects on this chart
    for (int i=ObjectsTotal()-1;igt;=0;i--) {
    string sObjName = ObjectName(i);
    sección de cadena;
    string sTrigger;
    string sTakeProfit;
    string sStopLoss;
    string sTrailStop;
    string sBreakEven;
    cadena de lotes;

    //si no es una línea horizontal o una línea de tendencia, continúe
    if (ObjectType(sObjName) != OBJ_HLINE ObjectType(sObjName) != OBJ_TREND)
    continue;

    /Is no action on this object, continue
    sAction = getParam(sObjName,Action);
    if (sAction != Buy sAction != Sell)
    continue;

    /Is the line within alert proximity? If not, continue iteration
    iProximity = MathAbs(Bid - dObjPrice)Point;
    if (iProximity gt; iObjAlert) continue;

    /Fire the alert and clear alert from description
    sMessage = Alert triggered: Symbol() @ DoubleToStr(Bid,Digits) .
    iProximity pips from sObjName .;
    if (PopupAlert) Alert(sMessage);
    if (EmailAlert) SendMail(Alert on Symbol(), sMessage);

    /Clear the alert from the object description
    clearObjectAlert(sObjName);
    }










    int getObjectAlert(string sObjName) {

    /looking for parn alert_## at end of obj description
    string sObjectDesc = ObjectDescription(sObjName);
    int iParnOffset = StringFind(sObjectDesc,OBJDESC_PATTERN);
    int iParnLength = StringLen(OBJDESC_PATTERN);

    /if parn not found, no alert for this object
    if (iParnOffset == -1)
    return(-1);

    /return value after the parn as number
    /Print(Alert: , StringSubstr(sObjectDesc,iParnOffset iParnLength));
    return (StrToInteger (StringSubstr (sObjectDesc, iParnOffset iParnLength)));
    }

    void clearObjectAlert(string sObjName) {

    /strip alert_* from end of obj description
    string sObjDesc = ObjectDescription(sObjName);
    int iSubStrOffset = StringFind (sObjDesc, Alert_);

    /if found at start of description, clear description
    if (iSubStrOffset == 0) {
    ObjectSetText (sObjName,);
    regreso;
    }

    /if found further on in desc, strip it from description
    if (iSubStrOffset gt; 0) {
    ObjectSetText(sObjName,StringSubstr(sObjDesc,0,iSu bStrOffset));
    return;
    }
    }

    void createAlertLabel(string sObjName) {

    /Set the text
    string sObjText = Alerter:;
    if (EmailAlert) sObjText = sObjText Alertas por correo electrónico activadas .;
    else sObjText = sObjText Emails Alerts OFF.;
    if (PopupAlert) sObjText = sObjText Popup Alerts ON.;
    más sObjText = sObjText Alertas emergentes OFF .;

    /Create and position the label
    ObjectCreate(sObjName,OBJ_LABEL,0,0,0);
    ObjectSetText(sObjName,sObjText,8,Arial,Yellow);
    ObjectSet(sObjName,OBJPROP_XDISTANCE,5);
    ObjectSet(sObjName,OBJPROP_YDISTANCE,5);
    ObjectSet(sObjName,OBJPROP_CORNER,1);

    }

    */

Permisos de publicación

  • No puedes crear nuevos temas
  • No puedes responder temas
  • No puedes subir archivos adjuntos
  • No puedes editar tus mensajes
  •  
Uso de cookies
Utilizamos cookies propias y de terceros para elaborar información estadística y mostrarle publicidad personalizada a través del análisis de su navegación. Si continúa navegando acepta su uso. Más información y política de cookies.
     

Aviso legal: Ni forosforex.com ni ninguna persona involucrada en forosforex.com aceptarán ninguna responsabilidad por cualquier pérdida o daño en el trading como resultado de la confianza en la información contenida en este sitio web, incluidos datos, cotizaciones, gráficos y señales de compra/venta. Por favor, infórmese plenamente de los riesgos y costes asociados a las operaciones en los mercados financieros, una de las formas de inversión que más riesgos entrañan.
forosforex.com le quiere recordar que los datos contenidos en este sitio web no son necesariamente en tiempo real ni exactos. forosforex.com no asume responsabilidad alguna por las pérdidas en que usted podría incurrir como resultado de la utilización de estos datos. Este acuerdo se rige por su versión en inglés, que prevalecerá siempre que haya alguna discrepancia entre la versión en inglés y la versión en español. Los CFD son un producto difícil de entender, varios organismos reguladores consideran que no es adecuado para inversores minoristas debido a su complejidad y riesgo.
Advertencia de riesgo: Los CFDs son un producto difícil de entender, y puede no ser adecuado para inversores minoristas debido a su complejidad y riesgo. Existe la posibilidad de sufrir una pérdida igual o superior a la inversión. Por lo tanto, no debe invertir o arriesgar dinero que no pueda permitirse perder. Debe asegurarse de que comprende todos los riesgos. Antes de abrir una cuenta en un broker por favor sea consciente e infórmese de los riesgos asociados con el trading. El contenido de este sitio web no debe interpretarse como asesoramiento personal. ForosForex recomienda que busque el consejo de un asesor financiero independiente.