[¡AVISO CERRADO!] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen. No puedo ir a ningún sitio sin ti. - página 697

 
rensbit:
El ángulo del ancla es desde el que se contará la posición del objeto en la ventana. Los ángulos se cuentan en el sentido de las agujas del reloj, de izquierda a derecha.

Si me ajusto a la esquina inferior derecha, entonces qué, ¿debo establecer coordenadas negativas?
 
valenok2003:

Si me ajusto a la esquina inferior derecha, ¿pongo coordenadas negativas?
No, coordenadas positivas, el terminal calcula el punto deseado por sí mismo. Por ejemplo: 15 píxeles desde la segunda esquina
 
Azerus:

Por favor, avisa,

Para calcular el número de eventos continuos (por ejemplo, el número de barras de una serie en las que el cierre es mayor que la apertura y viceversa), sólo he podido llegar a lo siguiente:

Dos preguntas (si lo anterior tiene sentido): (1) cómo reiniciar el valor del contador si la serie continua se ha detenido; y (2) cómo escribir correctamente Buffer[i] - es decir, cómo puedo "ver" el resultado en sí mismo.

Por ejemplo, si el indicador de una determinada barra muestra "-3", significa que es la tercera barra consecutiva que cierra por debajo de la apertura; si la siguiente barra cierra por encima de la apertura, el indicador mostrará "1" ......

int i=Barras-1

while (i > 0) {

int x=0;

int y=0;

if ( Close[i] > Open[i] ) { x++ ;

Buf [i]= x; }

if (Close[i] < Open[i] ) { y-- ;

Buf2[i] =y ; }

i--;

}

 
rensbit:
No, coordenadas positivas, el terminal calculará por sí mismo el punto deseado. Por ejemplo: 15 píxeles desde 2 esquinas
Gracias, ha funcionado.
 
artmedia70:
Muestra tu código, para no adivinar


Hecho en el programa Gorando, con su martin añadido.

//+------------------------------------------------------------------+
//| Copyright 2005, Gordago Software Corp.
//| http://www.gordago.com/ |
//| versión 2.0 |
//+------------------------------------------------------------------+

#property copyright "Copyright 2005, Gordago Software Corp."
#enlace de propiedad "http://www.gordago.com"

#define PUNTO_DE_TOPOSICIÓN_MÍNIMA 10
#define MIN_TAKEPROFIT_POINT 10
#define MAGIC 218650

extern string sNombreExperto = "Generar desde Gordago";
extern int nAccount =0;
extern double dBuyStopLossPoint = 0;
extern double dSellStopLossPoint = 0;
extern double dBuyTakeProfitPoint = 0;
extern double dSellTakeProfitPoint = 0;
extern double dBuyTrailingStopPoint = 0;
extern double dSellTrailingStopPoint = 0;
extern double Lote = 0,10;
extern int nSlippage = 30;
extern bool lFlagUseHourTrade = True;
extern inttern nFromHourTrade = 0;
extern intToHourTrade = 23;
extern bool lFlagUseSound = False;
extern string sSoundFileName = "alert.wav";
color externo colorOpenBuy = Azul;
extern colorCloseBuy = Aqua;
extern colorOpenSell = Rojo;
extern colorCloseSell = Aqua;


