Newbie asking

 

how to write code lotscalp():

double a = OrderLots()*((OrderStopLoss()-OrderOpenprice())*10000);

double b= lotscalp()*((Ask-OrderStopLoss())*10000);

a/b=1, how i must write to search value lotscalp?

 

Not sure what you are asking, but is this what you want?

double
   risk  = ( OrderOpenPrice()  - OrderStopLoss() ) * OrderLots(),
   delta =   OrderClosePrice() - OrderStopLoss()                , // Where OrderClosePrice() is current price of the open Order (Ask or Bid)
   lots  = risk / delta                                         ; // Lots for Scalp???
 
Beni Kurniawan:

how to write code lotscalp():

double a = OrderLots()*((OrderStopLoss()-OrderOpenprice())*10000);

double b= lotscalp()*((Ask-OrderStopLoss())*10000);

a/b=1, how i must write to search value lotscalp?

I would think


   lotscalp()=a/(Ask-OrderStopLoss())*10000;

 
Keith Watford: I would think - lotscalp()=a/(Ask-OrderStopLoss())*10000;

Yes, that is equivalent to my answer, but since "a/b" is a ratio, I removed the "10000" from the equations as the result will be the same and saves on computations.

Also, since I am assuming by "Ask" that the OP means the current price for the open order (Ask for a Sell, and Bid for a Buy), he can just use OrderClosePrice instead.

I also switched the ordering of the expression "OrderStopLoss()-OrderOpenprice()" so that the "a/b" ratio would automatically cancel out the signs and always return a positive value.

PS! You left out the parenthesis: "lotscalp = a/ ( (Ask-OrderStopLoss())*10000 ) ;"

 

Hello Fernando,

I wasn't sure what he was asking, I just  "changed sides" as you do in algebra. I don't know what happened to the parenthesis as I just cut and pasted basically. Weird!

 
  1. double a = OrderLots()*((OrderStopLoss()-OrderOpenprice())*10000);
    double b= lotscalp()*((Ask-OrderStopLoss())*10000);
    Don't hard code 10000. Breaks on JPY pairs. Adjust SL, TP, and slippage for 4/5 digit brokers/JPY pairs.
    double   pip        = StringFind(_Symbol,"JPY") < 0 ? 0.01 : 0.0001;
    int      pip_digits = (int)MathLog10(pip/_Point);
    int      slippage   = 3 * int(pip / _Point);

    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out
 
whroeder1:
  1. double a = OrderLots()*((OrderStopLoss()-OrderOpenprice())*10000);
    double b= lotscalp()*((Ask-OrderStopLoss())*10000);
    Don't hard code 10000. Breaks on JPY pairs. Adjust SL, TP, and slippage for 4/5 digit brokers/JPY pairs.
    double   pip        = StringFind(_Symbol,"JPY") < 0 ? 0.01 : 0.0001;
    int      pip_digits = (int)MathLog10(pip/_Point);
    int      slippage   = 3 * int(pip / _Point);

    • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
    • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
    • Do NOT use TickValue by itself - DeltaPerLot
    • You must normalize lots properly and check against min and max.
    • You must also check FreeMargin to avoid stop out

i will write in math equations to be easily understood. Becasuse of my poor language.

Fernando Carreiro:

Yes, that is equivalent to my answer, but since "a/b" is a ratio, I removed the "10000" from the equations as the result will be the same and saves on computations.

Also, since I am assuming by "Ask" that the OP means the current price for the open order (Ask for a Sell, and Bid for a Buy), he can just use OrderClosePrice instead.

I also switched the ordering of the expression "OrderStopLoss()-OrderOpenprice()" so that the "a/b" ratio would automatically cancel out the signs and always return a positive value.

PS! You left out the parenthesis: "lotscalp = a/ ( (Ask-OrderStopLoss())*10000 ) ;"

 idea it was like this.

Second and subsequent orders will not be open when AccountEquity () <AccountBalance ().

When the trailing stop moving stoploss above the open price. Then the value of the bid at the time it becomes a second order for OP_BUY.

The second stoploss and take profit should be identical to the first.

I need writing Lotscalp value () so that when the second order if to touch the stoploss value that has been moved to break even value. Because the first transaction gains and losses on the second transaction.

so I use a mathematical equation that the value of the value lotscalp progressive move. Following benefits if they move to touch stoploss order
Reason: