[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 697

 
rensbit:
The angle of the anchor is from which angle the position of the object in the window will be counted. Angles are counted clockwise from left to right.

If I snap to the bottom right corner, then what, should I set negative coordinates?
 
valenok2003:

If I snap to the bottom right corner, do I set negative coordinates?
No, positive coordinates, the terminal calculates the desired point by itself. For example: 15 pixels from the 2nd corner
 
Azerus:

Please advise,

In order to calculate the number of continuous events (e.g. the number of bars in a series in which the close is higher than the open and vice versa), I could only come up with the following:

Two questions (if the above makes sense): (1) how to reset the counter reading if the continuous series has stopped; and (2) how to correctly write Buffer[i] - i.e. how can I "see" the result itself?

I.e., if the indicator for a certain bar shows "-3", it means that it is the third bar in succession which closed below the opening; if the next bar after it closes above the opening, the indicator will show "1" ......

int i=Bars-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, positive coordinates, the terminal will calculate the desired point itself. For example: 15 pixels from 2 corners
Thank you, it worked.
 
artmedia70:
Show us your code so we don't have to guess


Made in the Gorando program, with your martin added.

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

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

#define MIN_STOPLOSS_POINT 10
#define MIN_TAKEPROFIT_POINT 10
#define MAGIC 218650

extern string sNameExpert = "Generate from 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 Lot = 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";
extern color colorOpenBuy = Blue;
extern colorCloseBuy = Aqua;
extern colorOpenSell = Red;
extern colorCloseSell = Aqua;


void deinit() {
Comment(");
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start(){
if (lFlagUseHourTrade){
if (!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)) {
Comment("Time for trade has not come yet!");
return(0);
}
}

if(Bars < 100){
Print("bars less than 100");
return(0);
}

if(nAccount > 0 && nAccount != AccountNumber()){
Comment("Trade on account : "+AccountNumber()+" FORBIDDEN!");
return(0);
}

if((dBuyStopLossPoint > 0 && dBuyStopLossPoint < MIN_STOPLOSS_POINT) ||
(dSellStopLossPoint > 0 && dSellStopLossPoint < MIN_STOPLOSS_POINT)){
Print("StopLoss less than " + MIN_STOPLOSS_POINT);
return(0);
}
if((dBuyTakeProfitPoint > 0 && dBuyTakeProfitPoint < MIN_TAKEPROFIT_POINT) ||
(dSellTakeProfitPoint > 0 && dSellTakeProfitPoint < MIN_TAKEPROFIT_POINT)){
Print("TakeProfit less than " + MIN_TAKEPROFIT_POINT);
return(0);
}

double diOpen0=iOpen(NULL,60,0);
double d1=(0.00030);
double diHigh2=iHigh(NULL,60,0);
double diOpen3=iOpen(NULL,60,0);
double 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);
double d11=(0.00030);
double diHigh12=iHigh(NULL,60,0);
double diOpen13=iOpen(NULL,60,0);
double 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("We have no money. Free Margin = " + 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()){

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

if (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) {
if (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);
}
}
}
}
}
}
return (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);
}

//+----------------------------------------------------------------------------+
//| Author : Kim Igor V. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Version : 19.02.2008 |
//| Description : Returns flag of loss of last position. |
//+----------------------------------------------------------------------------+
//| Parameters: |
//| sy - name of the instrument (" - any symbol, |
//| NULL - current symbol) |
| //| op - operation (-1 - any position) |
//| mn - MagicNumber (-1 - any magik) |
//+----------------------------------------------------------------------------+
bool isLossLastPos(string sy="", int op=-1, int mn=-1) {
datetime t;
int i, j=-1, k=OrdersHistoryTotal();

if (sy=="0") sy=Symbol();
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) {
if (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 Lots_New = Lot;

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


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

if (dBuyTakeProfitPoint > 0)
dTakeProfit = Bid + dBuyTakeProfitPoint * Point;

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 Lots_New = Lot;

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

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

if (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:

If it's not hard to fix the example, I can't get it to work for some reason.
      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);

I made the variable corner external (for convenience). It contains the number of the corner from which the coordinates will be calculated

 
Roger:


Try to replace with

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

to

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

Roger, thanks, but it still doesn't work correctly. Tried another trawl, but the error is still there :( Is there any difference between trailing one pose and trailing several at the same time?
 
rensbit:

I made the corner variable external (for convenience). It contains the number of the corner from which the coordinates will be calculated

Thank you!

One more question. How to correctly insert the symbol from Wingdings into the comments.

 
which symbol?
 
rensbit:
which symbol?

copyright