void deinit() {
Comentario(");
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int inicio(){
si (lFlagUseHourTrade){
if (!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)) {
Comentario("¡Aún no ha llegado la hora del comercio!");
return(0);
}
}

if(Bares < 100){
Print("barras menos de 100");
return(0);
}

if(nCuenta > 0 && nCuenta != Número de cuenta()){
Comentario("Comercio en la cuenta : "+Número de cuenta()+" ¡Prohibido!");
return(0);
}

if((dBuyStopLossPoint > 0 && dBuyStopLossPoint < MIN_STOPLOSS_POINT) ||
(dSellStopLossPoint > 0 && dSellStopLossPoint < MIN_STOPLOSS_POINT)){
Print("StopLoss inferior a " + MIN_STOPLOSS_POINT);
return(0);
}
if((dBuyTakeProfitPoint > 0 && dBuyTakeProfitPoint < MIN_TAKEPROFIT_POINT) ||
(dSellTakeProfitPoint > 0 && dSellTakeProfitPoint < MIN_TAKEPROFIT_POINT)){
Print("TakeProfit menor que " + MIN_TAKEPROFIT_POINT);
return(0);
}

double diOpen0=iOpen(NULL,60,0);
doble d1=(0,00030);
double diHigh2=iHigh(NULL,60,0);
double diOpen3=iOpen(NULL,60,0);
doble d4=(0,00030);
double diLow5=iLow(NULL,60,0);
double diOpen6=iOpen(NULL,60,1);
double diClose7=iClose(NULL,60,1);
double diOpen8=iOpen(NULL,60,2);
double diClose9=iClose(NULL,60,2);
double diOpen10=iOpen(NULL,60,0);
doble d11=(0,00030);
double diHigh12=iHigh(NULL,60,0);
double diOpen13=iOpen(NULL,60,0);
doble d14=(0,00030);
double diLow15=iLow(NULL,60,0);
double diOpen16=iOpen(NULL,60,1);
double diClose17=iClose(NULL,60,1);
double diOpen18=iOpen(NULL,60,2);
double diClose19=iClose(NULL,60,2);


if(AccountFreeMargin() < (1000*Lot)){
Print("No tenemos dinero. Margen libre = " + AccountFreeMargin());
return(0);
}

bool lFlagBuyOpen = false, lFlagSellOpen = false, lFlagBuyClose = false, lFlagSellClose = false;

lFlagBuyOpen = (diOpen0+d1>diHigh2 && diOpen3-d4<diLow5 && diOpen6<diClose7 && diOpen8>diClose9);
lFlagSellOpen = (diOpen10+d11>diHigh12 && diOpen13-d14<diLow15 && diOpen16>diClose17 && diOpen18<diClose19);
lFlagBuyClose = False;
lFlagSellClose = False;

if (!ExistPositions()){

si (lFlagBuyOpen){
OpenBuy();
{ return(0);
}

si (lFlagSellOpen){
OpenSell();
return(0);
}
}
if(ExistPositions()){
if(OrderType()==OP_BUY){
if(lFlagBuyClose){
bool flagCloseBuy = OrderClose(OrderTicket(), OrderLots(), Bid, nSlippage, colorCloseBuy);
if (flagCloseBuy && lFlagUseSound)
PlaySound(sSoundFileName);
return(0);
}
}
if(OrderType()==OP_SELL){
if(lFlagSellClose){
bool flagCloseSell = OrderClose(OrderTicket(), OrderLots(), Ask, nSlippage, colorCloseSell);
if (flagCloseSell && lFlagUseSound)
PlaySound(sSoundFileName);
return(0);
}
}
}

if (dBuyTrailingStopPoint > 0 || dSellTrailingStopPoint > 0){

for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
bool lMagic = true;
if (MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false;

if (OrderSymbol()==Symbol() && lMagic) {
if (OrderType()==OP_BUY && dBuyTrailingStopPoint > 0) {
if (Bid-OrderOpenPrice() > dBuyTrailingStopPoint*Point) {
si (OrderStopLoss()<Bid-dBuyTrailingStopPoint*Point)
ModifyStopLoss(Bid-dBuyTrailingStopPoint*Point);
}
}
if (OrderType()==OP_SELL) {
if (OrderOpenPrice()-Ask>dSellTrailingStopPoint*Point) {
if (OrderStopLoss()>Ask+dSellTrailingStopPoint*Point || OrderStopLoss()==0)
ModifyStopLoss(Ask+dSellTrailingStopPoint*Point);
}
}
}
}
}
}
retorno (0);
}

bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
bool lMagic = true;

if (MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false;

if (OrderSymbol()==Symbol() && lMagic) {
return(True);
}
}
}
return(false);
}

