[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 568

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Help me write a condition to open a position.
I can't write an additional condition to open a position according to my idea.
If I close any position with TP or SL it should reopen with the opposite position.
Example: If a Sell position, say SL, is closed, it will reopen a Sell position together with it and Buy
Here are 2 conditions from the Expert Advisor:
condition to buy
if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_BUY,Magic)<MaxOrders)OPENORDER ("Buy");
}
sell condition
if (SELL)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_SELL,Magic)<MaxOrders)OPENORDER ("Sell");
}
Who is good at this, please help me write additional condition.
Help me write a condition to open a position.
I can't write an additional condition to open a position according to my idea.
If I close any position with TP or SL it should reopen with the opposite position.
Example: If a Sell position, say SL, is closed, it will reopen a Sell position together with it and Buy
Here are 2 conditions from the Expert Advisor:
condition to buy
if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_BUY,Magic)<MaxOrders)OPENORDER ("Buy");
}
sell condition
if (SELL)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_SELL,Magic)<MaxOrders)OPENORDER ("Sell");
}
Who is good at this, please help me write additional condition.
I don't understand what you want. You want to open two opposite positions after closing a position? Then maybe that. But you can just give the AC on the spread instead of opening a position. It will be the same.
Good afternoon. Can you tell me how to solve a problem? There are two points, one to the left of the zero bar and one to the right of the zero bar. I need to calculate the number of bars between these points. If we simply take time intervals, according to the timeframe, the number of bars is not considered correctly when we get to Friday.
Are there any other solutions?
Please help to solve the problem
Please help solve the problem
Shift both points to the left by the same number of bars so that they are both to the left of the zero bar. I apologise, wrong mistake, so that the right one is on the zero bar.
Shift both points to the left by the same number of bars so that they are both to the left of the zero bar. Sorry, my mistake, the right one should be on the zero bar.
P.S. I've been thinking a bit and realised I'm answering the wrong question. The number of bars to the right of the zero bar cannot be determined accurately, because they are not yet present and, apart from the weekend, there may be skipped bars (when the price does not change during one bar, it is not "drawn"), missing quotes immediately after the market opening, etc.
P.S. I thought a bit and realised I was answering the wrong question. The number of bars to the right of the zero bar cannot be determined in principle, because they are not there yet, and apart from weekends there may be skipping bars (when the price does not change during one bar, it is not "drawn"), no quotes immediately after the market opening, etc.
Are you sure you know what you are writing? The attached script calculates the right point of the trend line (shift in bars relative to the 0th). Draw a trend line on the chart and give it a name, which you insert in the script.
The question didn't say anything about the trend line. the question was -- determine the number of bars between the two points.
The question was not about a trend line. The question was about determining the number of bars between two points.
In this case through the "trend line" is one way of solving the said problem. And I mean your statement:"The number of bars to the right of the zero point cannot be determined accurately in principle...". - You tell that to the developers! :))
We can forecast them, but we can't say for sure if they will be there or not, because the zero bar is the last open bar at the moment and whether the forecast will be correct or not depends on many factors. By the way just using the trend line in the case when the zero bar is the last bar on Friday, just get the wrong number of bars between points.
P.S. And try to tell the developers that you know exactly how many bars will be formed, for example, one-minute bars from the current moment per day or even per hour.