The so-called anti-martingale system, with a limit on the number of increases. If you close on profit, the next lot is increased by a factor. If there is a loss, or if the number of profitable positions in a row exceeds the specified number, the lot is equal to the starting lot.
Once the specified number of profitable positions is exceeded, how do I start the cycle of increasing again?
int K_U_=5;
double LotExponent=2.00;
//+------------------------------------------------------------------+double llot()
{
double lt1=LotLastCloPos(Symbol(),m_magic);//лот последней закрытой позиции
if(CountProfit(Symbol(),m_magic)>=1 && CountProfit(Symbol(),m_magic)<K_U_)
LotSize=lt1*LotExponent;//else
LotSize=Lots;
return(LotSize);
}
The so-called anti-martingale system, with a limit on the number of increases. If you close on profit, the next lot is increased by a factor. If there is a loss, or if the number of profitable positions in a row exceeds the specified number, the lot is equal to the starting lot.
Once the specified number of profitable positions is exceeded, how do I start the cycle of increasing again?
/
Example inStop Loss Take Profit code: lot size is stored (overwritten, increased and reset to minimum) in the "ExtLot" variable, declared at global program level (in the header). OnTradeTransaction() catches trades of the "Market Exit" type and checks how the trade was closed - at Take Profit or Stop Loss:
Example inStop Loss Take Profit code: lot size is stored (overwritten, increased and reset to minimum) in "ExtLot" variable declared on global program level (in the header). OnTradeTransaction() catches trades of the "Market Exit" type and checks how the trade was closed - at Take Profit or Stop Loss:
If at Stop Loss, we double the lot, if at Take Profit, we reset the lot size to its minimum value.
Note: in the Expert Advisor is slightly incorrect calculation of Stop Loss and Take Profit - but soon republished code.
I calculate the number of profitable trades going in a row, if it exceeds 5, then I return to the initial lot, position 6 opens with the initial lot and position 7 should open with volume = lot 6 multiplied by the coefficient, etc. When there are 5 more profitable positions, go back to the initial lot.
Profitable positions are 20 in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16
I calculate the number of profitable trades in a row, if it exceeds 5, then I return to the initial lot, position 6 opens with the initial lot and position 7 should open with volume = lot 6 multiplied by the coefficient, etc. When there are 5 more profitable positions, go back to the initial lot.
Profitable positions are 20 in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16
You need to use a static variable in the lot counting function. Here's how it works:
You need to use a static variable in the lot counting function. Here's how it works:
Result:
I reset according to your example, but I can't get the order of the lot increase
There are 20 profitable positions, in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16 but it should be1, 2, 4, 8,16, 1, 1, 1, 1, 1,............
I am zeroing according to your example, but I am not getting the order of the lot increase
There are 20 profitable positions, in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16 and it turns out so1, 2, 4, 8,16, 1, 1, 1, 1, 1,............
What's wrong?
So you still do not want to use OnTradeTransaction in a normal way? So, you prefer to request EXACTLY the entire trading history (since 1970)? Why?
/
/
Example inStop Loss Take Profit code: lot size is stored (overwritten, increased and reset to minimum) in the "ExtLot" variable, declared at global program level (in the header). OnTradeTransaction() catches trades of the "Market Exit" type and checks how the trade was closed - at Take Profit or Stop Loss:
If at Stop Loss, we double the lot, if at Take Profit, we reset the lot size to its minimum value.
Note: in the Expert Advisor itself the calculation of Stop Loss and Take Profit is a little bit incorrect - but the code will be republished soon.
Example inStop Loss Take Profit code: lot size is stored (overwritten, increased and reset to minimum) in "ExtLot" variable declared on global program level (in the header). OnTradeTransaction() catches trades of the "Market Exit" type and checks how the trade was closed - at Take Profit or Stop Loss:
If at Stop Loss, we double the lot, if at Take Profit, we reset the lot size to its minimum value.
Note: in the Expert Advisor is slightly incorrect calculation of Stop Loss and Take Profit - but soon republished code.
I calculate the number of profitable trades going in a row, if it exceeds 5, then I return to the initial lot, position 6 opens with the initial lot and position 7 should open with volume = lot 6 multiplied by the coefficient, etc. When there are 5 more profitable positions, go back to the initial lot.
Profitable positions are 20 in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16
I calculate the number of profitable trades in a row, if it exceeds 5, then I return to the initial lot, position 6 opens with the initial lot and position 7 should open with volume = lot 6 multiplied by the coefficient, etc. When there are 5 more profitable positions, go back to the initial lot.
Profitable positions are 20 in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16
You need to use a static variable in the lot counting function. Here's how it works:
Result:
0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2You need to use a static variable in the lot counting function. Here's how it works:
Result:
I reset according to your example, but I can't get the order of the lot increase
There are 20 profitable positions, in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16 but it should be1, 2, 4, 8,16, 1, 1, 1, 1, 1,............
What is wrong?
I am zeroing according to your example, but I am not getting the order of the lot increase
There are 20 profitable positions, in a row. Their lots should be 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16, 1, 2, 4, 8,16 and it turns out so1, 2, 4, 8,16, 1, 1, 1, 1, 1,............
What's wrong?
So you still do not want to use OnTradeTransaction in a normal way? So, you prefer to request EXACTLY the entire trading history (since 1970)? Why?
So you don't want to work properly with OnTradeTransaction? So you prefer to request ABSOLUTELY ALL trading history (since 1970)? Why???
Found a reason, brackets.
What do you mean I don't want to, what doesOnTradeTransaction have to dowith my question ;)
Now, I see, two posts before my question, an example of the calculation.
Thank you.
Found the reason, brackets.
What do you mean I don't want to, what doesOnTradeTransaction have to dowith my question;)
Just asking for trading history
means requesting all, all, all of the history from that trading account since 1970. This is very sub-optimal:
Please share the functions that work with the trading history.
I need to get information about the date of last trade opening, closing, volume, financial result and its type (buy or sell).
If you have any similar functions, please share them.