void ModifyStopLoss(double ldStopLoss) {
bool lFlagModify = OrderModify(OrderTicket(), OrderOpenPrice(), ldStopLoss, OrderTakeProfit(), 0, CLR_NONE);
if (lFlagModify && lFlagUseSound)
PlaySound(sSoundFileName);
}

//+----------------------------------------------------------------------------+
//| Autor : Kim Igor V. alias KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Versión: 19.02.2008
//| Descripción : Devuelve la bandera de pérdida de la última posición. ||
//+----------------------------------------------------------------------------+
//| Parámetros: |
//| sy - nombre del instrumento (" - cualquier símbolo, |
//| NULL - símbolo actual) |
| //| op - operación (-1 - cualquier posición) |
//| mn - MagicNumber (-1 - cualquier magik) |
//+----------------------------------------------------------------------------+
bool isLossLastPos(string sy="", int op=-1, int mn=-1) {
datetime t;
int, j=-1, k=Total de pedidos();

if (sy=="0") sy=Símbolo();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderSymbol()==sy || sy==") {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (op<0 || OrderType()==op) {
if (mn<0 || OrderMagicNumber()==mn) {
si (t<OrderCloseTime()) {
t=OrderCloseTime();
j=i;
}
}
}
}
}
}
}
if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderProfit()<0) return(True)
}
return(False);
}





void OpenBuy(){
double dStopLoss = 0, dTakeProfit = 0;
double Lotes_Nuevos = Lote;

si (isLossLastPos(NULL, -1, MAGIC))
Lots_New *= 2;
else if (!isLossLastPos(NULL, -1, MAGIC))
Lotes_Nuevos = Lote;


si (dBuyStopLossPoint > 0)
dStopLoss = Bid-dBuyStopLossPoint*Point;

si (dBuyTakeProfitPoint > 0)
dTakeProfit = Oferta + dBuyTakeProfitPoint * Punto;

int numorder = OrderSend(Symbol(), OP_BUY, Lots_New, Ask, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenBuy);

if (numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName);
}

void OpenSell() {
double dStopLoss = 0, dTakeProfit = 0;
double Lotes_Nuevos = Lote;

si (isLossLastPos(NULL, -1, MAGIC))
Lots_New *= 2;
else if (!isLossLastPos(NULL, -1, MAGIC))
Lotes_Nuevos = Lote;

si (dSellStopLossPoint > 0)
dStopLoss = Ask+dSellStopLossPoint*Point;

si (dSellTakeProfitPoint > 0)
dTakeProfit = Ask-dSellTakeProfitPoint*Point;

int numorder = OrderSend(Symbol(),OP_SELL, Lots_New, Bid, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenSell);

if (numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName);
}

 
valenok2003:

Si no es difícil arreglar el ejemplo, por alguna razón no consigo que funcione.
      ObjectSetText("info", str3, fontsize, fontname);
      ObjectSet("info", OBJPROP_CORNER, corner);
      ObjectSet("info", OBJPROP_XDISTANCE, xdistance);
      ObjectSet("info", OBJPROP_YDISTANCE, ydistance);
      ObjectSet("info", OBJPROP_COLOR, clr);

Hice la esquina variable externa (por comodidad). Contiene el número de la esquina a partir de la cual se calcularán las coordenadas

 
Roger:


Trate de reemplazar con

if (OrderStopLoss()<pp-(TStop.Buy+TrailingStep-1)*po|||OrderStopLoss()==0)

a

if (OrderStopLoss()>pp-(TStop.Buy+TrailingStep-1)*po|||OrderStopLoss()==0)

Roger, gracias, pero sigue sin funcionar correctamente. Intenté otro arrastre, pero el error sigue ahí :( ¿Hay alguna diferencia entre arrastrar una pose y arrastrar varias al mismo tiempo?
 
rensbit:

Hice la variable de la esquina externa (para la conveniencia). Contiene el número de la esquina a partir de la cual se calcularán las coordenadas

Gracias.

Una pregunta más. Cómo insertar correctamente el símbolo de Wingdings en los comentarios.

 
¿Qué símbolo?
 
rensbit:
¿Qué símbolo?

derechos de autor