Help with increasing StepSize and TakeProfit

 

HELP!

What I have is an existing Martingale program I want to modify.

The lot increase works fine. At or above SwitchLots I want the StepSize

to increase by AddSteps and like wise the TakeProfit by the same amount.

Then at AddSteps_2 to increase and additional amount and like wise the TakeProfit.

All should be cumulative. I concidered using Static int and GlobalVariableSet

but did not have any luck with either. I'm now thinking that getting the data from the previous trade

and doing the math might be better. Some reason I am not getting that to work either.

Example per given inputs:

Lots stepSize actual pip moved T/P actual pips

.01 open =1 9

.02 5 6 14

.04 7 13 21

.08 9 22 30

.16 11 33 41

.32 13 46 54

.64 17 63 71

1.28 21 84 92

2.56 25 109 117

and so on


// external inputs I would likle to use


extern int StepSize = 5;
extern string TP = "Min TakeProfit > StepSize + Bid Ask Spread";
extern double TakeProfit = 7;
extern double StopLoss = 60;
extern double NbrLots = 0.01;
extern double MaxLots = 41;
extern string SL = "What lot size to start increasing the step size";
extern double SwitchLots = 0.04;
extern string AS = "How much to add to step size";
extern int AddSteps = 2;
extern string SL2 = "What lot size to start increasing the step size #2";
extern double SwitchLots_2 = .32;
extern string AS2 = "How much to add to step size #2 cumulative";
extern int AddSteps_2 = 2;


// Exsisting code I copied from my EA. Just the buy side. Sell side simular.

int gi_96;
double gd_100;

int deinit() {
return (0);
}

void OpenBuy() {
int l_ord_ticket_0;
if (!GlobalVariableCheck("InTrade")) {
GlobalVariableSet("InTrade", TimeCurrent());
l_ord_ticket_0 = OrderSend(Symbol(), OP_BUY, gd_100, Ask, 1, 0, Ask + TakeProfit * Point, "MoneyPrinter", gi_96, 0, Red);
GlobalVariableDel("InTrade");
}
}

void ManageBuy() {
int l_datetime_0 = 0;
double l_ord_open_price_4 = 0;
double l_ord_lots_12 = 0;
double l_ord_takeprofit_20 = 0;
int l_ord_type_28 = -1;
int l_ord_ticket_32 = 0;
int li_36 = 0;
for (li_36 = 0; li_36 < OrdersTotal(); li_36++) {
OrderSelect(li_36, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() != gi_96 || OrderType() != OP_BUY) continue;
if (OrderOpenTime() > l_datetime_0) {
l_datetime_0 = OrderOpenTime();
l_ord_open_price_4 = OrderOpenPrice();
l_ord_type_28 = OrderType();
l_ord_ticket_32 = OrderTicket();
l_ord_takeprofit_20 = OrderTakeProfit();
}
if (OrderLots() > l_ord_lots_12) l_ord_lots_12 = OrderLots();
}
int li_40 = MathLog(l_ord_lots_12 / NbrLots) / MathLog(2) + 1.0;
if (li_40 < 0) li_40 = 0;
gd_100 = NbrLots * MathPow(2, li_40);
if (li_40 == 0) OpenBuy();
if (l_ord_open_price_4 - Ask > StepSize * Point) {
OpenBuy();
return;
}
for (li_36 = 0; li_36 < OrdersTotal(); li_36++) {
OrderSelect(li_36, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() != gi_96 || OrderType() != OP_BUY || OrderTakeProfit() == l_ord_takeprofit_20 || l_ord_takeprofit_20 == 0.0) continue;
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), l_ord_takeprofit_20, 0, Red);
}
}

int start() {

ManageBuy();
ManageSell();
return (0);
}

Reason: