[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 33

 
Andrew1001:

Good evening. Please advise me where and what I did wrong!

First - please insert the code via the appropriate button in your post.

Secondly, there is no If function in MQL4.

int start()


{
int cnt, ticket, total, profit;
total = OrdersTotal();
if(total < 1)
{
ticket=OrderSend(Symbol(),OP_BUY,LotTrend,Ask,0,Ask-SL*Point,Ask+TP*Point,0,511,0,Green);
}
profit = OrderProfit();
If (OrderProfit < 0) /*если сработал стоплосс*/
{
ticket=OrderSend(Symbol(),OP_SELL,LotTrend,Bid,0,Bid+SL*Point,Bid-TP*Point,0,511,0,Red);
} /*открываем позицию в противоположном направлении*/
return;
}

Мне выдает такие ошибки:
'If' - function is not defined
'<' - left parenthesis expected
'{' - semicolon expected
ПОДСКАЖИТЕ ПОЖАЛУЙСТА что я сделал не так! 
 
Arles:

Good afternoon everyone!

About a week ago I started learning programming and got an interesting result. I don't know if I can trust it. I have just thought of an indicator for a long time and have just now managed to implement it in code.


It looks good on the whole. There is a question about the difference between the maximum profitable trade and the average profitable trade.

Try to run it on different timeframe: 2003, 2004, year.

I had cases when the trend is positive one year and negative the next one. You can't do it one year at a time.

 
Andrew1001:

Good evening. Please tell me where and what I did wrong!

int start()


{
int cnt, ticket, total, profit;
total = OrdersTotal();
if(total < 1)
{
ticket=OrderSend(Symbol(),OP_BUY,LotTrend,Ask,0,Ask-SL*Point,Ask+TP*Point,0,511,0,Green);
}
profit = OrderProfit();
If (OrderProfit < 0) /*if the stop loss triggered*/
{
ticket=OrderSend(Symbol(),OP_SELL,LotTrend,Bid,0,Bid+SL*Point,Bid-TP*Point,0,511,0,Red);
} /*open position in the opposite direction*/
return;
}

I get these errors:
'If' - function is not defined
'<' - left parenthesis expected
'{' - semicolon expected
PLEASE tell me what I did wrong!


1. (trivia) "If" is spelled with a small "if".

2. (the main thing) to use the OrderProfit() function , the order itself which profit is read should be selected using the OrderSelect() function

To find out what was the result of the last order closing, we need to find the last closed order.

 
abolk:


1. (trivia) "If" is written with a small "if"

2. (most important) to use theOrderProfit() function, the order itself, the profit of which is to be read, should be selected using the OrderSelect() function

To find out what was the result of the last order closing, we need to find the last closed order.

Thank you! Can you tell me how to do it!))
 
Arles:

Good afternoon everyone!

About a week ago I started learning programming and got an interesting result. I don't know if I can trust it. I just invented the indicator a long time ago and only now I was able to implement it in the code.


Here the tester even bluntly wrong counts, or rather with an error, or what, if you, referring to the results, the transaction in -22 negative will be the minimum, then you, if I understand everything correctly, can not be an absolute drawdown 4.00, you have one trade already 20.00 gives, yes, further to go, by the way, you have a drawdown 29049(63%) but then again, how could you get so, if you have only two transactions on about -20)) shorter just something not counted as the tester itself.
 

I've written a function to move all stops to the same level, but in the end each of the open orders closes at its own stop loss, which was specified at opening, i.e. I guess the stops are not moved anywhere, what could be the problem?

void OrModSL(string period)//function to move stop to the bottom fractal of the 15-minute chart

{
if(period=="M15")//if period H1
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
RefreshRates();
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderType()==OP_BUY)//if the last buy order type
{
OrderModify(OrderTicket(),OrderOpenPrice(),dnfrM15,OrderTakeProfit(),0,Blue);
}

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderType()==OP_SELL)
{
OrderModify(OrderTicket(),OrderOpenPrice(),upfrM15,OrderTakeProfit(),0,Blue);//if the last order sell
}
}

return(0);


 

Hello!

Once again, I would like to request an example or link to show how to append information to a file without deleting the previous one, the file pointer is of particular interest (I have never used it before).

Thank you.

 

I don't know where you can learn to write codes, is there a website that says clearly and precisely what and how to write in code so the advisor can place orders, put stops and profits, etc. I don't have money to order an advisor, but the ideas seem very good to me.

 
sting-igor:

I don't know where you can learn to write codes, is there a website that says clearly and precisely what and how to write in code so the advisor can place orders, put stops and profits, etc. I don't have money to order an advisor, but the ideas seem very good to me.



I do not have the money to order an EA, but I think the ideas are very good.
Reason: